Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -2,135 +2,143 @@ using System;
namespace Server.Items
{
public class MorphItem : Item
{
private int m_InRange;
private int m_OutRange;
public class MorphItem : Item
{
private int m_InRange;
private int m_OutRange;
[CommandProperty( AccessLevel.GameMaster )]
public int InactiveItemID { get; set; }
[Constructible]
public MorphItem(int inactiveItemID, int activeItemID, int range) : this(inactiveItemID, activeItemID, range, range)
{
}
[CommandProperty( AccessLevel.GameMaster )]
public int ActiveItemID { get; set; }
[Constructible]
public MorphItem(int inactiveItemID, int activeItemID, int inRange, int outRange) : base(inactiveItemID)
{
Movable = false;
[CommandProperty( AccessLevel.GameMaster )]
public int InRange
{
get => m_InRange;
set{ if ( value > 18 ) value = 18; m_InRange = value; }
}
InactiveItemID = inactiveItemID;
ActiveItemID = activeItemID;
InRange = inRange;
OutRange = outRange;
}
[CommandProperty( AccessLevel.GameMaster )]
public int OutRange
{
get => m_OutRange;
set{ if ( value > 18 ) value = 18; m_OutRange = value; }
}
public MorphItem(Serial serial) : base(serial)
{
}
[CommandProperty( AccessLevel.GameMaster )]
public int CurrentRange => ItemID == InactiveItemID ? InRange : OutRange;
[CommandProperty(AccessLevel.GameMaster)]
public int InactiveItemID{ get; set; }
[Constructible]
public MorphItem( int inactiveItemID, int activeItemID, int range ) : this( inactiveItemID, activeItemID, range, range )
{
}
[CommandProperty(AccessLevel.GameMaster)]
public int ActiveItemID{ get; set; }
[Constructible]
public MorphItem( int inactiveItemID, int activeItemID, int inRange, int outRange ) : base( inactiveItemID )
{
Movable = false;
[CommandProperty(AccessLevel.GameMaster)]
public int InRange
{
get => m_InRange;
set
{
if (value > 18) value = 18;
m_InRange = value;
}
}
InactiveItemID = inactiveItemID;
ActiveItemID = activeItemID;
InRange = inRange;
OutRange = outRange;
}
[CommandProperty(AccessLevel.GameMaster)]
public int OutRange
{
get => m_OutRange;
set
{
if (value > 18) value = 18;
m_OutRange = value;
}
}
public MorphItem( Serial serial ) : base( serial )
{
}
[CommandProperty(AccessLevel.GameMaster)]
public int CurrentRange => ItemID == InactiveItemID ? InRange : OutRange;
public override bool HandlesOnMovement => true;
public override bool HandlesOnMovement => true;
public override void OnMovement( Mobile m, Point3D oldLocation )
{
if ( Utility.InRange( m.Location, Location, CurrentRange ) || Utility.InRange( oldLocation, Location, CurrentRange ) )
Refresh();
}
public override void OnMovement(Mobile m, Point3D oldLocation)
{
if (Utility.InRange(m.Location, Location, CurrentRange) || Utility.InRange(oldLocation, Location, CurrentRange))
Refresh();
}
public override void OnMapChange()
{
if ( !Deleted )
Refresh();
}
public override void OnMapChange()
{
if (!Deleted)
Refresh();
}
public override void OnLocationChange( Point3D oldLoc )
{
if ( !Deleted )
Refresh();
}
public override void OnLocationChange(Point3D oldLoc)
{
if (!Deleted)
Refresh();
}
public void Refresh()
{
bool found = false;
public void Refresh()
{
bool found = false;
foreach ( Mobile mob in GetMobilesInRange( CurrentRange ) )
{
if ( mob.Hidden && mob.AccessLevel > AccessLevel.Player )
continue;
foreach (Mobile mob in GetMobilesInRange(CurrentRange))
{
if (mob.Hidden && mob.AccessLevel > AccessLevel.Player)
continue;
found = true;
break;
}
found = true;
break;
}
if ( found )
ItemID = ActiveItemID;
else
ItemID = InactiveItemID;
if (found)
ItemID = ActiveItemID;
else
ItemID = InactiveItemID;
Visible = ( ItemID != 0x1 );
}
Visible = ItemID != 0x1;
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 1 ); // version
writer.Write(1); // version
writer.Write( (int) m_OutRange );
writer.Write(m_OutRange);
writer.Write( (int) InactiveItemID );
writer.Write( (int) ActiveItemID );
writer.Write( (int) m_InRange );
}
writer.Write(InactiveItemID);
writer.Write(ActiveItemID);
writer.Write(m_InRange);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int version = reader.ReadInt();
switch ( version )
{
case 1:
{
m_OutRange = reader.ReadInt();
goto case 0;
}
case 0:
{
InactiveItemID = reader.ReadInt();
ActiveItemID = reader.ReadInt();
m_InRange = reader.ReadInt();
switch (version)
{
case 1:
{
m_OutRange = reader.ReadInt();
goto case 0;
}
case 0:
{
InactiveItemID = reader.ReadInt();
ActiveItemID = reader.ReadInt();
m_InRange = reader.ReadInt();
if ( version < 1 )
m_OutRange = m_InRange;
if (version < 1)
m_OutRange = m_InRange;
break;
}
}
break;
}
}
Timer.DelayCall( TimeSpan.Zero, Refresh );
}
}
}
Timer.DelayCall(TimeSpan.Zero, Refresh);
}
}
}