Beispiel #1
0
 public void Broadcast(BaseNetworkable networkable)
 => m_AvailableServers.ForEach((x) => x.Broadcast(networkable));
Beispiel #2
0
 public Task <BaseNetworkableResponse> SendAsync(BaseNetworkable data, NetworkConnection connection)
 {
     return(null);
 }
		/*--------------------------------------------------------------//
		//					OnEntitySpawned Hook						//
		//--------------------------------------------------------------*/
		void OnEntitySpawned(BaseNetworkable entity)
		{
			
			if (entity == null) return;
			if (entity.LookupShortPrefabName() == "heli_crate.prefab") 
			{
				/*-----------------------------------------------------------------------------//
				//Prefab Properties of heli_crate:											   //
				//string guid = c175b252164d05d42ade2fb672b97331							   //
				//uint hash = 2225886856													   //
				//string name = assets/bundled/prefabs/npc/patrol_helicopter/heli_crate.prefab //
				//-----------------------------------------------------------------------------*/
				//Puts("HELI CRATE SPAWNED MOTHER FUCKERRR");

				//-----------------------------------------------------------------------------//
				if ((bool)Config["UseCustomLoot"])
				{
					LootContainer heli_crate = (LootContainer)entity;
					int index;
					//var random;
					do
					{
					var random = new System.Random();
					index = random.Next(storedData.HeliInventoryLists.Count);
					} while(index == last && storedData.HeliInventoryLists.Count > 1);
					last = index;
					//Puts("Index: " + index.ToString());
					BoxInventory inv = storedData.HeliInventoryLists[index];
					heli_crate.inventory.itemList.Clear();
					foreach ( ItemDef itemDef in inv.lootBoxContents)
					{
						Item item = ItemManager.CreateByName(itemDef.name, itemDef.amount);
						item.MoveToContainer(heli_crate.inventory, -1, false);
					}
					heli_crate.inventory.MarkDirty();
				}
				//---------------------------------------------------------------------------*/
				
				/*----------------Fill up the dat file with default drop---------------------//
				//-----------------------used for development--------------------------------//
				try
				{
					LootContainer heli_crate = (LootContainer)entity;
					//Puts(heli_crate.inventory.itemList);
					List<Item> itemlist = heli_crate.inventory.itemList;
					//Puts("itemlist: " + itemlist.Count.ToString());
					BoxInventory temp = new BoxInventory();
					//Puts("started from the bottom now we're here");
					foreach (var item in itemlist)
					{
						ItemDef temp2 = new ItemDef(item.info.shortname, item.amount);
						//Puts("yep");
						temp.lootBoxContents.Add(temp2);
						//Puts("heh");
					}
					foreach (ItemDef itemdef in temp.lootBoxContents)
					{
						Puts("item: " + itemdef.name + " " + itemdef.amount);
					}

					storedData.HeliInventoryLists.Add(temp);
					//Puts(storedData.ToString());
				} 
				catch(NullReferenceException)
				{
					Puts("f**k me it's null again");
				}
				SaveData();
				//-------------------------------------------------------------------------*/
			}

			//994850627 is the prefabID of a heli.
			if (entity.prefabID == 994850627)
			{
				// Disable Helicopters
				if ((bool)Config["DisableHeli"])
				{
					entity.KillMessage();
					Puts("Helicopter destroyed!");
					return;
				}
				BaseHelicopter heli = (BaseHelicopter)entity;
				heli.maxCratesToSpawn = (int)Config["MaxLootCratesToDrop"];
				heli.bulletDamage = float.Parse(Config["HeliBulletDamageAmount"].ToString());
			}
		}
Beispiel #4
0
 public void Send(BaseNetworkable data, NetworkConnection connection)
 {
     throw new NotImplementedException();
 }
 /////////////////////////////////////////
 // OnEntitySpawned(BaseNetworkable entity)
 // Called when any kind of entity is spawned in the world
 /////////////////////////////////////////
 private void OnEntitySpawned(BaseNetworkable entity)
 {
     if (entity is BaseCorpse)
     {
         timer.Once(2f, () =>
         {
             HashSet<Zone> zones;
             if (entity.isDestroyed || !resourceZones.TryGetValue(entity.GetComponent<ResourceDispenser>(), out zones)) return;
             foreach (var zone in zones)
             {
                 if (HasZoneFlag(zone, ZoneFlags.NoCorpse))
                 {
                     entity.KillMessage();
                     break;
                 }
             }
         });
     }
     else if (entity is BuildingBlock && zoneObjects != null)
     {
         var block = (BuildingBlock)entity;
         foreach (var zone in zoneObjects)
         {
             if (HasZoneFlag(zone, ZoneFlags.NoStability))
             {
                 if (zone.Info.Size != Vector3.zero)
                 {
                     if (!new Bounds(zone.Info.Location, Quaternion.Euler(zone.Info.Rotation) * zone.Info.Size).Contains(block.transform.position))
                         continue;
                 }
                 else if (Vector3.Distance(block.transform.position, zone.Info.Location) > zone.Info.radius)
                     continue;
                 block.grounded = true;
                 break;
             }
         }
     }
     var npc = entity.GetComponent<NPCAI>();
     if (npc != null)
         npcNextTick.SetValue(npc, Time.time + 10f);
 }
 void OnEntitySpawned(BaseNetworkable entity)
 {
     KillAnimals();
 }
Beispiel #7
0
 public void On_NetworkableKill(BaseNetworkable baseNetworkable)
 {
     SetHookWorking("On_NetworkableKill");
     Broadcast(baseNetworkable.ShortPrefabName + " got killed at: " + baseNetworkable.transform.position);
 }
Beispiel #8
0
    public void MakeConnection(BaseEntity.RPCMessage msg)
    {
        IOEntity component;
        IOEntity oEntity;

        if (!WireTool.CanPlayerUseWires(msg.player))
        {
            return;
        }
        uint            num             = msg.read.UInt32();
        int             num1            = msg.read.Int32();
        uint            num2            = msg.read.UInt32();
        int             num3            = msg.read.Int32();
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num);

        if (baseNetworkable == null)
        {
            component = null;
        }
        else
        {
            component = baseNetworkable.GetComponent <IOEntity>();
        }
        IOEntity oEntity1 = component;

        if (oEntity1 == null)
        {
            return;
        }
        BaseNetworkable baseNetworkable1 = BaseNetworkable.serverEntities.Find(num2);

        if (baseNetworkable1 == null)
        {
            oEntity = null;
        }
        else
        {
            oEntity = baseNetworkable1.GetComponent <IOEntity>();
        }
        IOEntity oEntity2 = oEntity;

        if (oEntity2 == null)
        {
            return;
        }
        if (Vector3.Distance(baseNetworkable1.transform.position, baseNetworkable.transform.position) > WireTool.maxWireLength)
        {
            return;
        }
        if (num1 >= (int)oEntity1.inputs.Length)
        {
            return;
        }
        if (num3 >= (int)oEntity2.outputs.Length)
        {
            return;
        }
        if (oEntity1.inputs[num1].connectedTo.Get(true) != null)
        {
            return;
        }
        if (oEntity2.outputs[num3].connectedTo.Get(true) != null)
        {
            return;
        }
        if (oEntity1.inputs[num1].rootConnectionsOnly && !oEntity2.IsRootEntity())
        {
            return;
        }
        oEntity1.inputs[num1].connectedTo.Set(oEntity2);
        oEntity1.inputs[num1].connectedToSlot = num3;
        oEntity1.inputs[num1].connectedTo.Init();
        oEntity2.outputs[num3].connectedTo.Set(oEntity1);
        oEntity2.outputs[num3].connectedToSlot = num1;
        oEntity2.outputs[num3].connectedTo.Init();
        oEntity2.MarkDirtyForceUpdateOutputs();
        oEntity2.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        oEntity1.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
        //
        // Update salt map when resource deposit is tapped for the first time
        //
        void OnEntitySpawned(BaseNetworkable entity)
        {
            if (entity is SurveyCharge)
            {
                OreType ore = OreType.None;

                ResourceDepositManager.ResourceDeposit rd = ResourceDepositManager.GetOrCreate(entity.transform.position);

                if (data.changedDeposits.Exists(d => GetVector3(d.origin) == rd.origin))
                {
                    return;
                }

                ResourceDepositManager.ResourceDeposit.ResourceDepositEntry originalResource = null;

                int oreCount = 0;
                foreach (ResourceDepositManager.ResourceDeposit.ResourceDepositEntry resource in rd._resources)
                {
                    switch (resource.type.shortname)
                    {
                    case "sulfur.ore":
                        ore = OreType.Sulfur;
                        originalResource = resource;
                        oreCount++;
                        break;

                    case "metal.ore":
                        ore = OreType.Metal;
                        originalResource = resource;
                        oreCount++;
                        break;

                    case "hq.metal.ore":
                        ore = OreType.HighQuality;
                        originalResource = resource;
                        oreCount++;
                        break;

                    default:
                        break;
                    }
                }

                if (oreCount > 1)
                {
                    return;
                }

                ItemDefinition sulfur = ItemManager.itemList.Find(x => x.shortname == "sulfur.ore");
                ItemDefinition metal  = ItemManager.itemList.Find(x => x.shortname == "metal.ore");
                ItemDefinition hq     = ItemManager.itemList.Find(x => x.shortname == "hq.metal.ore");

                Deposit deposit = new Deposit {
                    origin = GetOrigin(rd.origin)
                };

                if (originalResource == null && rd._resources.Count != 0)
                {
                    originalResource = rd._resources.ToArray()[0];
                }

                System.Random rng        = new System.Random();
                float         workNeeded = (float)(rng.Next(0, 2) + rng.NextDouble());
                int           choice     = rng.Next(1, 100);
                int           amount     = 0;
                switch (ore)
                {
                case OreType.Sulfur:                          // Give a chance at some amount of metal ore
                    if (workNeeded > 1f)
                    {
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                case OreType.Metal:                         // Give a chance at some amount of sulfur ore
                    if (workNeeded > 1.75f)
                    {
                        amount = rng.Next(10000, 100000);
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                case OreType.HighQuality:                        // Give a chance at some amount of either metal, sulfur, or both ores
                    if (choice < 40)                             // Just sulfur
                    {
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else if (choice < 80)                             // Just metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else                             // Both sulfur and metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;

                default:                         // Give a chance at some amount of either metal, sulfur, or both ores
                    if (oreCount == 1)
                    {
                        return;
                    }
                    if (choice < 40)                             // Just sulfur
                    {
                        if (workNeeded > 1.75f)
                        {
                            return;
                        }
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else if (choice < 80)                             // Just metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                    }
                    else                             // Both sulfur and metal
                    {
                        if (workNeeded < 1.75f)
                        {
                            workNeeded += (1.75f - workNeeded);
                        }
                        amount = rng.Next(10000, 100000);
                        rd.Add(metal, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Metal, amount = amount, workNeeded = workNeeded
                        });
                        amount     = rng.Next(10000, 100000);
                        workNeeded = (float)(rng.Next(3, 4) + rng.NextDouble());
                        rd.Add(sulfur, 1, amount, workNeeded, ResourceDepositManager.ResourceDeposit.surveySpawnType.ITEM);
                        deposit.entries.Add(new DepositEntry()
                        {
                            type = OreType.Sulfur, amount = amount, workNeeded = workNeeded
                        });
                    }
                    break;
                }

                data.changedDeposits.Add(deposit);
                SaveData();
            }
        }
Beispiel #10
0
 public static void NetworkableKill(BaseNetworkable bn)
 {
     OnNetworkableKill.OnNext(bn);
 }
Beispiel #11
0
 private void OnEntitySpawned(BaseNetworkable a)
 {
     CheckEntity(a);
 }
Beispiel #12
0
 /////////////////////////////////////////
 // OnEntitySpawned(BaseNetworkable entity)
 // Called when any kind of entity is spawned in the world
 /////////////////////////////////////////
 private void OnEntitySpawned(BaseNetworkable entity)
 {
     if (entity is BaseCorpse)
     {
         timer.Once(2f, () =>
         {
             HashSet<Zone> zones;
             if (!resourceZones.TryGetValue(entity.GetComponent<ResourceDispenser>(), out zones)) return;
             foreach (var zone in zones)
             {
                 if (HasZoneFlag(zone, ZoneFlags.NoCorpse))
                 {
                     entity.KillMessage();
                     break;
                 }
             }
         });
     }
     else if (entity is BuildingBlock && zoneObjects != null)
     {
         var block = (BuildingBlock) entity;
         foreach (var zone in zoneObjects)
         {
             if (HasZoneFlag(zone, ZoneFlags.NoStability) && zone.Collider.bounds.Contains(block.transform.position))
             {
                 block.grounded = true;
                 break;
             }
         }
     }
     var npc = entity.GetComponent<NPCAI>();
     if (npc != null)
         npcNextTick.SetValue(npc, Time.time + 10f);
 }
Beispiel #13
0
 private void OnEntitySpawned(BaseNetworkable entity)
 {
     HookCalled("OnEntitySpawned");
 }
Beispiel #14
0
        void ModifyContainerContents(BaseNetworkable entity)
        {
            var e = entity as LootContainer; if (e == null)
            {
                return;
            }
            List <Rarity> RaritiesUsed = new List <Rarity>();

            foreach (Item lootitem in e.inventory.itemList.ToList())
            {
                if (exclude.list.Contains(lootitem.info.shortname))
                {
                    lootitem.RemoveFromContainer(); e.inventory.itemList.Remove(lootitem); break;
                }
                if (Convert.ToInt16(Config["Settings", "Multiplier"]) != VANILLA_MULTIPLIER)
                {
                    if (lootitem.info.stackable > 1)
                    {
                        if (Convert.ToBoolean(Config["Developer", "Debug"]))
                        {
                            string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=yellow>" + lootitem.info.displayName.english + " : original amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                        }

                        int limit = 0;
                        int ac    = lootitem.amount * Convert.ToUInt16(Config["Settings", "Multiplier"]);
                        if (LootData.ItemList.TryGetValue(lootitem.info.shortname, out limit))
                        {
                            lootitem.amount = Math.Min(ac, Math.Min(limit, lootitem.info.stackable));
                        }

                        if (Convert.ToBoolean(Config["Developer", "Debug"]))
                        {
                            string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=white>" + lootitem.info.displayName.english + " : new amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                        }
                    }
                }
                if (lootitem.info.rarity != Rarity.None && !RaritiesUsed.Contains(lootitem.info.rarity))
                {
                    RaritiesUsed.Add(lootitem.info.rarity);
                }
            }
            if (Convert.ToBoolean(Config["Loot", "Enabled"]))
            {
                if (RarityList.Count == 0)
                {
                    GenerateRarityList();
                }
                if (RaritiesUsed.Count >= 1 && RaritiesUsed != null)
                {
                    Rarity         rarity = RaritiesUsed.GetRandom();
                    ItemDefinition item;
                    int            itemstogive    = UnityEngine.Random.Range(Convert.ToInt16(Config["Loot", "ItemsMin"]), Convert.ToInt16(Config["Loot", "ItemsMax"]));
                    int            final_capacity = e.inventory.itemList.Count() + itemstogive;
                    e.inventory.capacity = final_capacity;
                    e.inventorySlots     = final_capacity;
                    for (int i = 1; i <= itemstogive; i++)
                    {
                        item = RarityList[rarity].GetRandom();
                        if (item != null)
                        {
                            if (exclude.list.Contains(item.shortname))
                            {
                                break;
                            }
                            int limit = 0; int amounttogive = 0;
                            if (LootData.ItemList.TryGetValue(item.shortname, out limit) && item.stackable > 1)
                            {
                                amounttogive = UnityEngine.Random.Range(Convert.ToInt16(Config["Loot", "AmountMin"]), Math.Min(limit, item.stackable));
                            }
                            else
                            {
                                amounttogive = item.stackable;
                            }
                            e.inventory.AddItem(item, amounttogive);
                            if (Convert.ToBoolean(Config["Developer", "Debug"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=white>Extra Item: " + item.displayName.english + " : amount: " + amounttogive.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }
                        }
                    }
                }
            }
        }
Beispiel #15
0
    public void AddBookmark(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!IsPlayerAdmin(player) || isStatic)
        {
            return;
        }
        if (UnityEngine.Time.realtimeSinceStartup < nextAddTime)
        {
            player.ChatMessage("Slow down...");
            return;
        }
        if (controlBookmarks.Count >= 128)
        {
            player.ChatMessage("Too many bookmarks, delete some");
            return;
        }
        nextAddTime = UnityEngine.Time.realtimeSinceStartup + 1f;
        string text = msg.read.String();

        if (!IsValidIdentifier(text))
        {
            return;
        }
        foreach (KeyValuePair <string, uint> controlBookmark in controlBookmarks)
        {
            if (controlBookmark.Key == text)
            {
                return;
            }
        }
        uint num  = 0u;
        bool flag = false;

        foreach (IRemoteControllable allControllable in RemoteControlEntity.allControllables)
        {
            if (allControllable != null && allControllable.GetIdentifier() == text)
            {
                if (!(allControllable.GetEnt() == null))
                {
                    num  = allControllable.GetEnt().net.ID;
                    flag = true;
                    break;
                }
                Debug.LogWarning("Computer station added bookmark with missing ent, likely a static CCTV (wipe the server)");
            }
        }
        if (!flag)
        {
            return;
        }
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num);

        if (baseNetworkable == null)
        {
            return;
        }
        IRemoteControllable component = baseNetworkable.GetComponent <IRemoteControllable>();

        if (component != null && Interface.CallHook("OnBookmarkAdd", this, player, text) == null)
        {
            string identifier = component.GetIdentifier();
            if (text == identifier)
            {
                controlBookmarks.Add(text, num);
            }
            SendControlBookmarks(player);
        }
    }
        private void OnEntitySpawned(BaseNetworkable entity)
        {
            var prefabname = entity.name;

            if (prefabname.Contains("bradleyapc"))
            {
                bradleys.Add(entity as BradleyAPC);
            }

            if (lastBradleyDeath == 0.0f || Time.realtimeSinceStartup - lastBradleyDeath > 2.0f) // TODO: Check if around a Bradley instead.
            {
                lastBradleyDeath = 0.0f;
                return;
            }

            var debris = entity?.GetComponent <HelicopterDebris>() ?? null;

            gibs.Add(debris);

            if (prefabname.Contains("servergibs_bradley"))
            {
                NextTick(() =>
                {
                    if (debris == null || entity.IsDestroyed)
                    {
                        return;
                    }

                    debris.InitializeHealth(configs.options.gibsHealth, configs.options.gibsHealth);

                    if (configs.options.gibsHotDelay != -1.0f)
                    {
                        tooHotUntil.SetValue(debris, Time.realtimeSinceStartup + configs.options.gibsHotDelay);
                    }

                    if (!configs.options.enableGibs)
                    {
                        entity.Kill();
                    }

                    debris.SendNetworkUpdate();
                });
            }

            if ((prefabname.Contains("napalm") || prefabname.Contains("oilfireball")) && !prefabname.Contains("rocket"))
            {
                fireBalls.Add(entity as FireBall);

                NextTick(() =>
                {
                    var fireball = entity?.GetComponent <FireBall>() ?? null;

                    if (fireball == null || (entity?.IsDestroyed ?? true))
                    {
                        return;
                    }

                    if (configs.options.lootAccessDelay != -1)
                    {
                        fireball.lifeTimeMin = configs.options.lootAccessDelay - 10.0f;
                        fireball.lifeTimeMax = configs.options.lootAccessDelay + 10.0f;
                    }

                    if (configs.options.napamWaterRequired != -1)
                    {
                        fireball.waterToExtinguish = configs.options.napamWaterRequired;
                    }

                    if (!configs.options.enableNapalm)
                    {
                        fireball.enableSaving = false;
                        entity.Kill();
                    }

                    fireball.SendNetworkUpdate();
                });
            }

            if (prefabname.Contains("bradley_crate"))
            {
                var loot = entity?.GetComponent <LootContainer>() ?? null;
                lockedCrates.Add(entity?.GetComponent <LockedByEntCrate>() ?? null);

                if (configs.options.customLootTables && configs.lootTables.bradleyCrate.Count != 0)
                {
                    loot.inventory.itemList.Clear();

                    for (int i = 0; i < 6; i++)
                    {
                        var keys = Enumerable.ToList(configs.lootTables.bradleyCrate.Keys);
                        int t    = i == 0 ? 1 : i < 3 ? 2 : 3;
                        int r    = random.Next(keys.Count);
                        var val  = configs.lootTables.bradleyCrate[keys[r]];
                        int j    = 0;

                        while ((Convert.ToInt32(val[2]) != t || Convert.ToInt32(val[0]) == 0) && j != 20)
                        {
                            r   = random.Next(keys.Count);
                            val = configs.lootTables.bradleyCrate[keys[r]];
                            j++;
                        }

                        var item = ItemManager.CreateByItemID(ItemManager.FindItemDefinition(keys[r]).itemid, Convert.ToInt32(val[0]), Convert.ToUInt64(val[1]));
                        item.MoveToContainer(loot.inventory);
                    }

                    loot.inventory.MarkDirty();
                }

                if (configs.options.lootAccessDelay != -1.0f)
                {
                    timer.Once(configs.options.lootAccessDelay, () =>
                    {
                        var crate = entity?.GetComponent <LockedByEntCrate>() ?? null;

                        if (crate == null || (entity?.IsDestroyed ?? true))
                        {
                            return;
                        }

                        var lockingEnt = (crate?.lockingEnt != null) ? crate.lockingEnt.GetComponent <FireBall>() : null;

                        if (lockingEnt != null && !(lockingEnt?.IsDestroyed ?? true))
                        {
                            lockingEnt.enableSaving = false;
                            lockingEnt.CancelInvoke(lockingEnt.Extinguish);
                            lockingEnt.Invoke(lockingEnt.Extinguish, 30.0f);
                        }

                        crate.CancelInvoke(crate.Think);
                        crate.SetLocked(false);
                        crate.lockingEnt = null;
                    });
                }
            }
        }
Beispiel #17
0
 void OnEntityKill(BaseNetworkable entity) => OnKilledChild((BaseEntity)entity);
 void KillCoptor(BaseNetworkable entity)
 {
     //ConsoleSystem.Broadcast("chat.add", 0, "<color=Red> [Coptor Tracker]</color>  Patrol Coptor Has been removed due to lack of something", 1);
     entity.Kill();
 }
 private void OnEntitySpawned(BaseNetworkable entity) => CheckEntity(entity.GetComponent <BaseEntity>());
Beispiel #20
0
 private void AreaTimer()
 {
     // ==================================== [ ENTITY PORTION ] ==========================================
     new List <uint>(MAData.Entities.Keys).ForEach(u =>
     {
         BaseNetworkable ent = BaseNetworkable.serverEntities.Find(u);
         if (ent != null && UnixTimeStampUTC() >= MAData.Entities[u].iExpire)
         {
             int area_id = MAData.Entities[u].iAreaID;
             if (area_id != -1 && MagicAreaExists(area_id))
             {
                 if (MAData.Areas[area_id].bRemoveEntities && MAData.Areas[area_id].iEntityExpire != 0)
                 {
                     MAData.Entities.Remove(u);
                     ent.Kill();
                     if (Convert.ToBoolean(Config["Settings", "Debug"]))
                     {
                         Puts("Removing entity ID: " + u.ToString() + " [EXPIRED]");
                     }
                 }
             }
         }
     });
     // ================================== [ PLAYER ] ====================================================
     foreach (BasePlayer connected_player in BasePlayer.activePlayerList)
     {
         bool found = false;
         if (connected_player != null && connected_player.IsConnected)
         {
             if (!PlayerExists(connected_player))
             {
                 InitPlayer(connected_player);
             }
             foreach (var area in MAData.Areas.Values)
             {
                 if (PlayerToPoint(connected_player, area.fRadius, area.fMinX, area.fMinY, area.fMinZ))
                 {
                     if (MAData.PlayerData[connected_player.userID].iInArea != area.iID)
                     {
                         MAData.PlayerData[connected_player.userID].iInArea = area.iID;
                         Interface.Oxide.CallHook("OnPlayerEnterMagicArea", connected_player, MAData.PlayerData[connected_player.userID].iInArea);
                         if (area.tKit.Length >= 1 && area.tKit != null)
                         {
                             object iskit = Kits?.Call("isKit", area.tKit);
                             if (iskit is bool && (bool)iskit)
                             {
                                 connected_player.inventory.Strip();
                                 object successkit = Kits.Call("GiveKit", connected_player, area.tKit);
                                 if (successkit is bool && (bool)successkit)
                                 {
                                     string parsed_config = GetMessage("KitReceived", connected_player.UserIDString);
                                     parsed_config = parsed_config.Replace("{kit_name}", area.tKit);
                                     parsed_config = parsed_config.Replace("{area_title}", area.tTitle);
                                     PrintToChat(connected_player, parsed_config);
                                 }
                             }
                         }
                     }
                     found = true;
                 }
             }
             if (!found && MAData.PlayerData[connected_player.userID].iInArea != -1)
             {
                 if (MAData.Areas[MAData.PlayerData[connected_player.userID].iInArea].bResetInv)
                 {
                     PrintToChat(connected_player, GetMessage("InventoryReset", connected_player.UserIDString));
                     connected_player.inventory.Strip();
                 }
                 Interface.Oxide.CallHook("OnPlayerExitMagicArea", connected_player, MAData.PlayerData[connected_player.userID].iInArea);
                 MAData.PlayerData[connected_player.userID].iInArea = -1;
             }
         }
     }
 }
Beispiel #21
0
 /// <summary>
 /// Called from <c>BaseNetworkable.Kill(BaseNetworkable.DestroyMode)</c> .
 /// </summary>
 public static void On_NetworkableKill(BaseNetworkable bn) => OnNext("On_NetworkableKill", bn);
 public RustNetworkableTransform(BaseNetworkable baseNetworkable)
 {
     m_BaseNetworkable = baseNetworkable;
     m_UnityTransform  = new UnityTransform(baseNetworkable.transform);
 }
Beispiel #23
0
 private object OnEntitySpawned(BaseNetworkable entity)
 {
     return Interface.Oxide.CallDeprecatedHook("OnEntitySpawn", entity);
 }
Beispiel #24
0
 public void Broadcast(BaseNetworkable data)
 {
     throw new NotImplementedException();
 }
 // automatically set lights on that are deployed if the lights are in the on state
 private void OnEntitySpawned(BaseNetworkable entity)
 {
     // Puts(entity.ShortPrefabName);
     // will turn the light on during a lights on phase or if neither is set to on
     if ((config.AlwaysOn || NightToggleactive) &&
         ProcessShortPrefabName(entity.ShortPrefabName))
     {
         if (entity is BaseOven)
         {
             var bo = entity as BaseOven;
             bo.SetFlag(BaseEntity.Flags.On, true);
         }
         else if (entity is CeilingLight)
         {
             var cl = entity as CeilingLight;
             cl.SetFlag(BaseEntity.Flags.On, true);
         }
         else if (entity is SimpleLight)
         {
             var sl = entity as SimpleLight;
             sl.SetFlag(BaseEntity.Flags.On, true);
         }
         else if (entity is SearchLight)
         {
             var sl = entity as SearchLight;
             sl.SetFlag(BaseEntity.Flags.On, true);
             sl.secondsRemaining = 99999999;
         }
         else if (entity is Candle)
         {
             var ca = entity as Candle;
             ca.SetFlag(BaseEntity.Flags.On, true);
         }
     }
     if ((config.DevicesAlwaysOn || NightToggleactive) &&
         ProcessShortPrefabName(entity.ShortPrefabName))
     {
         if (entity is FogMachine)
         {
             var fm = entity as FogMachine;
             fm.SetFlag(BaseEntity.Flags.On, true);
             fm.EnableFogField();
             fm.StartFogging();
         }
         else if (entity is SnowMachine)
         {
             var sl = entity as SnowMachine;
             sl.SetFlag(BaseEntity.Flags.On, true);
         }
         else if (entity is StrobeLight)
         {
             var sl = entity as StrobeLight;
             sl.SetFlag(BaseEntity.Flags.On, true);
         }
         else if (entity is SpookySpeaker)
         {
             var ss = entity as SpookySpeaker;
             ss.SetFlag(BaseEntity.Flags.On, true);
             ss.SendPlaySound();
         }
     }
 }
Beispiel #26
0
 public Task <BaseNetworkableResponse> SendAsync(BaseNetworkable data, NetworkConnection connection)
 {
     throw new NotImplementedException();
 }
Beispiel #27
0
        public static void OnEntityDestroy(Message packet)
        {
            UInt32 uid = packet.read.EntityID();

            BaseNetworkable.Destroy(uid);
        }
Beispiel #28
0
 public void Send(BaseNetworkable data, NetworkConnection connection)
 => m_AvailableServers.ForEach((x) => x.Send(data, connection));
Beispiel #29
0
 private void OnEntitySpawned(BaseNetworkable entity)
 {
     HookCalled("OnEntitySpawned");
 }
Beispiel #30
0
 void Block(BaseNetworkable block, BasePlayer player, bool Height, bool Water)
 {
     if (usePermissions && !IsAllowed(player.UserIDString, permBS) && player.net.connection.authLevel < AuthLvl && block && !block.IsDestroyed)
     {
         Vector3 Pos = block.transform.position;
         if (Height || Water)
         {
             float height = TerrainMeta.HeightMap.GetHeight(Pos);
             if (Height && Pos.y - height > HeightBlock)
             {
                 Reply(player, Lang("blockHeight", player.UserIDString, HeightBlock));
                 block.Kill(BaseNetworkable.DestroyMode.Gib);
                 return;
             }
             else if (Water && height < 0 && height < WaterBlock && Pos.y < 2.8f)
             {
                 Reply(player, Lang("blockWater", player.UserIDString, WaterBlock));
                 block.Kill(BaseNetworkable.DestroyMode.Gib);
                 return;
             }
         }
         if (BlockInRock)
         {
             Pos.y += 200;
             RaycastHit[] hits = Physics.RaycastAll(Pos, Vector3.down, 199.0f);
             Pos.y -= 200;
             for (int i = 0; i < hits.Length; i++)
             {
                 RaycastHit hit = hits[i];
                 if (hit.collider)
                 {
                     string ColName = hit.collider.name;
                     if ((ColName.StartsWith("rock", StringComparison.CurrentCultureIgnoreCase) || ColName.StartsWith("cliff", StringComparison.CurrentCultureIgnoreCase)) && (hit.point.y < Pos.y ? BlockInRock : hit.collider.bounds.Contains(Pos)))
                     {
                         var buildingBlock = block.GetComponent <BuildingBlock>();
                         if (buildingBlock != null)
                         {
                             foreach (ItemAmount item in buildingBlock.blockDefinition.grades[(int)buildingBlock.grade].costToBuild)
                             {
                                 player.inventory.GiveItem(ItemManager.CreateByItemID(item.itemid, (int)item.amount));
                             }
                         }
                         Reply(player, Lang("block", player.UserIDString));
                         block.Kill(BaseNetworkable.DestroyMode.Gib);
                         break;
                     }
                 }
             }
         }
         if (BlockOnIceberg)
         {
             Pos.y += 200;
             RaycastHit[] hits = Physics.RaycastAll(Pos, Vector3.down, 202.8f);
             Pos.y -= 200;
             for (int i = 0; i < hits.Length; i++)
             {
                 RaycastHit hit = hits[i];
                 if (hit.collider)
                 {
                     string ColName = hit.collider.name;
                     if (BlockOnIceberg && ColName == "iceberg_COL")
                     {
                         var buildingBlock = block.GetComponent <BuildingBlock>();
                         if (buildingBlock != null)
                         {
                             foreach (ItemAmount item in buildingBlock.blockDefinition.grades[(int)buildingBlock.grade].costToBuild)
                             {
                                 player.inventory.GiveItem(ItemManager.CreateByItemID(item.itemid, (int)item.amount));
                             }
                         }
                         Reply(player, Lang("blockIce", player.UserIDString));
                         block.Kill(BaseNetworkable.DestroyMode.Gib);
                         break;
                     }
                 }
             }
         }
         if (BlockUnTerrain)
         {
             Pos.y += 200;
             RaycastHit[] hits = Physics.RaycastAll(Pos, Vector3.down, 199.0f);
             Pos.y -= 200;
             bool isMining = block is MiningQuarry;
             for (int i = 0; i < hits.Length; i++)
             {
                 RaycastHit hit = hits[i];
                 if (hit.collider)
                 {
                     string ColName = hit.collider.name;
                     if (BlockUnTerrain && !isMining && ColName == "Terrain" && hit.point.y > Pos.y)
                     {
                         var buildingBlock = block.GetComponent <BuildingBlock>();
                         if (buildingBlock != null)
                         {
                             foreach (ItemAmount item in buildingBlock.blockDefinition.grades[(int)buildingBlock.grade].costToBuild)
                             {
                                 player.inventory.GiveItem(ItemManager.CreateByItemID(item.itemid, (int)item.amount));
                             }
                         }
                         Reply(player, Lang("blockTerrain", player.UserIDString));
                         block.Kill(BaseNetworkable.DestroyMode.Gib);
                         break;
                     }
                 }
             }
         }
     }
 }
 public async Task <TcpNetworkData> SendAsync(BaseNetworkable data)
 => await Task.Run(() => Service.SendAndWait(data));
Beispiel #32
0
        void ModifyContainerContents(BaseNetworkable entity)
        {
            var e = entity as LootContainer; if (e?.inventory?.itemList == null)
            {
                return;
            }
            List <Rarity> RaritiesUsed  = new List <Rarity>();
            List <Item>   ItemsToRemove = new List <Item>();

            foreach (Item lootitem in e.inventory.itemList)
            {
                if (Exclude.list.Contains(lootitem.info.shortname))
                {
                    ItemsToRemove.Add(lootitem); continue;
                }
                if (lootitem.IsBlueprint() && Convert.ToBoolean(Config["_Settings", "DisableBlueprintDropMultiplier"]))
                {
                    continue;
                }
                if (ExcludeFromMultiplication.list.Contains(lootitem.info.shortname))
                {
                    continue;
                }
                var skins = GetSkins(ItemManager.FindItemDefinition(lootitem.info.itemid));
                if (skins.Count > 1 && Convert.ToBoolean(Config["_Settings", "RandomWorkshopSkins"])) // If workshop skins enabled, randomise skin
                {
                    lootitem.skin = skins.GetRandom(); if (lootitem.GetHeldEntity() != null)
                    {
                        lootitem.GetHeldEntity().skinID = lootitem.skin;
                    }

                    // Debug msges
                    if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "Skins"]))
                    {
                        string debugs = "[" + lootitem.info.displayName.english + "] Skin has been modified to: " + lootitem.skin; Puts(debugs); PrintToChat(debugs);
                    }
                }
                double multiplier = 1.0;
                if (Components.list.TryGetValue(lootitem.info.shortname, out multiplier))
                {
                    CrateData data = null;
                    Crates.list.TryGetValue(e.ShortPrefabName.ToString(), out data);

                    if (Convert.ToInt16(Config["_Settings", "ItemListMultiplier"]) != VANILLA_MULTIPLIER || multiplier != VANILLA_MULTIPLIER || (data != null && data.lootMultiplier != VANILLA_MULTIPLIER))
                    {
                        if (lootitem.info.stackable > 1) // Detect whether to change Amounts
                        {
                            // Debug msges
                            if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "AmountChange"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=yellow>" + lootitem.info.displayName.english + " : original amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }

                            double crateMult = 1.0;
                            if (data != null)
                            {
                                crateMult = data.lootMultiplier;
                            }

                            int limit = 0;
                            int ac    = (int)(lootitem.amount * Convert.ToUInt16(Config["_Settings", "ItemListMultiplier"]) * multiplier * crateMult);
                            if (LootData.ExtraLootList.TryGetValue(lootitem.info.shortname, out limit))
                            {
                                lootitem.amount = Math.Min(ac, Math.Min(limit, lootitem.info.stackable));
                            }
                            else
                            {
                                break;
                            }

                            if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "AmountChange"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=white>" + lootitem.info.displayName.english + " : new amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }
                        }
                    }
                }
                else
                {
                    CrateData data = null;
                    Crates.list.TryGetValue(e.ShortPrefabName.ToString(), out data);

                    if (Convert.ToInt16(Config["_Settings", "Multiplier"]) != VANILLA_MULTIPLIER || (data != null && data.lootMultiplier != VANILLA_MULTIPLIER))
                    {
                        if (lootitem.info.stackable > 1 && !Convert.ToBoolean(Config["_Settings", "MultiplyOnlyItemList"])) // Detect whether to change Amounts
                        {
                            // Debug msges
                            if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "AmountChange"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=yellow>" + lootitem.info.displayName.english + " : original amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }

                            double crateMult = 1.0;
                            if (data != null)
                            {
                                crateMult = data.lootMultiplier;
                            }

                            int limit = 0;
                            int ac    = (int)(lootitem.amount * Convert.ToUInt16(Config["_Settings", "Multiplier"]) * crateMult);
                            if (LootData.ExtraLootList.TryGetValue(lootitem.info.shortname, out limit))
                            {
                                lootitem.amount = Math.Min(ac, Math.Min(limit, lootitem.info.stackable));
                            }
                            else
                            {
                                break;
                            }

                            // Debug msges
                            if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "AmountChange"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=white>" + lootitem.info.displayName.english + " : new amount: " + lootitem.amount.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }
                        }
                    }
                }
                if (lootitem.info.rarity != Rarity.None && !RaritiesUsed.Contains(lootitem.info.rarity))
                {
                    RaritiesUsed.Add(lootitem.info.rarity);
                }
            }

            if (ItemsToRemove.Count > 0)
            {
                foreach (Item k in ItemsToRemove)
                {
                    k.RemoveFromContainer();
                    e.inventory.itemList.Remove(k);
                }
            }

            if (Convert.ToBoolean(Config["ExtraLoot", "Enabled"]) && !Convert.ToBoolean(Config["ExtraLoot", "VanillaLootTablesOnly"])) // Extra Loot Items
            {
                if (RarityList.Count == 0)
                {
                    GenerateRarityList();
                }

                //Puts("RarityList.Count: " + RarityList.Count + "  RaritiesUsed.Count - " + RaritiesUsed.Count + " " + e.GetEstimatedWorldPosition());
                if (RaritiesUsed.Count >= 1 && RaritiesUsed != null)
                {
                    Rarity         rarity = RaritiesUsed.GetRandom();
                    ItemDefinition item;
                    CrateData      data = null;
                    int            min  = Convert.ToInt16(Config["ExtraLoot", "ExtraItemsMin"]);
                    int            max  = Convert.ToInt16(Config["ExtraLoot", "ExtraItemsMax"]);
                    if (Crates.list.TryGetValue(e.ShortPrefabName.ToString(), out data) && data != null)
                    {
                        min += data.minExtraItems;
                        max += data.maxExtraItems;
                    }

                    int itemstogive = UnityEngine.Random.Range(min, max);
                    int tempCap     = e.inventory.capacity;
                    e.inventory.capacity = MAX_LOOT_CONTAINER_SLOTS;
                    e.inventorySlots     = MAX_LOOT_CONTAINER_SLOTS;
                    for (int i = 1; i <= itemstogive; i++)
                    {
                        item = RarityList[rarity].GetRandom();
                        if (e.inventory.FindItemsByItemID(item.itemid).Count >= 1 && item.stackable == 1 && Convert.ToBoolean(Config["ExtraLoot", "PreventDuplicates"]))
                        {
                            break;
                        }
                        if (item != null)
                        {
                            if (Exclude.list.Contains(item.shortname))
                            {
                                break;
                            }
                            int limit = 0; int amounttogive = 0;
                            if (LootData.ExtraLootList.TryGetValue(item.shortname, out limit) && item.stackable > 1)
                            {
                                amounttogive = UnityEngine.Random.Range(Convert.ToInt16(Config["ExtraLoot", "ItemStackSizeMin"]), Math.Min(limit, item.stackable));
                            }
                            else
                            {
                                amounttogive = item.stackable;
                            }
                            var skins = GetSkins(item);
                            if (skins.Count > 1 && Convert.ToBoolean(Config["_Settings", "RandomWorkshopSkins"]))
                            {
                                Item skinned = ItemManager.CreateByItemID(item.itemid, amounttogive, skins.GetRandom()); skinned.MoveToContainer(e.inventory, -1, false);
                            }
                            else
                            {
                                e.inventory.AddItem(item, amounttogive);
                            }

                            // Debug msges
                            if (Convert.ToBoolean(Config["DeveloperDebug", "_EnableLogs"]) && Convert.ToBoolean(Config["DeveloperDebug", "ExtraItem"]))
                            {
                                string debugs = "[<color=green>" + e.GetInstanceID().ToString() + "</color> | " + e.ShortPrefabName + "] <color=white>Extra Item: " + item.displayName.english + " : amount: " + amounttogive.ToString() + "</color>"; Puts(debugs); PrintToChat(debugs);
                            }
                        }
                    }
                    int fcapacity = Math.Max(tempCap, e.inventory.itemList.Count());
                    e.inventory.capacity = fcapacity;
                    e.inventorySlots     = fcapacity;
                }
            }
        }
 public async Task <T> SendAsync <T>(BaseNetworkable data, Packets awaitablePacketId) where T : BaseNetworkable
 => await Task.Run(() => Service.SendAsync <T>(data, (int)awaitablePacketId));
 public RustBaseNetworkableAsset(BaseNetworkable networkable, string type)
 {
     BuildableAssetId = networkable.PrefabName;
     BuildableType    = type;
 }
        // TODO: made that => await Task.Run(() => Service.SendAsync<T>(data, data.Identifier));

        public void Send(BaseNetworkable data)
        => Service.Send(data);
Beispiel #36
0
    public void AddLine(BaseEntity.RPCMessage msg)
    {
        IOEntity component;
        IOEntity oEntity;

        if (!WireTool.CanPlayerUseWires(msg.player))
        {
            return;
        }
        int num = msg.read.Int32();

        if (num > 18)
        {
            return;
        }
        List <Vector3> vector3s = new List <Vector3>();

        for (int i = 0; i < num; i++)
        {
            vector3s.Add(msg.read.Vector3());
        }
        if (!this.ValidateLine(vector3s))
        {
            return;
        }
        uint            num1            = msg.read.UInt32();
        int             num2            = msg.read.Int32();
        uint            num3            = msg.read.UInt32();
        int             num4            = msg.read.Int32();
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num1);

        if (baseNetworkable == null)
        {
            component = null;
        }
        else
        {
            component = baseNetworkable.GetComponent <IOEntity>();
        }
        IOEntity oEntity1 = component;

        if (oEntity1 == null)
        {
            return;
        }
        BaseNetworkable baseNetworkable1 = BaseNetworkable.serverEntities.Find(num3);

        if (baseNetworkable1 == null)
        {
            oEntity = null;
        }
        else
        {
            oEntity = baseNetworkable1.GetComponent <IOEntity>();
        }
        IOEntity array = oEntity;

        if (array == null)
        {
            return;
        }
        if (num2 >= (int)oEntity1.inputs.Length)
        {
            return;
        }
        if (num4 >= (int)array.outputs.Length)
        {
            return;
        }
        if (oEntity1.inputs[num2].connectedTo.Get(true) != null)
        {
            return;
        }
        if (array.outputs[num4].connectedTo.Get(true) != null)
        {
            return;
        }
        array.outputs[num4].linePoints = vector3s.ToArray();
        array.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
Beispiel #37
0
        void CheckBlock(BaseNetworkable StartBlock, BasePlayer sender, bool CheckHeight, bool CheckWater)
        {
            if (StartBlock && sender.net.connection.authLevel < AuthLVL && !StartBlock.isDestroyed)
            {
                Vector3 Pos = StartBlock.transform.position;
                if (StartBlock.name == "foundation.steps(Clone)")
                {
                    Pos.y += 1.3f;
                }

                if (CheckHeight || CheckWater)
                {
                    float height = TerrainMeta.HeightMap.GetHeight(Pos);
                    if (CheckHeight && Pos.y - height > MaxHeight)
                    {
                        sender.ChatMessage(MsgHeight);
                        StartBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                        return;
                    }
                    else if (CheckWater && height < 0 && height < MaxWater && Pos.y < 2.8f)
                    {
                        sender.ChatMessage(MsgWater);
                        StartBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                        return;
                    }
                }

                Pos.y += 200;
                RaycastHit[] hits = Physics.RaycastAll(Pos, Vector3.down, 202.8f);
                Pos.y -= 200;

                bool isMining = StartBlock is MiningQuarry;
                for (int i = 0; i < hits.Length; i++)
                {
                    RaycastHit hit = hits[i];
                    if (hit.collider)
                    {
                        string ColName = hit.collider.name;
                        if (UnTerrain && !isMining && ColName == "Terrain" && hit.point.y > Pos.y ||
                            InBase && ColName.StartsWith("base", StringComparison.CurrentCultureIgnoreCase) ||
                            InMetalBuilding && ColName == "Metal_building_COL" ||
                            UnBridge && ColName == "Bridge_top" ||
                            UnRadio && ColName.StartsWith("dish") ||
                            InWarehouse && ColName.StartsWith("Warehouse") ||
                            InHangar && ColName.StartsWith("Hangar") ||
                            OnRiver && ColName == "rivers" ||
                            InTunnel && ColName.Contains("unnel") ||
                            OnRoad && ColName.EndsWith("road", StringComparison.CurrentCultureIgnoreCase) ||
                            InStormDrain && ColName.StartsWith("Storm_drain", StringComparison.CurrentCultureIgnoreCase) ||
                            InTank && ColName == "howie_spheretank_blockin" ||
                            (ColName.StartsWith("rock", StringComparison.CurrentCultureIgnoreCase) ||
                             ColName.StartsWith("cliff", StringComparison.CurrentCultureIgnoreCase)) &&
                            (hit.point.y < Pos.y ? OnRock : hit.collider.bounds.Contains(Pos) ? InRock : InCave))
                        {
                            sender.ChatMessage(Msg);
                            StartBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                            break;
                        }
                    }
                }
            }
        }
Beispiel #38
0
 /////////////////////////////////////////////////////
 ///  DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 ///  Erase function
 /////////////////////////////////////////////////////
 private static void DoErase(BuildPlayer buildplayer, BasePlayer player, Collider baseentity)
 {
     currentBaseNet = baseentity.GetComponentInParent<BaseNetworkable>();
     currentBaseNet?.Kill(BaseNetworkable.DestroyMode.Gib);
 }
 private void OnEntityKill(BaseNetworkable networkable)
 {
     var entity = networkable as BaseEntity;
     if (entity == null) return;
     var resource = entity.GetComponent<ResourceDispenser>();
     if (resource != null)
     {
         HashSet<Zone> zones;
         if (resourceZones.TryGetValue(resource, out zones))
         {
             foreach (var source in zones.ToArray())
                 OnResourceExitZone(source, resource);
         }
     }
     else if (entity is BasePlayer)
     {
         var player = (BasePlayer)entity;
         HashSet<Zone> zones;
         if (playerZones.TryGetValue(player, out zones))
         {
             foreach (var zone in zones.ToArray())
                 OnPlayerExitZone(zone, player);
         }
     }
     else if (entity is BaseNPC)
     {
         var npc = (BaseNPC)entity;
         HashSet<Zone> zones;
         if (npcZones.TryGetValue(npc, out zones))
         {
             foreach (var source in zones.ToArray())
                 OnNpcExitZone(source, npc);
         }
     }
     else if (entity is BaseCombatEntity && !(entity is LootContainer) && !(entity is BaseHelicopter))
     {
         var building = (BaseCombatEntity)entity;
         HashSet<Zone> zones;
         if (buildingZones.TryGetValue(building, out zones))
         {
             foreach (var source in zones.ToArray())
                 OnBuildingExitZone(source, building);
         }
     }
     else
     {
         HashSet<Zone> zones;
         if (otherZones.TryGetValue(entity, out zones))
         {
             foreach (var source in zones.ToArray())
                 OnOtherExitZone(source, entity);
         }
     }
 }