Esempio n. 1
0
        void OnEntitySpawned(BaseNetworkable entity)
        {
            if (!init)
            {
                return;
            }
            if (entity?.net?.ID == null)
            {
                return;
            }
            if (IsDecayEntity(entity) && !decayEntities.Contains((BaseCombatEntity)entity))
            {
                decayEntities.Add((BaseCombatEntity)entity);
            }
            BuildingPrivlidge privlidge = entity as BuildingPrivlidge;

            if (privlidge != null)
            {
                cupboards.Add(privlidge.net.ID);
            }
            NextTick(() =>
            {
                DecayEntity decEnt = entity as DecayEntity;
                if (decEnt != null)
                {
                    decEnt.CancelInvoke("RunDecay");
                }
            });
        }
Esempio n. 2
0
        void InitDecayEntities()
        {
            var ents = UnityEngine.Object.FindObjectsOfType <BaseCombatEntity>();

            decayEntities = new List <BaseCombatEntity>(ents.Length);

            Parallel.For(0, ents.Length, (i) =>
            {
                var ent = ents[i];
                if (ent == null)
                {
                    return;
                }
                DecayEntity decEnt = ent as DecayEntity;
                NextTick(() =>
                {
                    if (decEnt != null)
                    {
                        decEnt.CancelInvoke("RunDecay");
                    }
                    if (IsDecayEntity(ent))
                    {
                        decayEntities.Add(ent);
                    }
                });
            });
            Puts($"Загрузка объектов прошла успешно! Count: {ents.Length}");
            init = true;
        }