コード例 #1
0
        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]);
                }
            }
        }
コード例 #2
0
ファイル: AutoFuel.cs プロジェクト: mbello2/anatomiarust2.0
 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");
     }
 }
コード例 #3
0
        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);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        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();
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: Timber.cs プロジェクト: welcometopwn/oxideplugins
        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();
            }
        }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 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);
                 }
             }
         }
     }
 }
コード例 #9
0
 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);
             }
         }
     }
 }
コード例 #10
0
    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);
    }
コード例 #11
0
    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);
    }
コード例 #12
0
        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>();
        }
コード例 #13
0
        private void OnEntityKill(BaseNetworkable networkable)
        {
            CarController controller = networkable.GetComponent <CarController>();

            if (controller != null && saveableCars.Contains(controller))
            {
                saveableCars.Remove(controller);
            }
        }
コード例 #14
0
 // 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>());
 }
コード例 #15
0
 void OnEntitySpawned(BaseNetworkable entity)
 {
     if (entity != null)
     {
         if (entity.GetComponent <ReactiveTarget>())
         {
             ModifyTargetStats(entity);
         }
     }
 }
コード例 #16
0
        private void OnEntitySpawned(BaseNetworkable entity)
        {
            WaterWell well = entity.GetComponent <WaterWell>();

            if (!well)
            {
                return;
            }
            SetWellVariables(well);
        }
コード例 #17
0
        private void OnEntitySpawned(BaseNetworkable entity)
        {
            LootableCorpse corpse = entity?.GetComponent <LootableCorpse>();

            if (corpse == null || corpse is NPCPlayerCorpse)
            {
                return;
            }

            TakePlayerItems(corpse);
        }
コード例 #18
0
        private void OnEntityKill(BaseNetworkable networkable)
        {
            Signage signage = networkable.GetComponent <Signage>();

            if (signage != null)
            {
                if (signRegisteredSkulls.ContainsKey(signage))
                {
                    signRegisteredSkulls.Remove(signage);
                }
            }
        }
コード例 #19
0
ファイル: PurifierConfig.cs プロジェクト: saunders-d/RustDev
        void OnEntitySpawned(BaseNetworkable entity)
        {
            if (entity == null || !init || !(entity is WaterPurifier))
            {
                return;
            }
            var purifier = entity?.GetComponent <WaterPurifier>() ?? null;

            if (purifier != null)
            {
                ConfigurePurifier(purifier);
            }
        }
コード例 #20
0
        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>();
            }
        }
コード例 #21
0
        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();
            }
        }
コード例 #22
0
    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);
            }
        }
    }
コード例 #23
0
 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]);
             }
         });
     }
 }
コード例 #24
0
        private void OnEntitySpawned(BaseNetworkable a)
        {
            var entity = a.GetComponent <ElectricBattery>();

            if (entity == null)
            {
                return;
            }

            if (HasPerm(entity.OwnerID.ToString()) || config.all)
            {
                ChangeBattery(entity);
            }
        }
コード例 #25
0
        private void OnEntityKill(BaseNetworkable entity)
        {
            if (!isInitialized)
            {
                return;
            }

            LightController lightController = entity.GetComponent <LightController>();

            if (lightController != null)
            {
                lightControllers.Remove(lightController);
                UnityEngine.Object.DestroyImmediate(lightController);
            }
        }
コード例 #26
0
        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);
            }
        }
コード例 #27
0
 void OnEntitySpawned(BaseNetworkable entity)
 {
     if (initialized)
     {
         if (entity.GetComponent <DroppedItemContainer>())
         {
             NextTick(() =>
             {
                 if (entity != null)
                 {
                     entity.gameObject.AddComponent <BagRotator>();
                 }
             });
         }
     }
 }
コード例 #28
0
        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);
                }
            }
        }
コード例 #29
0
    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>());
    }
コード例 #30
0
// 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);
            }
        }
コード例 #31
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 (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);
 }
コード例 #32
0
ファイル: ZoneManager.cs プロジェクト: mpendel/RUSTBOYS
 /////////////////////////////////////////
 // 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);
 }