Esempio n. 1
0
 void DestroyObject(GameObject obj)
 {
     if (obj != null)
     {
         NetCull.Destroy(obj);
     }
 }
Esempio n. 2
0
 public void Destroy()
 {
     try
     {
         if (this.IsDeployableObject())
         {
             this.GetObject <DeployableObject>().OnKilled();
         }
         else if (this.IsStructure())
         {
             StructureComponent comp = this.GetObject <StructureComponent>();
             comp._master.RemoveComponent(comp);
             comp._master = null;
             this.GetObject <StructureComponent>().StartCoroutine("DelayedKill");
         }
     }
     catch (Exception)
     {
         if (this.IsDeployableObject())
         {
             NetCull.Destroy(this.GetObject <DeployableObject>().networkViewID);
         }
         else if (this.IsStructure())
         {
             NetCull.Destroy(this.GetObject <StructureComponent>().networkViewID);
         }
     }
 }
Esempio n. 3
0
        int CleanRadius(Vector3 position, float radius, string name, bool all)
        {
            int destroyed = 0;

            foreach (Collider collider in Physics.OverlapSphere(position, radius))
            {
                if (name == string.Empty && collider.GetComponent <DeployableObject>())
                {
                    if (!all && collider.GetComponent <DeployableObject>()._carrier != null)
                    {
                        continue;
                    }
                    if (shouldDestroy(collider.transform.position, all))
                    {
                        NetCull.Destroy(collider.gameObject);
                        destroyed++;
                    }
                }
                else if (collider.gameObject.name == name)
                {
                    if (shouldDestroy(collider.transform.position, all))
                    {
                        NetCull.Destroy(collider.gameObject);
                        destroyed++;
                    }
                }
            }
            return(destroyed);
        }
Esempio n. 4
0
 void OnItemDeployedByPlayer(DeployableObject component, IDeployableItem item)
 {
     if (!antiSleepingBagHack)
     {
         return;
     }
     if (component.gameObject.name == "SleepingBagA(Clone)" || component.gameObject.name == "SingleBed(Clone)")
     {
         if (!item.character)
         {
             return;
         }
         if (!(MeshBatchPhysics.Linecast(item.character.eyesOrigin, component.transform.position, out cachedRaycast, out cachedBoolean, out cachedhitInstance)))
         {
             return;
         }
         if (cachedhitInstance == null && cachedRaycast.collider.gameObject.name != "MetalDoor(Clone)")
         {
             return;
         }
         if (Vector3.Distance(item.character.eyesOrigin, component.transform.position) > 9f)
         {
             return;
         }
         AntiCheatBroadcastAdmins(string.Format("{0} tried to spawn a {1} @ {2} from {3}", item.character.playerClient.userName, component.gameObject.name.Replace("(Clone)", ""), component.transform.position.ToString(), item.character.eyesOrigin.ToString()));
         AntiCheatBroadcastAdmins(string.Format("{0} was on the way", (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         Puts(string.Format("{0} tried to spawn a {1} @ {2} from {3} threw {4}", item.character.playerClient.userName, component.gameObject.name.Replace("(Clone)", ""), component.transform.position.ToString(), item.character.eyesOrigin.ToString(), (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         NetCull.Destroy(component.gameObject);
         if (sleepingbaghackPunish)
         {
             Punish(item.character.playerClient, string.Format("rSleepHack ({0})", (cachedhitInstance == null) ? "Metal Door" : cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Replace("(Clone)", "")));
         }
     }
 }
        private int method_0()
        {
            int num = 0;

            foreach (BasicWildLifeAI eai in UnityEngine.Object.FindObjectsOfType <BasicWildLifeAI>())
            {
                TakeDamage component = eai.GetComponent <TakeDamage>();
                if ((component != null) && component.alive)
                {
                    NavMeshMovement movement = eai.GetComponent <NavMeshMovement>();
                    if (((movement == null) || (movement._agent == null)) || (movement._agent.pathStatus == NavMeshPathStatus.PathInvalid))
                    {
                        int index = WildlifeManager.Data.lifeInstances.IndexOf(eai);
                        if ((index != -1) && (index < WildlifeManager.Data.lifeInstanceCount))
                        {
                            if (movement != null)
                            {
                                Helper.Log(string.Concat(new object[] { "WildLifeAI: Creature '", Helper.NiceName(eai.gameObject.name), " at ", eai.gameObject.transform.position, "' has been removed because creature without mesh agent." }), false);
                            }
                            else
                            {
                                Helper.Log(string.Concat(new object[] { "WildLifeAI: Creature '", Helper.NiceName(eai.gameObject.name), " at ", eai.gameObject.transform.position, "' has been removed because mesh agent have invalid path." }), false);
                            }
                            WildlifeManager.Data.lifeInstances.RemoveAt(index);
                            WildlifeManager.Data.lifeInstanceCount--;
                            WildlifeManager.Data.thinkIterator = 0;
                            NetCull.Destroy(eai.gameObject);
                            num++;
                        }
                    }
                }
            }
            return(num);
        }
Esempio n. 6
0
 public void OnDestroy()
 {
     NetCull.Destroy(DeployableObject.gameObject);
     if (character != null)
     {
         character.takeDamage.SetGodMode(false);
     }
 }
Esempio n. 7
0
 void OnDestroy()
 {
     NetCull.Destroy(lastObject.gameObject);
     if (character != null)
     {
         character.takeDamage.SetGodMode(false);
     }
 }
Esempio n. 8
0
 private void TryNetCullDestroy()
 {
     try
     {
         NetCull.Destroy(this._sleeper.networkViewID);
     }
     catch { }
 }
Esempio n. 9
0
 /*  public void EntHurt(HurtEvent he)
  * {
  *    // Dretax his way in Hungergames
  *    Entity ent = he.Entity;
  *    RoyaleUser attacker = (RoyaleUser)he.Attacker;
  *    string gun = he.WeaponName;
  *    if(attacker != null && ent != null && !he.IsDecay && he.AttackerIsPlayer)
  *    {
  *        ulong id = attacker.UID;
  *
  *        if(gun == "Shotgun")
  *        {
  *            attacker.MessageFrom("BattleRoyale", "You cannot use shotgun in entity mode");
  *            return;
  *        }
  *        if(entitymode.Contains(id))
  *        {
  *            if(ent.Name.ToLower().Contains("box"))
  *            {
  *                string[] c = lootlist.EnumSection("Chests");
  *                string co = (Convert.ToInt32(c[c.Length - 1]) + 1).ToString();
  *                lootlist.AddSetting("Chests", ent.Name + "-" + co.ToString(), ent.X.ToString() + ", " + ent.Y.ToString() + ", " + ent.Z.ToString() + ", " + ent.Rotation.x.ToString() + "," + ent.Rotation.y.ToString() + "," + ent.Rotation.z.ToString() + "," + ent.Rotation.w.ToString());
  *                lootlist.Save();
  *                attacker.MessageFrom("BattleRoyale", "Chest added");
  *            }
  *        }
  *    }
  */
 private void CleanSacks()
 {
     foreach (LootableObject loot in UnityEngine.Resources.FindObjectsOfTypeAll <LootableObject>())
     {
         if (loot.gameObject.name == "LootSack(Clone)")
         {
             NetCull.Destroy(loot.gameObject);
         }
     }
 }
Esempio n. 10
0
 public static void HidePoints()
 {
     if (Zones.Markers != null && Zones.Markers.Count != 0)
     {
         foreach (GameObject current in Zones.Markers)
         {
             NetCull.Destroy(current);
         }
         Zones.Markers.Clear();
     }
 }
Esempio n. 11
0
 public static void HidePoints()
 {
     if ((Markers != null) && (Markers.Count != 0))
     {
         foreach (GameObject obj2 in Markers)
         {
             NetCull.Destroy(obj2);
         }
         Markers.Clear();
     }
 }
Esempio n. 12
0
 private static void DestroyStructure(StructureComponent comp)
 {
     try
     {
         comp._master.RemoveComponent(comp);
         comp._master = null;
         comp.StartCoroutine("DelayedKill");
     } catch
     {
         NetCull.Destroy(comp.networkViewID);
     }
 }
Esempio n. 13
0
        private int method_0()
        {
            int num = 0;

            BasicWildLifeAI[] array  = UnityEngine.Object.FindObjectsOfType <BasicWildLifeAI>();
            BasicWildLifeAI[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                BasicWildLifeAI basicWildLifeAI = array2[i];
                TakeDamage      component       = basicWildLifeAI.GetComponent <TakeDamage>();
                if (!(component == null) && component.alive)
                {
                    NavMeshMovement component2 = basicWildLifeAI.GetComponent <NavMeshMovement>();
                    if (component2 == null || component2._agent == null || component2._agent.pathStatus == NavMeshPathStatus.PathInvalid)
                    {
                        int num2 = WildlifeManager.Data.lifeInstances.IndexOf(basicWildLifeAI);
                        if (num2 != -1 && num2 < WildlifeManager.Data.lifeInstanceCount)
                        {
                            if (component2 != null)
                            {
                                Helper.Log(string.Concat(new object[]
                                {
                                    "WildLifeAI: Creature '",
                                    Helper.NiceName(basicWildLifeAI.gameObject.name),
                                    " at ",
                                    basicWildLifeAI.gameObject.transform.position,
                                    "' has been removed because creature without mesh agent."
                                }), false);
                            }
                            else
                            {
                                Helper.Log(string.Concat(new object[]
                                {
                                    "WildLifeAI: Creature '",
                                    Helper.NiceName(basicWildLifeAI.gameObject.name),
                                    " at ",
                                    basicWildLifeAI.gameObject.transform.position,
                                    "' has been removed because mesh agent have invalid path."
                                }), false);
                            }
                            WildlifeManager.Data.lifeInstances.RemoveAt(num2);
                            WildlifeManager.Data.lifeInstanceCount--;
                            WildlifeManager.Data.thinkIterator = 0;
                            NetCull.Destroy(basicWildLifeAI.gameObject);
                            num++;
                        }
                    }
                }
            }
            return(num);
        }
Esempio n. 14
0
 void DestroySack(LootableObject sack)
 {
     if (sack != null)
     {
         if (dontremoveiflooted && ((uLink.NetworkPlayer)usingPlayer.GetValue(sack) != uLink.NetworkPlayer.unassigned))
         {
             timer.Once(1f, () => DestroySack(sack));
         }
         else
         {
             NetCull.Destroy(sack.gameObject);
         }
     }
 }
Esempio n. 15
0
        private void TryNetCullDestroy()
        {
            try
            {
                if (this.IsDeployableObject())
                {
                    NetCull.Destroy(this.GetObject <DeployableObject>().networkViewID);
                }

                if (this.IsStructureMaster())
                {
                    NetCull.Destroy(this.GetObject <StructureMaster>().networkViewID);
                }
            }
            catch { }
        }
Esempio n. 16
0
 void OnItemDeployedByPlayer(DeployableObject component, IDeployableItem item)
 {
     if (!antiWoodDoorGlitch)
     {
         return;
     }
     if (component.gameObject.name == "WoodBoxLarge(Clone)")
     {
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 1.2f, doorLayer))
         {
             if (collider.gameObject.name == "MetalDoor(Clone)")
             {
                 if (doorstate.GetValue(collider.GetComponent <BasicDoor>()).ToString() == "Opened" || doorstate.GetValue(collider.GetComponent <BasicDoor>()).ToString() == "Opening")
                 {
                     ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} should be closed before trying to build here", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                     item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                     timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                     return;
                 }
             }
         }
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 0.65f, doorLayer))
         {
             if (collider.gameObject.name == "MetalDoor(Clone)")
             {
                 ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} is blocking the way", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                 item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                 timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                 return;
             }
         }
     }
     else if (component.gameObject.name == "MetalDoor(Clone)")
     {
         foreach (Collider collider in Physics.OverlapSphere(component.transform.position + Vector3Up, 0.65f))
         {
             if (collider.gameObject.name == "WoodBoxLarge(Clone)")
             {
                 ConsoleNetworker.SendClientCommand(item.character.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("{0} is blocking the way", collider.gameObject.name.ToString().Replace("(Clone)", ""))));
                 item.character.GetComponent <Inventory>().AddItemAmount(item.datablock, 1);
                 timer.Once(0.01f, () => NetCull.Destroy(component.gameObject));
                 return;
             }
         }
     }
 }
Esempio n. 17
0
        int CleanAllSacks(bool all)
        {
            int destroyed = 0;

            foreach (LootableObject lootable in UnityEngine.Resources.FindObjectsOfTypeAll <LootableObject>())
            {
                if (lootable.gameObject.name == "LootSack(Clone)")
                {
                    if (shouldDestroy(lootable.transform.position, all))
                    {
                        NetCull.Destroy(lootable.gameObject);
                        destroyed++;
                    }
                }
            }
            return(destroyed);
        }
Esempio n. 18
0
 void FixedUpdate()
 {
     if (character == null)
     {
         GameObject.Destroy(this);
     }
     if (speed == 0f)
     {
         return;
     }
     nextForward = nextForward + (character.eyesRotation * Vector3.forward) * speed;
     if (lastObject != null)
     {
         NetCull.Destroy(lastObject.gameObject);
     }
     NewObject();
     management.TeleportPlayerToWorld(playerClient.netPlayer, nextForward);
 }
Esempio n. 19
0
 public void FixedUpdate()
 {
     if (character == null)
     {
         Destroy(this);
         return;
     }
     if (speed == 0f)
     {
         return;
     }
     origin = origin + (character.eyesRotation * Vector3.forward) * speed;
     if (DeployableObject != null)
     {
         NetCull.Destroy(DeployableObject.gameObject);
     }
     NewObject();
     ServerManagement.TeleportPlayerToWorld(playerClient.netPlayer, origin);
 }
        private IEnumerator RefillAndSpawnCoroutine(LootStorage lootStorage)
        {
            foreach (var collider in Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(
                         transform.position, 2))
            {
                if (collider.name.Contains("WoodBoxLarge"))
                {
                    NetCull.Destroy(collider.gameObject);
                }
            }

            var loot           = NetCull.InstantiateStatic(";deploy_wood_storage_large", transform.position, Quaternion.identity);
            var lootableObject = loot.GetComponent <LootableObject>();

            FillWithItems(lootableObject, lootStorage.GetItems());

            while (true)
            {
                var foundBox = false;

                foreach (var collider in Facepunch.MeshBatch.MeshBatchPhysics.OverlapSphere(
                             transform.position, 2))
                {
                    if (collider.name.Contains("WoodBoxLarge"))
                    {
                        foundBox = true;
                        break;
                    }
                }

                if (!foundBox)
                {
                    loot           = NetCull.InstantiateStatic(";deploy_wood_storage_large", transform.position, Quaternion.identity);
                    lootableObject = loot.GetComponent <LootableObject>();
                }

                lootableObject._inventory.Clear();
                FillWithItems(lootableObject, lootStorage.GetItems());

                yield return(new WaitForSeconds(lootStorage.RefillSeconds));
            }
        }
Esempio n. 21
0
        void CheckPositionExplosive(DeployableObject deployedEntity, IDeployableItem deployableItem)
        {
            var objects = GameObject.FindObjectsOfType(typeof(Zone));

            if (objects != null)
            {
                foreach (Zone zone in objects)
                {
                    if (zone.info.undestr == null)
                    {
                        continue;
                    }
                    if (Vector3.Distance(deployedEntity.transform.position, zone.info.Location.GetPosition()) < (zone.info.Location.GetRadius() + 5f))
                    {
                        deployableItem.character.GetComponent <Inventory>().AddItemAmount(deployableItem.datablock, 1);
                        NetCull.Destroy(deployedEntity.gameObject);
                    }
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Drops this item from the inventory.
        /// </summary>
        public ItemPickup Drop()
        {
            if (!IsEmpty())
            {
                IInventoryItem item = GetItemRef();
                if (item == null)
                {
                    return(null);
                }

                CharacterItemDropPrefabTrait trait = new Character().GetTrait <CharacterItemDropPrefabTrait>();

                ItemPickup dropped  = null;
                Vector3    position = internalInv.transform.localPosition;
                // Try making the positions random, instead of letting the objects stuck into together.
                position.x = position.x + UnityEngine.Random.Range(0f, 0.85f);
                position.y = position.y + UnityEngine.Random.Range(0.75f, 1f);
                position.z = position.z + UnityEngine.Random.Range(0f, 0.85f);

                Vector3    arg      = new Vector3(UnityEngine.Random.Range(0.75f, 1.3f), UnityEngine.Random.Range(0.75f, 1.3f), UnityEngine.Random.Range(0.75f, 1.3f));
                Quaternion rotation = new Quaternion(0f, 0f, 0f, 1f);
                GameObject go       = NetCull.InstantiateDynamicWithArgs <Vector3>(trait.prefab, position, rotation, arg);
                dropped = go.GetComponent <ItemPickup>();
                if (!dropped.SetPickupItem(item))
                {
                    //Debug.LogError($"Could not make item pickup for {item}", inventory);
                    NetCull.Destroy(go);
                    //internalInv.RemoveItem(item);
                    //internalInv.MarkSlotDirty(Slot);
                    return(null);
                }

                internalInv.RemoveItem(item);
                //internalInv.MarkSlotDirty(Slot);
                return(dropped);
                //DropHelper.DropItem(this.internalInv, this.Slot);
            }

            return(null);
        }
Esempio n. 23
0
        int CleanAllDeployables(string name, bool all)
        {
            int  destroyed     = 0;
            bool shoulddestroy = true;

            foreach (DeployableObject deployable in UnityEngine.Resources.FindObjectsOfTypeAll <DeployableObject>())
            {
                if (deployable.gameObject.name == name)
                {
                    if (!all && deployable._carrier != null)
                    {
                        continue;
                    }
                    if (shouldDestroy(deployable.transform.position, all))
                    {
                        NetCull.Destroy(deployable.gameObject);
                        destroyed++;
                    }
                }
            }
            return(destroyed);
        }
Esempio n. 24
0
 public void DestroyObject(GameObject go)
 {
     NetCull.Destroy(go);
 }
Esempio n. 25
0
 public void DestroyObject(GameObject go)
 {
     Contract.Requires(go != null);
     NetCull.Destroy(go);
 }
Esempio n. 26
0
        void cmdChatBan(NetUser netuser, string command, string[] args)
        {
            if (!hasAccess(netuser, "canairdrop"))
            {
                SendReply(netuser, notAllowed); return;
            }

            // CALL 1 AIRDROP
            if (args.Length == 0)
            {
                SendReply(netuser, calledAirdrop); SupplyDropZone.CallAirDrop(); return;
            }


            // CANCEL ALL AIRDROPS
            if (args.Length == 1 && args[0].ToString() == "cancel")
            {
                int planenumber = 0;
                foreach (SupplyDropPlane plane in UnityEngine.Resources.FindObjectsOfTypeAll <SupplyDropPlane>())
                {
                    if (plane.gameObject.name == "C130")
                    {
                        continue;
                    }
                    planenumber++;
                    plane.NetDestroy();
                }
                SendReply(netuser, string.Format(cancelledAirdrop, planenumber.ToString()));
                return;
            }

            // DESTROY ALL SUPPLY CRATES
            if (args.Length == 1 && args[0].ToString() == "destroy")
            {
                int cratenumber = 0;
                foreach (SupplyCrate crate in UnityEngine.Resources.FindObjectsOfTypeAll <SupplyCrate>())
                {
                    if (crate.gameObject.name == "SupplyCrate")
                    {
                        continue;
                    }
                    cratenumber++;
                    NetCull.Destroy(crate.gameObject);
                }
                SendReply(netuser, string.Format(destroyedCrates, cratenumber.ToString()));
                return;
            }

            // CALL MASS AIRDROP
            int number;

            if (args.Length == 1 && int.TryParse(args[0], out number))
            {
                SendReply(netuser, string.Format(massAirdrop, number.ToString()));
                for (int i = 0; i < number; i++)
                {
                    SupplyDropZone.CallAirDrop();
                }
                return;
            }

            // CALL AN AIRDROP ON POSITION
            float x;
            float z;

            if (args.Length > 1 && float.TryParse(args[0], out x))
            {
                if (args.Length == 2)
                {
                    float.TryParse(args[1], out z);
                }
                else
                {
                    float.TryParse(args[2], out z);
                }

                if (z != default(float))
                {
                    cachedPos = new Vector3(x, 0f, z);
                    SupplyDropZone.CallAirDropAt(cachedPos);
                    SendReply(netuser, string.Format(airdropPos, cachedPos.ToString()));
                }
                return;
            }

            // CALL AN AIRDROP TO A PLAYER POSITION
            NetUser targetuser = rust.FindPlayer(args[0]);

            if (targetuser != null)
            {
                cachedPos = targetuser.playerClient.lastKnownPosition;
                if (cachedPos != default(Vector3))
                {
                    SupplyDropZone.CallAirDropAt(cachedPos);
                    SendReply(netuser, string.Format(airdropPlayer, cachedPos.ToString(), targetuser.playerClient.userName.ToString()));
                }
                return;
            }


            SendReply(netuser, wrongarguments);
        }