示例#1
0
        public Entity(object Obj)
        {
            Contract.Requires(Obj != null);
            Contract.Requires(Obj as StructureComponent != null || Obj as DeployableObject != null);

            this._obj = Obj;

            if (Obj is DeployableObject)
            {
                var deployable = Obj as DeployableObject;

                var inventory = deployable.GetComponent <Inventory>();
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else
            {
                this.hasInventory = false;
            }
        }
示例#2
0
        public Entity(object Obj)
        {
            this._obj = Obj;
            if (this.IsStructureMaster())
            {
                this._ownerid   = (Obj as StructureMaster).ownerID;
                this._creatorid = (Obj as StructureMaster).creatorID;
                this._name      = "Structure Master";
            }

            if (this.IsStructure())
            {
                StructureComponent comp = Obj as StructureComponent;

                if (comp != null && comp._master != null)
                {
                    this._ownerid   = comp._master.ownerID;
                    this._creatorid = comp._master.creatorID;
                }
                string clone = this.GetObject <StructureComponent>().ToString();
                var    index = clone.IndexOf("(Clone)");
                this._name = clone.Substring(0, index);
            }
            if (this.IsDeployableObject())
            {
                DeployableObject dobj = Obj as DeployableObject;
                this._ownerid   = dobj.ownerID;
                this._creatorid = dobj.creatorID;
                string clone = this.GetObject <DeployableObject>().ToString();
                if (clone.Contains("Barricade"))
                {
                    this._name = "Wood Barricade";
                }
                else
                {
                    var index = clone.IndexOf("(Clone)");
                    this._name = clone.Substring(0, index);
                }
                var deployable = Obj as DeployableObject;

                var inventory = deployable.GetComponent <Inventory>();
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else if (this.IsLootableObject())
            {
                this._ownerid   = 76561198095992578UL;
                this._creatorid = 76561198095992578UL;
                var loot = Obj as LootableObject;
                this._name = loot.name;
                var inventory = loot._inventory;
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else if (this.IsSupplyCrate())
            {
                this._ownerid   = 76561198095992578UL;
                this._creatorid = 76561198095992578UL;
                this._name      = "Supply Crate";
                var crate     = Obj as SupplyCrate;
                var inventory = crate.lootableObject._inventory;
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else if (IsResourceTarget())
            {
                var x = (ResourceTarget)Obj;
                this._ownerid     = 76561198095992578UL;
                this._creatorid   = 76561198095992578UL;
                this._name        = x.name;
                this.hasInventory = false;
            }
            else
            {
                this.hasInventory = false;
            }
            if (Fougerite.Server.Cache.ContainsKey(_ownerid))
            {
                this._ownername = Fougerite.Server.Cache[_ownerid].Name;
            }
            else if (Server.GetServer().HasRustPP)
            {
                if (Server.GetServer().GetRustPPAPI().Cache.ContainsKey(_ownerid))
                {
                    this._ownername = Server.GetServer().GetRustPPAPI().Cache[_ownerid];
                }
            }
            else
            {
                this._ownername = "UnKnown";
            }
            if (Fougerite.Server.Cache.ContainsKey(_creatorid))
            {
                this._creatorname = Fougerite.Server.Cache[_creatorid].Name;
            }
            else if (Server.GetServer().HasRustPP)
            {
                if (Server.GetServer().GetRustPPAPI().Cache.ContainsKey(_creatorid))
                {
                    this._creatorname = Server.GetServer().GetRustPPAPI().Cache[_creatorid];
                }
            }
            else
            {
                this._creatorname = "UnKnown";
            }
        }
示例#3
0
        public Entity(object Obj)
        {
            this._obj = Obj;

            if (Obj is StructureMaster)
            {
                this._ownerid = (Obj as StructureMaster).ownerID;
                this._name    = "Structure Master";
            }

            if (Obj is StructureComponent)
            {
                this._ownerid = (Obj as StructureComponent)._master.ownerID;
                string clone = this.GetObject <StructureComponent>().ToString();
                var    index = clone.IndexOf("(Clone)");
                this._name = clone.Substring(0, index);
            }
            if (Obj is DeployableObject)
            {
                this._ownerid = (Obj as DeployableObject).ownerID;
                string clone = this.GetObject <DeployableObject>().ToString();
                if (clone.Contains("Barricade"))
                {
                    this._name = "Wood Barricade";
                }
                else
                {
                    var index = clone.IndexOf("(Clone)");
                    this._name = clone.Substring(0, index);
                }
                var deployable = Obj as DeployableObject;

                var inventory = deployable.GetComponent <Inventory>();
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else if (Obj is SupplyCrate)
            {
                this._ownerid = 76561198095992578UL;
                this._name    = "Supply Crate";
                var crate     = Obj as SupplyCrate;
                var inventory = crate.lootableObject._inventory;
                if (inventory != null)
                {
                    this.hasInventory = true;
                    this.inv          = new EntityInv(inventory, this);
                }
                else
                {
                    this.hasInventory = false;
                }
            }
            else
            {
                this.hasInventory = false;
            }
        }