Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -4,289 +4,293 @@ using Server.Multis;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
public abstract class BaseAddonContainer : BaseContainer, IChopable, IAddon
|
||||
{
|
||||
public override bool DisplayWeight => false;
|
||||
|
||||
[Hue, CommandProperty( AccessLevel.GameMaster )]
|
||||
public override int Hue
|
||||
{
|
||||
get => base.Hue;
|
||||
set
|
||||
{
|
||||
if ( base.Hue != value )
|
||||
{
|
||||
base.Hue = value;
|
||||
|
||||
if ( !Deleted && ShareHue && Components != null )
|
||||
{
|
||||
Hue = value;
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
c.Hue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CraftResource m_Resource;
|
||||
public abstract class BaseAddonContainer : BaseContainer, IChopable, IAddon
|
||||
{
|
||||
private CraftResource m_Resource;
|
||||
|
||||
public BaseAddonContainer(int itemID) : base(itemID)
|
||||
{
|
||||
AddonComponent.ApplyLightTo(this);
|
||||
|
||||
Components = new List<AddonContainerComponent>();
|
||||
}
|
||||
|
||||
public BaseAddonContainer(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool DisplayWeight => false;
|
||||
|
||||
[Hue]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public override int Hue
|
||||
{
|
||||
get => base.Hue;
|
||||
set
|
||||
{
|
||||
if (base.Hue != value)
|
||||
{
|
||||
base.Hue = value;
|
||||
|
||||
if (!Deleted && ShareHue && Components != null)
|
||||
{
|
||||
Hue = value;
|
||||
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
c.Hue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public CraftResource Resource
|
||||
{
|
||||
get => m_Resource;
|
||||
set
|
||||
{
|
||||
if (m_Resource != value)
|
||||
{
|
||||
m_Resource = value;
|
||||
Hue = CraftResources.GetHue(m_Resource);
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool RetainDeedHue => false;
|
||||
public virtual bool NeedsWall => false;
|
||||
public virtual bool ShareHue => true;
|
||||
public virtual Point3D WallPosition => Point3D.Zero;
|
||||
public virtual BaseAddonContainerDeed Deed => null;
|
||||
|
||||
public List<AddonContainerComponent> Components{ get; private set; }
|
||||
|
||||
Item IAddon.Deed => Deed;
|
||||
|
||||
public bool CouldFit(IPoint3D p, Map map)
|
||||
{
|
||||
BaseHouse house = null;
|
||||
|
||||
return CouldFit(p, map, null, ref house) == AddonFitResult.Valid;
|
||||
}
|
||||
|
||||
public virtual void OnChop(Mobile from)
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
if (house != null && house.IsOwner(from))
|
||||
{
|
||||
if (!IsSecure)
|
||||
{
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
|
||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public CraftResource Resource
|
||||
{
|
||||
get => m_Resource;
|
||||
set
|
||||
{
|
||||
if ( m_Resource != value )
|
||||
{
|
||||
m_Resource = value;
|
||||
Hue = CraftResources.GetHue( m_Resource );
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item IAddon.Deed => Deed;
|
||||
|
||||
public virtual bool RetainDeedHue => false;
|
||||
public virtual bool NeedsWall => false;
|
||||
public virtual bool ShareHue => true;
|
||||
public virtual Point3D WallPosition => Point3D.Zero;
|
||||
public virtual BaseAddonContainerDeed Deed => null;
|
||||
int hue = 0;
|
||||
|
||||
public List<AddonContainerComponent> Components { get; private set; }
|
||||
|
||||
public BaseAddonContainer( int itemID ) : base( itemID )
|
||||
{
|
||||
AddonComponent.ApplyLightTo( this );
|
||||
|
||||
Components = new List<AddonContainerComponent>();
|
||||
}
|
||||
|
||||
public BaseAddonContainer( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnLocationChange( Point3D oldLoc )
|
||||
{
|
||||
base.OnLocationChange( oldLoc );
|
||||
|
||||
if ( Deleted )
|
||||
return;
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
c.Location = new Point3D( X + c.Offset.X, Y + c.Offset.Y, Z + c.Offset.Z );
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
|
||||
if ( Deleted )
|
||||
return;
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
c.Map = Map;
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( this );
|
||||
|
||||
house?.Addons.Remove( this );
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public override void GetProperties( ObjectPropertyList list )
|
||||
{
|
||||
base.GetProperties( list );
|
||||
|
||||
if ( !CraftResources.IsStandard( m_Resource ) )
|
||||
list.Add( CraftResources.GetLocalizationNumber( m_Resource ) );
|
||||
}
|
||||
if (RetainDeedHue)
|
||||
for (int i = 0; hue == 0 && i < Components.Count; ++i)
|
||||
{
|
||||
AddonContainerComponent c = Components[i];
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
c.Delete();
|
||||
}
|
||||
if (c.Hue != 0)
|
||||
hue = c.Hue;
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
DropItemsToGround();
|
||||
|
||||
Delete();
|
||||
|
||||
house.Addons.Remove(this);
|
||||
|
||||
BaseAddonContainerDeed deed = Deed;
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
if (deed != null)
|
||||
{
|
||||
deed.Resource = Resource;
|
||||
|
||||
writer.WriteItemList<AddonContainerComponent>( Components );
|
||||
writer.Write( (int) m_Resource );
|
||||
}
|
||||
if (RetainDeedHue)
|
||||
deed.Hue = hue;
|
||||
|
||||
from.AddToBackpack(deed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1074870); // This item must be unlocked/unsecured before re-deeding it.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldLoc)
|
||||
{
|
||||
base.OnLocationChange(oldLoc);
|
||||
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
c.Location = new Point3D(X + c.Offset.X, Y + c.Offset.Y, Z + c.Offset.Z);
|
||||
}
|
||||
|
||||
int version = reader.ReadInt();
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
|
||||
Components = reader.ReadStrongItemList<AddonContainerComponent>();
|
||||
m_Resource = (CraftResource) reader.ReadInt();
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
AddonComponent.ApplyLightTo( this );
|
||||
}
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
c.Map = Map;
|
||||
}
|
||||
|
||||
public virtual void DropItemsToGround()
|
||||
{
|
||||
for ( int i = Items.Count - 1; i >= 0; i-- )
|
||||
Items[ i ].MoveToWorld( Location );
|
||||
}
|
||||
public override void OnDelete()
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(this);
|
||||
|
||||
public void AddComponent( AddonContainerComponent c, int x, int y, int z )
|
||||
{
|
||||
if ( Deleted )
|
||||
return;
|
||||
house?.Addons.Remove(this);
|
||||
|
||||
Components.Add( c );
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
c.Addon = this;
|
||||
c.Offset = new Point3D( x, y, z );
|
||||
c.MoveToWorld( new Point3D( X + x, Y + y, Z + z ), Map );
|
||||
}
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
public AddonFitResult CouldFit( IPoint3D p, Map map, Mobile from, ref BaseHouse house )
|
||||
{
|
||||
if ( Deleted )
|
||||
return AddonFitResult.Blocked;
|
||||
if (!CraftResources.IsStandard(m_Resource))
|
||||
list.Add(CraftResources.GetLocalizationNumber(m_Resource));
|
||||
}
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
{
|
||||
Point3D p3D = new Point3D( p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z );
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if ( !map.CanFit( p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, ( c.Z == 0 ) ) )
|
||||
return AddonFitResult.Blocked;
|
||||
if ( !BaseAddon.CheckHouse( from, p3D, map, c.ItemData.Height, ref house ) )
|
||||
return AddonFitResult.NotInHouse;
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
c.Delete();
|
||||
}
|
||||
|
||||
if ( c.NeedsWall )
|
||||
{
|
||||
Point3D wall = c.WallPosition;
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if ( !BaseAddon.IsWall( p3D.X + wall.X, p3D.Y + wall.Y, p3D.Z + wall.Z, map ) )
|
||||
return AddonFitResult.NoWall;
|
||||
}
|
||||
}
|
||||
writer.Write(0); // version
|
||||
|
||||
Point3D p3 = new Point3D( p.X, p.Y, p.Z );
|
||||
writer.WriteItemList(Components);
|
||||
writer.Write((int)m_Resource);
|
||||
}
|
||||
|
||||
if ( !map.CanFit( p3.X, p3.Y, p3.Z, ItemData.Height, false, true, ( Z == 0 ) ) )
|
||||
return AddonFitResult.Blocked;
|
||||
if ( !BaseAddon.CheckHouse( from, p3, map, ItemData.Height, ref house ) )
|
||||
return AddonFitResult.NotInHouse;
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
if ( NeedsWall )
|
||||
{
|
||||
Point3D wall = WallPosition;
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( !BaseAddon.IsWall( p3.X + wall.X, p3.Y + wall.Y, p3.Z + wall.Z, map ) )
|
||||
return AddonFitResult.NoWall;
|
||||
}
|
||||
Components = reader.ReadStrongItemList<AddonContainerComponent>();
|
||||
m_Resource = (CraftResource)reader.ReadInt();
|
||||
|
||||
if ( house != null )
|
||||
{
|
||||
ArrayList doors = house.Doors;
|
||||
AddonComponent.ApplyLightTo(this);
|
||||
}
|
||||
|
||||
for ( int i = 0; i < doors.Count; ++i )
|
||||
{
|
||||
BaseDoor door = doors[ i ] as BaseDoor;
|
||||
public virtual void DropItemsToGround()
|
||||
{
|
||||
for (int i = Items.Count - 1; i >= 0; i--)
|
||||
Items[i].MoveToWorld(Location);
|
||||
}
|
||||
|
||||
if ( door != null && door.Open )
|
||||
return AddonFitResult.DoorsNotClosed;
|
||||
public void AddComponent(AddonContainerComponent c, int x, int y, int z)
|
||||
{
|
||||
if (Deleted)
|
||||
return;
|
||||
|
||||
Point3D doorLoc = door.GetWorldLocation();
|
||||
int doorHeight = door.ItemData.CalcHeight;
|
||||
Components.Add(c);
|
||||
|
||||
foreach ( AddonContainerComponent c in Components )
|
||||
{
|
||||
Point3D addonLoc = new Point3D( p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z );
|
||||
int addonHeight = c.ItemData.CalcHeight;
|
||||
c.Addon = this;
|
||||
c.Offset = new Point3D(x, y, z);
|
||||
c.MoveToWorld(new Point3D(X + x, Y + y, Z + z), Map);
|
||||
}
|
||||
|
||||
if ( Utility.InRange( doorLoc, addonLoc, 1 ) && ( addonLoc.Z == doorLoc.Z || ( ( addonLoc.Z + addonHeight ) > doorLoc.Z && ( doorLoc.Z + doorHeight ) > addonLoc.Z ) ) )
|
||||
return AddonFitResult.DoorTooClose;
|
||||
}
|
||||
public AddonFitResult CouldFit(IPoint3D p, Map map, Mobile from, ref BaseHouse house)
|
||||
{
|
||||
if (Deleted)
|
||||
return AddonFitResult.Blocked;
|
||||
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
{
|
||||
Point3D p3D = new Point3D(p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z);
|
||||
|
||||
Point3D addonLo = new Point3D( p.X, p.Y, p.Z );
|
||||
int addonHeigh = ItemData.CalcHeight;
|
||||
if (!map.CanFit(p3D.X, p3D.Y, p3D.Z, c.ItemData.Height, false, true, c.Z == 0))
|
||||
return AddonFitResult.Blocked;
|
||||
if (!BaseAddon.CheckHouse(from, p3D, map, c.ItemData.Height, ref house))
|
||||
return AddonFitResult.NotInHouse;
|
||||
|
||||
if ( Utility.InRange( doorLoc, addonLo, 1 ) && ( addonLo.Z == doorLoc.Z || ( ( addonLo.Z + addonHeigh ) > doorLoc.Z && ( doorLoc.Z + doorHeight ) > addonLo.Z ) ) )
|
||||
return AddonFitResult.DoorTooClose;
|
||||
}
|
||||
}
|
||||
if (c.NeedsWall)
|
||||
{
|
||||
Point3D wall = c.WallPosition;
|
||||
|
||||
return AddonFitResult.Valid;
|
||||
}
|
||||
if (!BaseAddon.IsWall(p3D.X + wall.X, p3D.Y + wall.Y, p3D.Z + wall.Z, map))
|
||||
return AddonFitResult.NoWall;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CouldFit( IPoint3D p, Map map )
|
||||
{
|
||||
BaseHouse house = null;
|
||||
Point3D p3 = new Point3D(p.X, p.Y, p.Z);
|
||||
|
||||
return ( CouldFit( p, map, null, ref house ) == AddonFitResult.Valid );
|
||||
}
|
||||
if (!map.CanFit(p3.X, p3.Y, p3.Z, ItemData.Height, false, true, Z == 0))
|
||||
return AddonFitResult.Blocked;
|
||||
if (!BaseAddon.CheckHouse(from, p3, map, ItemData.Height, ref house))
|
||||
return AddonFitResult.NotInHouse;
|
||||
|
||||
public virtual void OnChop( Mobile from )
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt( this );
|
||||
|
||||
if ( house != null && house.IsOwner( from ) )
|
||||
{
|
||||
if ( !IsSecure )
|
||||
{
|
||||
Effects.PlaySound( GetWorldLocation(), Map, 0x3B3 );
|
||||
from.SendLocalizedMessage( 500461 ); // You destroy the item.
|
||||
if (NeedsWall)
|
||||
{
|
||||
Point3D wall = WallPosition;
|
||||
|
||||
int hue = 0;
|
||||
if (!BaseAddon.IsWall(p3.X + wall.X, p3.Y + wall.Y, p3.Z + wall.Z, map))
|
||||
return AddonFitResult.NoWall;
|
||||
}
|
||||
|
||||
if ( RetainDeedHue )
|
||||
{
|
||||
for ( int i = 0; hue == 0 && i < Components.Count; ++i )
|
||||
{
|
||||
AddonContainerComponent c = Components[ i ];
|
||||
if (house != null)
|
||||
{
|
||||
ArrayList doors = house.Doors;
|
||||
|
||||
if ( c.Hue != 0 )
|
||||
hue = c.Hue;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = doors[i] as BaseDoor;
|
||||
|
||||
DropItemsToGround();
|
||||
if (door != null && door.Open)
|
||||
return AddonFitResult.DoorsNotClosed;
|
||||
|
||||
Point3D doorLoc = door.GetWorldLocation();
|
||||
int doorHeight = door.ItemData.CalcHeight;
|
||||
|
||||
Delete();
|
||||
foreach (AddonContainerComponent c in Components)
|
||||
{
|
||||
Point3D addonLoc = new Point3D(p.X + c.Offset.X, p.Y + c.Offset.Y, p.Z + c.Offset.Z);
|
||||
int addonHeight = c.ItemData.CalcHeight;
|
||||
|
||||
if (Utility.InRange(doorLoc, addonLoc, 1) &&
|
||||
(addonLoc.Z == doorLoc.Z ||
|
||||
addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z))
|
||||
return AddonFitResult.DoorTooClose;
|
||||
}
|
||||
|
||||
house.Addons.Remove( this );
|
||||
Point3D addonLo = new Point3D(p.X, p.Y, p.Z);
|
||||
int addonHeigh = ItemData.CalcHeight;
|
||||
|
||||
BaseAddonContainerDeed deed = Deed;
|
||||
|
||||
if ( deed != null )
|
||||
{
|
||||
deed.Resource = Resource;
|
||||
|
||||
if ( RetainDeedHue )
|
||||
deed.Hue = hue;
|
||||
|
||||
from.AddToBackpack( deed );
|
||||
}
|
||||
}
|
||||
else
|
||||
from.SendLocalizedMessage( 1074870 ); // This item must be unlocked/unsecured before re-deeding it.
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnComponentLoaded( AddonContainerComponent c )
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnComponentUsed( AddonContainerComponent c, Mobile from )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Utility.InRange(doorLoc, addonLo, 1) &&
|
||||
(addonLo.Z == doorLoc.Z || addonLo.Z + addonHeigh > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z))
|
||||
return AddonFitResult.DoorTooClose;
|
||||
}
|
||||
}
|
||||
|
||||
return AddonFitResult.Valid;
|
||||
}
|
||||
|
||||
public virtual void OnComponentLoaded(AddonContainerComponent c)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnComponentUsed(AddonContainerComponent c, Mobile from)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue