From 12826da7c4103c18769fa4b5f96ad4eb8f133221 Mon Sep 17 00:00:00 2001 From: Mark Sturgill Date: Sat, 15 Feb 2014 13:21:28 -0700 Subject: [PATCH] remove ParentEntity and RootParentEntity Parent and RootParent are now IEntity properties refactor object arguments to IEntity for parent related methods branch and version bump to 2.6 --- Scripts/Engines/ConPVP/Trophy.cs | 2 +- Scripts/Engines/Factions/Items/Sigil.cs | 6 +- .../Dark Tides/Items/ScrollOfAbraxus.cs | 2 +- Scripts/Items/Armor/BaseArmor.cs | 4 +- Scripts/Items/Clothing/BaseClothing.cs | 4 +- Scripts/Items/Clothing/Cloaks.cs | 4 +- Scripts/Items/Clothing/Hats.cs | 2 +- Scripts/Items/Clothing/OuterTorso.cs | 8 +-- Scripts/Items/Containers/Container.cs | 2 +- Scripts/Items/Jewels/BaseJewel.cs | 4 +- Scripts/Items/Lights/BaseEquipableLight.cs | 2 +- Scripts/Items/Lights/Torch.cs | 2 +- Scripts/Items/Misc/PromotionalToken.cs | 2 +- Scripts/Items/Quivers/BaseQuiver.cs | 8 +-- .../Items/Skill Items/Magical/Spellbook.cs | 4 +- .../8th Anniversary Items/Talismans.cs | 2 +- .../Blacksmithy/AncientSmithyHammer.cs | 4 +- .../Blacksmithy/GlovesOfMining.cs | 4 +- .../Rares/Containers/BaseWaterContainer.cs | 2 +- Scripts/Items/Talismans/BaseTalisman.cs | 4 +- Scripts/Items/Weapons/BaseWeapon.cs | 4 +- Scripts/Mobiles/PlayerMobile.cs | 2 +- Server/AssemblyInfo.cs | 2 +- Server/Item.cs | 72 +++++++------------ 24 files changed, 66 insertions(+), 86 deletions(-) diff --git a/Scripts/Engines/ConPVP/Trophy.cs b/Scripts/Engines/ConPVP/Trophy.cs index 28ef450ab..f1096f1f8 100644 --- a/Scripts/Engines/ConPVP/Trophy.cs +++ b/Scripts/Engines/ConPVP/Trophy.cs @@ -75,7 +75,7 @@ namespace Server.Items LootType = LootType.Blessed; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Engines/Factions/Items/Sigil.cs b/Scripts/Engines/Factions/Items/Sigil.cs index 2ae6ad511..9b91eec1e 100644 --- a/Scripts/Engines/Factions/Items/Sigil.cs +++ b/Scripts/Engines/Factions/Items/Sigil.cs @@ -186,7 +186,7 @@ namespace Server.Factions return null; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -196,7 +196,7 @@ namespace Server.Factions mob.SolidHueOverride = OwnershipHue; } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); @@ -442,7 +442,7 @@ namespace Server.Factions return ( monolith != null && !monolith.Deleted ); } - public override void OnParentDeleted( object parent ) + public override void OnParentDeleted(IEntity parent) { base.OnParentDeleted( parent ); diff --git a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs index a8dab9a9b..beaba214b 100644 --- a/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs +++ b/Scripts/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs @@ -29,7 +29,7 @@ namespace Server.Engines.Quests.Necro return false; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Armor/BaseArmor.cs b/Scripts/Items/Armor/BaseArmor.cs index 1f6e37b3c..6ffcd6890 100644 --- a/Scripts/Items/Armor/BaseArmor.cs +++ b/Scripts/Items/Armor/BaseArmor.cs @@ -667,7 +667,7 @@ namespace Server.Items return v; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( parent is Mobile ) { @@ -1265,7 +1265,7 @@ namespace Server.Items return base.OnEquip( from ); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Items/Clothing/BaseClothing.cs b/Scripts/Items/Clothing/BaseClothing.cs index 4bff72a3f..be903dcf7 100644 --- a/Scripts/Items/Clothing/BaseClothing.cs +++ b/Scripts/Items/Clothing/BaseClothing.cs @@ -335,7 +335,7 @@ namespace Server.Items return m_AosClothingAttributes.LowerStatReq; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { Mobile mob = parent as Mobile; @@ -351,7 +351,7 @@ namespace Server.Items base.OnAdded( parent ); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { Mobile mob = parent as Mobile; diff --git a/Scripts/Items/Clothing/Cloaks.cs b/Scripts/Items/Clothing/Cloaks.cs index b0af4b482..8c81208ae 100644 --- a/Scripts/Items/Clothing/Cloaks.cs +++ b/Scripts/Items/Clothing/Cloaks.cs @@ -188,7 +188,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -196,7 +196,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Clothing/Hats.cs b/Scripts/Items/Clothing/Hats.cs index f9ab30741..32aaf212d 100644 --- a/Scripts/Items/Clothing/Hats.cs +++ b/Scripts/Items/Clothing/Hats.cs @@ -728,7 +728,7 @@ namespace Server.Items return true; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Clothing/OuterTorso.cs b/Scripts/Items/Clothing/OuterTorso.cs index c6f02100a..1dd9bd303 100644 --- a/Scripts/Items/Clothing/OuterTorso.cs +++ b/Scripts/Items/Clothing/OuterTorso.cs @@ -265,7 +265,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -273,7 +273,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); @@ -390,7 +390,7 @@ namespace Server.Items public override int BasePhysicalResistance{ get{ return 3; } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -398,7 +398,7 @@ namespace Server.Items ((Mobile)parent).VirtualArmorMod += 2; } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Containers/Container.cs b/Scripts/Items/Containers/Container.cs index 8453f12ae..67b08cb7a 100644 --- a/Scripts/Items/Containers/Container.cs +++ b/Scripts/Items/Containers/Container.cs @@ -280,7 +280,7 @@ namespace Server.Items public override int DefaultMaxWeight { get { if ( Core.ML ) { - Mobile m = ParentEntity as Mobile; + Mobile m = Parent as Mobile; if ( m != null && m.Player && m.Backpack == this ) { return 550; } else { diff --git a/Scripts/Items/Jewels/BaseJewel.cs b/Scripts/Items/Jewels/BaseJewel.cs index 57c5b5140..0d67bdf14 100644 --- a/Scripts/Items/Jewels/BaseJewel.cs +++ b/Scripts/Items/Jewels/BaseJewel.cs @@ -141,7 +141,7 @@ namespace Server.Items m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits ); } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( Core.AOS && parent is Mobile ) { @@ -171,7 +171,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( Core.AOS && parent is Mobile ) { diff --git a/Scripts/Items/Lights/BaseEquipableLight.cs b/Scripts/Items/Lights/BaseEquipableLight.cs index 201777375..9afe1f34c 100644 --- a/Scripts/Items/Lights/BaseEquipableLight.cs +++ b/Scripts/Items/Lights/BaseEquipableLight.cs @@ -41,7 +41,7 @@ namespace Server.Items } } - public override void OnAdded ( object parent ) + public override void OnAdded(IEntity parent) { if ( Burning && parent is Container ) Douse(); diff --git a/Scripts/Items/Lights/Torch.cs b/Scripts/Items/Lights/Torch.cs index 45f43b947..68fae024d 100644 --- a/Scripts/Items/Lights/Torch.cs +++ b/Scripts/Items/Lights/Torch.cs @@ -24,7 +24,7 @@ namespace Server.Items Weight = 1.0; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); diff --git a/Scripts/Items/Misc/PromotionalToken.cs b/Scripts/Items/Misc/PromotionalToken.cs index a044d4de6..c775a2109 100644 --- a/Scripts/Items/Misc/PromotionalToken.cs +++ b/Scripts/Items/Misc/PromotionalToken.cs @@ -44,7 +44,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { Mobile m = null; diff --git a/Scripts/Items/Quivers/BaseQuiver.cs b/Scripts/Items/Quivers/BaseQuiver.cs index b90c1aaaa..e850a3073 100644 --- a/Scripts/Items/Quivers/BaseQuiver.cs +++ b/Scripts/Items/Quivers/BaseQuiver.cs @@ -191,8 +191,8 @@ namespace Server.Items InvalidateWeight(); } - - public override void OnAdded( object parent ) + + public override void OnAdded(IEntity parent) { if ( parent is Mobile ) { @@ -201,8 +201,8 @@ namespace Server.Items m_Attributes.AddStatBonuses( mob ); } } - - public override void OnRemoved( object parent ) + + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Scripts/Items/Skill Items/Magical/Spellbook.cs index cb8a25999..a4b44c252 100644 --- a/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -454,7 +454,7 @@ namespace Server.Items book.m_AosSkillBonuses = new AosSkillBonuses( newItem, m_AosSkillBonuses ); } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { if ( Core.AOS && parent is Mobile ) { @@ -484,7 +484,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( Core.AOS && parent is Mobile ) { diff --git a/Scripts/Items/Special/8th Anniversary Items/Talismans.cs b/Scripts/Items/Special/8th Anniversary Items/Talismans.cs index cede77d9f..a53df7a5e 100644 --- a/Scripts/Items/Special/8th Anniversary Items/Talismans.cs +++ b/Scripts/Items/Special/8th Anniversary Items/Talismans.cs @@ -46,7 +46,7 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs index ca4986af5..8da692539 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs @@ -41,7 +41,7 @@ namespace Server.Items } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -55,7 +55,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs index 89883363d..4b63a8794 100644 --- a/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs +++ b/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs @@ -176,7 +176,7 @@ namespace Server.Items } } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -190,7 +190,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { base.OnRemoved( parent ); diff --git a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs index 492bdfd0b..2d833e85a 100644 --- a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs +++ b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs @@ -33,7 +33,7 @@ if( !IsEmpty ) { - IEntity rootParent = RootParentEntity; + IEntity rootParent = RootParent; if( rootParent != null && rootParent.Map != null && rootParent.Map != Map.Internal ) MoveToWorld( rootParent.Location, rootParent.Map ); diff --git a/Scripts/Items/Talismans/BaseTalisman.cs b/Scripts/Items/Talismans/BaseTalisman.cs index 556757f2d..f9b193fe6 100644 --- a/Scripts/Items/Talismans/BaseTalisman.cs +++ b/Scripts/Items/Talismans/BaseTalisman.cs @@ -234,7 +234,7 @@ namespace Server.Items return base.CanEquip( from ); } - public override void OnAdded(object parent) + public override void OnAdded(IEntity parent) { if (parent is Mobile) { @@ -259,7 +259,7 @@ namespace Server.Items InvalidateProperties(); } - public override void OnRemoved(object parent) + public override void OnRemoved(IEntity parent) { if (parent is Mobile) { diff --git a/Scripts/Items/Weapons/BaseWeapon.cs b/Scripts/Items/Weapons/BaseWeapon.cs index 10488e661..79178b435 100644 --- a/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Scripts/Items/Weapons/BaseWeapon.cs @@ -659,7 +659,7 @@ namespace Server.Items return true; } - public override void OnAdded( object parent ) + public override void OnAdded(IEntity parent) { base.OnAdded( parent ); @@ -675,7 +675,7 @@ namespace Server.Items } } - public override void OnRemoved( object parent ) + public override void OnRemoved(IEntity parent) { if ( parent is Mobile ) { diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 77d77c2e4..7f7e97cac 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -2659,7 +2659,7 @@ namespace Server.Mobiles { if (!item.Deleted && (item.LootType == LootType.Blessed || item.Insured)) { - if (this.Backpack != item.ParentEntity) + if (this.Backpack != item.Parent) { return true; } diff --git a/Server/AssemblyInfo.cs b/Server/AssemblyInfo.cs index 3706d10a8..d5c2d76c2 100644 --- a/Server/AssemblyInfo.cs +++ b/Server/AssemblyInfo.cs @@ -47,7 +47,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.5.0.*")] +[assembly: AssemblyVersion("2.6.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the diff --git a/Server/Item.cs b/Server/Item.cs index e41bbf26c..ff7392285 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -470,7 +470,7 @@ namespace Server { public Map m_Map; public Point3D m_Location, m_WorldLoc; - public object m_Parent; + public IEntity m_Parent; public BounceInfo( Item item ) { @@ -480,7 +480,7 @@ namespace Server m_Parent = item.Parent; } - private BounceInfo( Map map, Point3D loc, Point3D worldLoc, object parent ) + private BounceInfo( Map map, Point3D loc, Point3D worldLoc, IEntity parent ) { m_Map = map; m_Location = loc; @@ -496,7 +496,7 @@ namespace Server Point3D loc = reader.ReadPoint3D(); Point3D worldLoc = reader.ReadPoint3D(); - object parent; + IEntity parent; Serial serial = reader.ReadInt(); @@ -594,7 +594,7 @@ namespace Server private int m_Hue; private int m_Amount; private Layer m_Layer; - private object m_Parent; // Mobile, Item, or null=World + private IEntity m_Parent; // Mobile, Item, or null=World private Map m_Map; private LootType m_LootType; private DateTime m_LastMovedTime; @@ -1149,12 +1149,12 @@ namespace Server if ( bounce != null ) { - object parent = bounce.m_Parent; + IEntity parent = bounce.m_Parent; if ( parent is Item && !((Item)parent).Deleted ) { Item p = (Item)parent; - object root = p.RootParent; + IEntity root = p.RootParent; if ( p.IsAccessibleTo( from ) && ( !(root is Mobile) || ((Mobile)root).CheckNonlocalDrop( from, this, p ) ) ) { Location = bounce.m_Location; @@ -1898,11 +1898,11 @@ namespace Server { } - public virtual void OnRemoved( object parent ) + public virtual void OnRemoved( IEntity parent ) { } - public virtual void OnAdded( object parent ) + public virtual void OnAdded( IEntity parent ) { } @@ -2918,11 +2918,12 @@ namespace Server } } - public object RootParent + [CommandProperty(AccessLevel.GameMaster)] + public IEntity RootParent { get { - object p = m_Parent; + IEntity p = m_Parent; while ( p is Item ) { @@ -2944,7 +2945,7 @@ namespace Server public bool ParentsContain() where T : Item { - object p = m_Parent; + IEntity p = m_Parent; while( p is Item ) { @@ -3325,7 +3326,7 @@ namespace Server } } - public virtual void OnParentDeleted( object parent ) + public virtual void OnParentDeleted( IEntity parent ) { this.Delete(); } @@ -3539,28 +3540,6 @@ namespace Server } } - [CommandProperty( AccessLevel.GameMaster )] - public IEntity ParentEntity - { - get - { - IEntity p = Parent as IEntity; - - return p; - } - } - - [CommandProperty( AccessLevel.GameMaster )] - public IEntity RootParentEntity - { - get - { - IEntity p = RootParent as IEntity; - - return p; - } - } - #region Location Location Location! public virtual void OnLocationChange( Point3D oldLocation ) @@ -3728,7 +3707,8 @@ namespace Server } } - public virtual object Parent + [CommandProperty(AccessLevel.GameMaster)] + public virtual IEntity Parent { get { @@ -3739,7 +3719,7 @@ namespace Server if ( m_Parent == value ) return; - object oldParent = m_Parent; + IEntity oldParent = m_Parent; m_Parent = value; @@ -4190,12 +4170,12 @@ namespace Server public Point3D GetWorldLocation() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return m_Location; else - return ((IEntity)root).Location; + return root.Location; //return root == null ? m_Location : new Point3D( (IPoint3D) root ); } @@ -4204,22 +4184,22 @@ namespace Server public Point3D GetSurfaceTop() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return new Point3D( m_Location.m_X, m_Location.m_Y, m_Location.m_Z + (ItemData.Surface ? ItemData.CalcHeight : 0) ); else - return ((IEntity)root).Location; + return root.Location; } public Point3D GetWorldTop() { - object root = RootParent; + IEntity root = RootParent; if ( root == null ) return new Point3D( m_Location.m_X, m_Location.m_Y, m_Location.m_Z + ItemData.CalcHeight ); else - return ((IEntity)root).Location; + return root.Location; } public void SendLocalizedMessageTo( Mobile to, int number ) @@ -4378,14 +4358,14 @@ namespace Server return true;*/ } - public bool IsChildOf( object o ) + public bool IsChildOf(IEntity o) { return IsChildOf( o, false ); } - public bool IsChildOf( object o, bool allowNull ) + public bool IsChildOf(IEntity o, bool allowNull) { - object p = m_Parent; + IEntity p = m_Parent; if ( (p == null || o == null) && !allowNull ) return false; @@ -4536,7 +4516,7 @@ namespace Server int ourHue = Hue; Map thisMap = this.Map; - object thisParent = this.m_Parent; + IEntity thisParent = this.m_Parent; Point3D worldLoc = this.GetWorldLocation(); LootType type = this.LootType;