private void OnEntityKill(BaseNetworkable entity) { var baseEnt = entity as BaseEntity; if (baseEnt == null) { return; } if (wipeList.Contains(baseEnt)) { return; } if (entity.GetComponent <LootContainer>()) { if (boxCache.ContainsKey(baseEnt)) { InitiateRefresh(baseEnt, boxCache[baseEnt]); } } else if (entity.GetComponent <StorageContainer>()) { if (boxCache.ContainsKey(baseEnt)) { InitiateRefresh(baseEnt, boxCache[baseEnt]); } } }
private void OnEntitySpawned(BaseNetworkable entity) { if (entity.GetComponent <BaseEntity>()?.ShortPrefabName == "jackolantern.angry" || entity.GetComponent <BaseEntity>()?.ShortPrefabName == "jackolantern.happy") { entity.GetComponent <BaseOven>().fuelType = ItemManager.FindItemDefinition("wood"); } }
void OnEntitySpawned(BaseNetworkable entity) { if (Loaded) { for (int i = 0; i < configData.deployables.Count; i++) { if (entity.ShortPrefabName.Contains(configData.deployables[i])) { var ownerID = entity.GetComponent <BaseEntity>().OwnerID; if (ownerID != 0) { BasePlayer player = BasePlayer.FindByID(ownerID); if (player == null || player.IsAdmin()) { return; } if (!HasPriv(player)) { Item item; if (entity.ShortPrefabName.Contains("landmine")) { entity.KillMessage(); item = ItemManager.CreateByPartialName("trap.landmine"); } else if (entity.ShortPrefabName.Contains("bear")) { entity.GetComponent <BaseCombatEntity>().DieInstantly(); item = ItemManager.CreateByPartialName("trap.bear"); } else { entity.GetComponent <BaseCombatEntity>().DieInstantly(); item = ItemManager.CreateByPartialName(configData.deployables[i]); var deployable = item.info.GetComponent <ItemModDeployable>(); if (deployable != null) { var oven = deployable.entityPrefab.Get()?.GetComponent <BaseOven>(); if (oven != null) { oven.startupContents = null; } } } if (!pendingItems.ContainsKey(player.userID)) { pendingItems.Add(player.userID, new PendingItem()); } pendingItems[player.userID].item = item; CheckForDuplicate(player); } } } } } }
private void OnEntitySpawned(BaseNetworkable entity) { if (isInitialized) { if (configData.deployables.Contains(entity.ShortPrefabName) || configData.deployables.Contains(entity.PrefabName)) { var ownerID = entity.GetComponent <BaseEntity>().OwnerID; if (ownerID != 0) { BasePlayer player = BasePlayer.FindByID(ownerID); if (player == null || player.IsAdmin || IsInPrivilege(player)) { return; } List <ItemAmount> items = new List <ItemAmount>(); if (entity is BuildingBlock && constructionToIngredients.ContainsKey(entity.PrefabName)) { foreach (var ingredient in constructionToIngredients[entity.PrefabName]) { items.Add(ingredient); } } else if (prefabToItem.ContainsKey(entity.PrefabName)) { items.Add(new ItemAmount { amount = 1, startAmount = 1, itemDef = ItemManager.FindItemDefinition(prefabToItem[entity.PrefabName]) }); } if (!pendingItems.ContainsKey(player.userID)) { pendingItems.Add(player.userID, new PendingItem()); } pendingItems[player.userID].items = items; CheckForDuplicate(player); StorageContainer container = entity.GetComponent <StorageContainer>(); if (container != null) { container.inventory.Clear(); } if (entity is BaseTrap || !(entity is BaseCombatEntity)) { entity.Kill(); } else { (entity as BaseCombatEntity).DieInstantly(); } } } } }
private void OnEntityKill(BaseNetworkable entity) { bool fallDefined = entity.GetComponent <FallControl>() != null; bool despawnDefined = entity.GetComponent <DespawnControl>() != null; var entityPosition = entity.transform.position; var entityRotation = entity.transform.rotation; // Creates the fall behaviour if none is defined. if (!fallDefined && !despawnDefined) { if (entity is TreeEntity || (configs.options.includeCacti && StringPool.Get(entity.prefabID).Contains("cactus"))) { Effect.server.Run(despawnPrefab, entityPosition); if (configs.options.logToPlayer) { foreach (var player in BasePlayer.activePlayerList) { float distance = Vector3.Distance(player.transform.position, entityPosition); if (distance < maxFirstDistance) { if (!storedData.loggedTo.Contains(player.UserIDString)) { MessagePlayer(Lang("TIMBER_FIRST", player), player); storedData.loggedTo.Add(player.UserIDString); } } } } var newFalling = GameManager.server.CreateEntity(StringPool.Get(entity.prefabID), entityPosition, entityRotation, true); var controlFall = newFalling.gameObject.AddComponent <FallControl>(); controlFall.Load(newFalling, configs.options.despawnLength, configs.options.screamPercent); newFalling.Spawn(); } } // Creates the despawn behaviour if fall is defined. else if (fallDefined && !despawnDefined) { Effect.server.Run(soundDespawnPrefab, entityPosition); // TODO: Effects down length of fallen tree. Effect.server.Run(despawnPrefab, entityPosition); var newFalling = GameManager.server.CreateEntity(StringPool.Get(entity.prefabID), entityPosition, entityRotation, true); var controlDespawn = newFalling.gameObject.AddComponent <DespawnControl>(); controlDespawn.Load(newFalling); newFalling.Spawn(); } }
void OnEntitySpawned(BaseNetworkable entity) { if (entity.GetComponent("BaseCorpse")) { BaseCorpse corpse = entity as BaseCorpse; corpse.RemoveCorpse(); } if (entity.GetComponent("BaseNPC")) { BaseNPC npc = entity as BaseNPC; npc.Kill(); } }
private void OnEntitySpawned(BaseNetworkable networkObject) { ElectricBattery battery = networkObject.GetComponent <ElectricBattery>(); if (battery != null) { AdjustBattery(battery); } SolarPanel panel = networkObject.GetComponent <SolarPanel>(); if (panel != null) { AdjustSolarPanel(panel); } }
void OnEntitySpawned(BaseNetworkable entity) { if (entity is BaseCorpse) { var corpse = entity.GetComponent <LootableCorpse>(); if (corpse != null) { if (corpse.playerSteamID != 0) { if (GetPercentage(corpse.playerSteamID) == 100) { return; } SaveInventory(corpse.playerSteamID); var loot = corpse.GetComponent <LootableCorpse>().containers; if (loot != null) { ProcessItems(corpse.GetComponent <LootableCorpse>(), 0); ProcessItems(corpse.GetComponent <LootableCorpse>(), 1); ProcessItems(corpse.GetComponent <LootableCorpse>(), 2); } } } } }
void OnEntitySpawned(BaseNetworkable entity) { if (entity is BaseOven) { if (entity.ShortPrefabName == "jackolantern.happy" || entity.ShortPrefabName == "jackolantern.angry") { var jack = entity.GetComponent <BaseOven>(); if (craftedBombs.Contains(jack.OwnerID)) { jack.gameObject.AddComponent <BombLight>(); var expEnt = GameManager.server.CreateEntity("assets/prefabs/tools/c4/explosive.timed.deployed.prefab", jack.transform.position, new Quaternion(), true); TimedExplosive explosive = expEnt.GetComponent <TimedExplosive>(); explosive.timerAmountMax = configData.ExplosiveSettings.DetonationTimer; explosive.timerAmountMin = configData.ExplosiveSettings.DetonationTimer; explosive.explosionRadius = configData.ExplosiveSettings.ExplosionRadius; explosive.damageTypes = new List <Rust.DamageTypeEntry> { new Rust.DamageTypeEntry { amount = configData.ExplosiveSettings.DamageAmount, type = Rust.DamageType.Explosion } }; explosive.Spawn(); craftedBombs.Remove(jack.OwnerID); } } } }
public void TryClear(BaseEntity.RPCMessage msg) { IOEntity component; if (!WireTool.CanPlayerUseWires(msg.player)) { return; } uint num = msg.read.UInt32(); BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num); if (baseNetworkable == null) { component = null; } else { component = baseNetworkable.GetComponent <IOEntity>(); } IOEntity oEntity = component; if (oEntity == null) { return; } oEntity.ClearConnections(); oEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); }
public void RequestClear(BaseEntity.RPCMessage msg) { IOEntity component; IOEntity.IOSlot oSlot; if (!WireTool.CanPlayerUseWires(msg.player)) { return; } uint num = msg.read.UInt32(); int num1 = msg.read.Int32(); bool flag = msg.read.Bit(); BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(num); if (baseNetworkable == null) { component = null; } else { component = baseNetworkable.GetComponent <IOEntity>(); } IOEntity oEntity = component; if (oEntity == null) { return; } if (num1 >= (flag ? (int)oEntity.inputs.Length : (int)oEntity.outputs.Length)) { return; } IOEntity.IOSlot oSlot1 = (flag ? oEntity.inputs[num1] : oEntity.outputs[num1]); if (oSlot1.connectedTo.Get(true) == null) { return; } IOEntity oEntity1 = oSlot1.connectedTo.Get(true); oSlot = (flag ? oEntity1.outputs[oSlot1.connectedToSlot] : oEntity1.inputs[oSlot1.connectedToSlot]); if (flag) { oEntity.UpdateFromInput(0, num1); } else if (oEntity1) { oEntity1.UpdateFromInput(0, oSlot1.connectedToSlot); } oSlot1.Clear(); oSlot.Clear(); if (oEntity1) { oEntity1.MarkDirtyForceUpdateOutputs(); oEntity1.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); } oEntity.MarkDirtyForceUpdateOutputs(); oEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); }
private void AddLogic(BaseNetworkable entity) { var npc = entity.GetComponent <BaseNpc>(); if (npc == null) { return; } if (config.blocked.Contains(entity.ShortPrefabName)) { return; } if (entity.GetComponent <OLogic>() != null) { return; } entity.gameObject.AddComponent <OLogic>(); }
private void OnEntityKill(BaseNetworkable networkable) { CarController controller = networkable.GetComponent <CarController>(); if (controller != null && saveableCars.Contains(controller)) { saveableCars.Remove(controller); } }
// find storage container from parent and child id private static StorageContainer GetChildContainer(BaseNetworkable parent, uint id = 0) { if (id != 0) { BaseResourceExtractor ext = parent?.GetComponent <BaseResourceExtractor>(); if (ext != null) { foreach (var c in ext.children) { if (c is ResourceExtractorFuelStorage && c.GetComponent <ResourceExtractorFuelStorage>().panelName == ((id == 2) ? "fuelstorage" : "generic")) { return(c.GetComponent <StorageContainer>()); } } } //return parent.GetComponent<StorageContainer>(); } return(parent?.GetComponent <StorageContainer>()); }
void OnEntitySpawned(BaseNetworkable entity) { if (entity != null) { if (entity.GetComponent <ReactiveTarget>()) { ModifyTargetStats(entity); } } }
private void OnEntitySpawned(BaseNetworkable entity) { WaterWell well = entity.GetComponent <WaterWell>(); if (!well) { return; } SetWellVariables(well); }
private void OnEntitySpawned(BaseNetworkable entity) { LootableCorpse corpse = entity?.GetComponent <LootableCorpse>(); if (corpse == null || corpse is NPCPlayerCorpse) { return; } TakePlayerItems(corpse); }
private void OnEntityKill(BaseNetworkable networkable) { Signage signage = networkable.GetComponent <Signage>(); if (signage != null) { if (signRegisteredSkulls.ContainsKey(signage)) { signRegisteredSkulls.Remove(signage); } } }
void OnEntitySpawned(BaseNetworkable entity) { if (entity == null || !init || !(entity is WaterPurifier)) { return; } var purifier = entity?.GetComponent <WaterPurifier>() ?? null; if (purifier != null) { ConfigurePurifier(purifier); } }
private void OnEntitySpawned(BaseNetworkable entity) { if (entity.GetComponent <BaseEntity>()?.ShortPrefabName == "jackolantern.angry" || entity.GetComponent <BaseEntity>()?.ShortPrefabName == "jackolantern.happy") { entity.GetComponent <BaseOven>().fuelType = ItemManager.FindItemDefinition("wood"); } BaseOven oven = entity.GetComponent <BaseOven>(); if (!oven) { return; } if (!activeShortNames.Contains(oven.ShortPrefabName)) { return; } if (!oven.GetComponent <AutomaticRefuel>()) { oven.gameObject.AddComponent <AutomaticRefuel>(); } }
void OnEntitySpawned(BaseNetworkable entity) { if (!init || entity == null || !(entity is PlayerCorpse)) { return; } var corpse = entity.GetComponent <PlayerCorpse>(); if (corpse.playerSteamID == phantomId && !corpse.IsDestroyed) { corpse.Kill(); } }
public void ForceAddBookmark(string identifier) { if (controlBookmarks.Count >= 128 || !IsValidIdentifier(identifier)) { return; } foreach (KeyValuePair <string, uint> controlBookmark in controlBookmarks) { if (controlBookmark.Key == identifier) { return; } } uint num = 0u; bool flag = false; foreach (IRemoteControllable allControllable in RemoteControlEntity.allControllables) { if (allControllable != null && allControllable.GetIdentifier() == identifier) { 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) { string identifier2 = component.GetIdentifier(); if (identifier == identifier2) { controlBookmarks.Add(identifier, num); } } }
void MethodThatPutsLootIntoCorpse(BaseNetworkable entity) { if (entity != null) { Item ammo = ItemManager.CreateByItemID(ammoType, Random.Range(0, 60)); PlayerCorpse corpse = entity.GetComponent <PlayerCorpse>(); NextTick(() => { if (ammo != null && corpse != null) { ammo.MoveToContainer(corpse.containers[0]); } }); } }
private void OnEntitySpawned(BaseNetworkable a) { var entity = a.GetComponent <ElectricBattery>(); if (entity == null) { return; } if (HasPerm(entity.OwnerID.ToString()) || config.all) { ChangeBattery(entity); } }
private void OnEntityKill(BaseNetworkable entity) { if (!isInitialized) { return; } LightController lightController = entity.GetComponent <LightController>(); if (lightController != null) { lightControllers.Remove(lightController); UnityEngine.Object.DestroyImmediate(lightController); } }
private void AddProtection(BaseNetworkable entity) { var ent = entity.GetComponent <BaseCombatEntity>(); if (ent == null) { return; } var value = ent.GetBuildingPrivilege() == null ? protection1 : protection2; if (ent.baseProtection.Get(DamageType.Decay) != value) { ent.baseProtection.Add(DamageType.Decay, value); } }
void OnEntitySpawned(BaseNetworkable entity) { if (initialized) { if (entity.GetComponent <DroppedItemContainer>()) { NextTick(() => { if (entity != null) { entity.gameObject.AddComponent <BagRotator>(); } }); } } }
void OnEntitySpawned(BaseNetworkable entity) { ElectricGenerator generator = entity.GetComponent <ElectricGenerator>(); if (generator != null) { if (debug) { Puts($"ELECTRIC GENERATOR SPAWN !"); } bool istweaker = permission.UserHasPermission(generator.OwnerID.ToString(), Tweaker); if (ElectricGeneratorWorld || istweaker) { ElectricGeneratorTweakerizer(generator); } } }
public PagerEntity GetPagerEnt(Item item, bool isServer = true) { BaseNetworkable baseNetworkable = null; if (item.instanceData == null) { return(null); } if (isServer) { baseNetworkable = BaseNetworkable.serverEntities.Find(item.instanceData.subEntity); } if (!baseNetworkable) { return(null); } return(baseNetworkable.GetComponent <PagerEntity>()); }
// FOR FUTURE USE /*List<SolarPanel> SolarPanelSpawned = new List<SolarPanel>(); * void OnServerInitialized() * { * timer.Every(10f, () => * { * insidetimerstuff(); * }); * }*/ void OnEntitySpawned(BaseNetworkable entity) { SolarPanel solarpanel = entity.GetComponent <SolarPanel>(); if (solarpanel != null) { if (debug) { Puts($"SOLAR PANEL SPAWN !"); } bool istweaker = permission.UserHasPermission(solarpanel.OwnerID.ToString(), Tweaker); if (SolarWorld || istweaker) { SolarPanelTweakerizer(solarpanel); } //SolarPanelSpawned.Add(solarpanel); } }
///////////////////////////////////////// // 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); }
///////////////////////////////////////// // 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); }