public static void EndEffect(LSEffect effect)
 {
     if (EffectActive [effect.ID] == false)
     {
         return;
     }
     effect.Deactivate();
     EffectPool [effect.MyEffectCode].Add(effect);
     EffectActive [effect.ID] = false;
     Effects [effect.ID]      = null;
     OpenSlots.Add(effect.ID);
 }
        public static void Pool(MovementGroup group)
        {
            int indexID = group.indexID;

            activeGroups.RemoveAt(indexID);
            pooledGroups.Add(group);
        }
Exemple #3
0
 public static void PoolPair(CollisionPair pair)
 {
     pair.Deactivate();
     if (LockstepManager.PoolingEnabled)
     {
         CachedCollisionPairs.Add(pair);
     }
 }
        private static void Generate()
        {
            #region Pooling; no need to create all those nodes again

            if (Grid != null)
            {
                int min = Grid.Length;
                CachedGridNodes.EnsureCapacity(min);
                for (int i = min - 1; i >= 0; i--)
                {
                    if (LockstepManager.PoolingEnabled)
                    {
                        CachedGridNodes.Add(Grid[i]);
                    }
                }
            }


            if (ScanGrid != null)
            {
                int min = ScanGrid.Length;
                CachedScanNodes.EnsureCapacity(min);
                for (int i = min - 1; i >= 0; i--)
                {
                    if (LockstepManager.PoolingEnabled)
                    {
                        CachedScanNodes.Add(ScanGrid[i]);
                    }
                }
            }
            #endregion

            //long startMem = System.GC.GetTotalMemory (true);
            ScanGrid = new ScanNode[ScanGridSize];
            for (int i = ScanWidth - 1; i >= 0; i--)
            {
                for (int j = ScanHeight - 1; j >= 0; j--)
                {
                    ScanNode node = CachedScanNodes.Count > 0 ? CachedScanNodes.Pop() : new ScanNode();
                    node.Setup(i, j);
                    ScanGrid [GetScanIndex(i, j)] = node;
                }
            }
            Grid = new GridNode[GridSize];
            for (int i = Width - 1; i >= 0; i--)
            {
                for (int j = Height - 1; j >= 0; j--)
                {
                    GridNode node = CachedGridNodes.Count > 0 ? CachedGridNodes.Pop() : new GridNode();
                    node.Setup(i, j);
                    Grid [GetGridIndex(i, j)] = node;
                }
            }
            //long usedMem = System.GC.GetTotalMemory (true) - startMem;
            //Debug.Log ("Grid generated using " + usedMem + " Bytes!");
        }
 public void Deactivate()
 {
     for (i = 0; i < Movers.Count; i++)
     {
         Move mover = Movers [i];
         mover.MyMovementGroup   = null;
         mover.MyMovementGroupID = -1;
     }
     Movers.FastClear();
     ActiveGroups[this.IndexID] = null;
     ActiveGroupOpenSlots.Add(this.IndexID);
     InactiveGroups.Add(this);
     CalculatedBehaviors = false;
     this.IndexID        = -1;
 }
Exemple #6
0
        internal static void Dessimilate(LSBody body)
        {
            int tid = body.ID;

            if (!SimObjects[tid].IsNotNull())
            {
                Debug.LogWarning("Object with ID" + body.ID.ToString() + "cannot be dessimilated because it it not assimilated");
                return;
            }

            SimObjects[tid] = null;
            CachedIDs.Add(tid);


            if (body.DynamicID >= 0)
            {
                DynamicSimObjects.RemoveAt(body.DynamicID);
                body.DynamicID = -1;
            }
        }
        public static void ChangeController(RTSAgent agent, AgentController newCont)
        {
            AgentController leController = agent.Controller;

            if (leController != null)
            {
                leController.LocalAgentActive[agent.LocalID] = false;
                GlobalAgentActive[agent.GlobalID]            = false;
                leController.OpenLocalIDs.Add(agent.LocalID);
                OpenGlobalIDs.Add(agent.GlobalID);

                if (newCont == null)
                {
                    agent.InitializeController(null, 0, 0);
                }
                else
                {
                    agent.Influencer.Deactivate();

                    newCont.AddAgent(agent);
                    agent.Influencer.Initialize();
                }
            }
        }