/// <summary>
        /// Tells the collisionsystem to check all bodies for collisions. Hook into the
        /// <see cref="CollisionSystem.PassedBroadphase"/>
        /// and <see cref="CollisionSystem.CollisionDetected"/> events to get the results.
        /// </summary>
        public override void Detect()
        {
            if (addCounter > AddedObjectsBruteForceIsUsed)
            {
                for (int i = 0, length = fullOverlaps.Count; i < length; i++)
                {
                    OverlapPair.Pool.GiveBack(fullOverlaps[i]);
                }
                fullOverlaps.Clear();

                DirtySortAxis(axis1);
                DirtySortAxis(axis2);
                DirtySortAxis(axis3);
            }
            else
            {
                sortCallback(axis1);
                sortCallback(axis2);
                sortCallback(axis3);
            }

            addCounter = 0;
            foreach (OverlapPair key in fullOverlaps)
            {
                if (this.CheckBothStaticNonKinematic(key.Entity1, key.Entity2))
                {
                    continue;
                }

                if (base.RaisePassedBroadphase(key.Entity1, key.Entity2))
                {
                    Detect(key.Entity1, key.Entity2);
                }
            }
        }
Ejemplo n.º 2
0
 public void ClearContentTriggers()
 {
     lock (_triggerContent)
     {
         _triggerContent.Clear();
     }
 }
Ejemplo n.º 3
0
 public void ClearResponses()
 {
     lock (_responses)
     {
         _responses.Clear();
     }
 }
Ejemplo n.º 4
0
 public void ClearCardTriggers()
 {
     lock (_triggerCards)
     {
         _triggerCards.Clear();
     }
 }
Ejemplo n.º 5
0
        public void VersionCheck_Clear()
        {
            var         list       = new HashList <int>();
            IEnumerator enumerator = list.GetEnumerator();

            list.Clear();

            try
            {
                enumerator.MoveNext();
                Assert.Fail("#1");
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                enumerator.Reset();
                Assert.Fail("#2");
            }
            catch (InvalidOperationException)
            {
            }

            enumerator = list.GetEnumerator();
            enumerator.MoveNext();
        }
Ejemplo n.º 6
0
        void ReCreateAlerts()
        {
            foreach (var alert in ActiveItems)
            {
                GOPool.Despawn(alert.gameObject);
            }
            ActiveItems.Clear();
            if (delayCallTask != null)
            {
                BattleCoroutine.Kill(delayCallTask);
            }
            delayCallTask = BattleCoroutine.Run(AddInitAlerts());

            IEnumerator <float> AddInitAlerts()
            {
                if (AlertMgr != null)
                {
                    for (int i = 0; i < AlertMgr.Data.Count; ++i)
                    {
                        if (i >= AlertMgr.Data.Count)
                        {
                            yield break;
                        }
                        yield return(Timing.WaitForSeconds(0.1f));

                        AddAlert(AlertMgr.Data[i]);
                    }
                }
                yield break;
            }
        }
Ejemplo n.º 7
0
        public static void ClearAllCachedAttributes()
        {
            try
            {
                BaseClass = string.Empty;

                ClassName = string.Empty;
                if (HashClassGUID != null)
                {
                    HashClassGUID.Clear();
                }

                if (HashList != null)
                {
                    HashList.Clear();
                }

                if (HashTableBaseClass != null)
                {
                    HashTableBaseClass.Clear();
                }
                if (OMResultedQuery != null)
                {
                    OMResultedQuery.Clear();
                }

                QueryResultToolWindow = null;
                Tab_index             = 0;
                ListofModifiedObjects.Instance.Clear();
            }
            catch (Exception oEx)
            {
                LoggingHelper.ShowMessage(oEx);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Tells the collisionsystem to check all bodies for collisions. Hook into the
        /// <see cref="CollisionSystem.PassedBroadphase"/>
        /// and <see cref="CollisionSystem.CollisionDetected"/> events to get the results.
        /// </summary>
        public override void Detect()
        {
            if (addCounter > AddedObjectsBruteForceIsUsed)
            {
                fullOverlaps.Clear();

                DirtySortAxis(axis1);
                DirtySortAxis(axis2);
                DirtySortAxis(axis3);
            }
            else
            {
                sortCallback(axis1);
                sortCallback(axis2);
                sortCallback(axis3);
            }

            addCounter = 0;
            for (int index = 0, length = fullOverlaps.Count; index < length; index++)
            {
                OverlapPair pair = fullOverlaps[index];
                if (this.CheckBothStaticNonKinematic(pair.Entity1, pair.Entity2))
                {
                    continue;
                }

                if (base.RaisePassedBroadphase(pair.Entity1, pair.Entity2))
                {
                    Detect(pair.Entity1, pair.Entity2);
                }
            }
        }
        private void Rebuild()
        {
            HashList <T> l = new HashList <T>();

            l.AddRange(_items.Where(a => !a.IsDeleted));
            l.AddRange(Secondary.Where(a => !a.IsDeleted));
            Secondary.Clear();
            Populate(l);
            _grow   = 0;
            _degrow = 0;
        }
        /// <summary>
        /// Removes all objects from the world and removes all memory cached objects.
        /// </summary>
        public void Clear()
        {
            // remove bodies from collision system
            for (int index = 0, length = rigidBodies.Count; index < length; index++)
            {
                RigidBody body = rigidBodies[index];

                CollisionSystem.RemoveEntity(body);

                if (body.island != null)
                {
                    body.island.ClearLists();
                    body.island = null;
                }

                body.connections.Clear();
                body.arbiters.Clear();
                body.constraints.Clear();

                events.RaiseRemovedRigidBody(body);
            }

            for (int index = 0, length = softbodies.Count; index < length; index++)
            {
                SoftBody body = softbodies[index];
                CollisionSystem.RemoveEntity(body);
            }

            // remove bodies from the world
            rigidBodies.Clear();

            // remove constraints
            for (int index = 0, length = constraints.Count; index < length; index++)
            {
                Constraint constraint = constraints[index];
                events.RaiseRemovedConstraint(constraint);
            }
            constraints.Clear();

            softbodies.Clear();

            // remove all islands
            islands.RemoveAll();

            // delete the arbiters
            arbiterMap.Clear();
            arbiterTriggerMap.Clear();

            ResetResourcePools();
        }
Ejemplo n.º 11
0
 protected override void OnSetPlayerBase(BaseUnit oldPlayer, BaseUnit newPlayer)
 {
     base.OnSetPlayerBase(oldPlayer, newPlayer);
     if (AlertMgr != null)
     {
         AlertMgr.Callback_OnAdded          -= OnAlertAdded;
         AlertMgr.Callback_OnRemoved        -= OnAlertRemoved;
         AlertMgr.Callback_OnMerge          -= OnAlertMerge;
         AlertMgr.Callback_OnCommingTimeOut -= OnAlertCommingTimeOut;
     }
     AlertMgr = NewAlertMgr;
     AlertMgr.Callback_OnAdded          += OnAlertAdded;
     AlertMgr.Callback_OnRemoved        += OnAlertRemoved;
     AlertMgr.Callback_OnMerge          += OnAlertMerge;
     AlertMgr.Callback_OnCommingTimeOut += OnAlertCommingTimeOut;
     AlertDatasSet.Clear();
     ReCreateAlerts();
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Tells the collisionsystem to check all bodies for collisions. Hook into the
        /// 告诉碰撞系统检查所有碰撞物体。
        /// <see cref="CollisionSystem.PassedBroadphase"/>
        /// and <see cref="CollisionSystem.CollisionDetected"/> events to get the results.
        /// </summary>
        public override void Detect()
        {
            if (addCounter > AddedObjectsBruteForceIsUsed)
            {
                fullOverlaps.Clear();

                DirtySortAxis(axis1);
                DirtySortAxis(axis2);
                DirtySortAxis(axis3);
            }
            else
            {
                sortCallback(axis1);
                sortCallback(axis2);
                sortCallback(axis3);
            }

            addCounter = 0;
            foreach (OverlapPair key in fullOverlaps)
            {
                if (this.CheckBothStaticNonKinematic(key.Entity1, key.Entity2))
                {
                    continue;
                }

                if (base.RaisePassedBroadphase(key.Entity1, key.Entity2))
                {
                    if (swapOrder)
                    {
                        Detect(key.Entity1, key.Entity2);
                    }
                    else
                    {
                        Detect(key.Entity2, key.Entity1);
                    }

                    swapOrder = !swapOrder;
                }
            }
        }
Ejemplo n.º 13
0
        private void Update()
        {
            ScreenLog.SetSticky("Update", update.Count.ToString());
            if (update.Count == 0)
            {
                return;
            }

            foreach (var redraw in update)
            {
                if (chunks.ContainsKey(redraw))
                {
                    continue;
                }
                CreateChunk(redraw);
            }

            foreach (var redraw in update)
            {
                chunks[redraw].UpdateChunk();
            }

            update.Clear();
        }
Ejemplo n.º 14
0
 internal void Clear()
 {
     keysSortedList.Clear();
     dictionaryKeys.Clear();
 }
Ejemplo n.º 15
0
        public void Tick()
        {
            if (changes.Count == 0)
            {
                return;
            }

            tick++;

            // go through all changes made
            foreach (var change in changes)
            {
                // find each change's area
                var area = change / 8;
                List <AreaHistory> steps;

                if (!history.TryGetValue(area, out steps))
                {
                    steps = new List <AreaHistory>();
                    steps.Add(new AreaHistory(tick));
                    history.Add(area, steps);
                }

                // if area doesn't already have a history for this tick: create one
                if (steps[steps.Count - 1].time < tick)
                {
                    // if we have 10 history entries for this area merge the last two together
                    // and reuse one as the new top entry. Else add a new top entry.
                    if (steps.Count >= 10)
                    {
                        var swap = steps[1];
                        steps.RemoveAt(1);
                        steps[0].changes.AddRange(swap.changes);
                        steps[0].time = swap.time;
                        swap.changes.Clear();
                        swap.time = tick;
                        steps.Add(swap);
                    }
                    else
                    {
                        steps.Add(new AreaHistory(tick));
                    }
                }

                // make sure that each change is only represented at ONE history step
                for (int i = 0; i < steps.Count; i++)
                {
                    if (steps[i].changes.Remove(change))
                    {
                        break;
                    }
                }

                // add the change to the top history step
                steps[steps.Count - 1].changes.Add(change);
            }

            changes.Clear();

            for (int i = 0; i < players.Count; i++)
            {
                for (int j = 0; j < Vint3.Offset.Length; j++)
                {
                    var a = players[i].area + Vint3.Offset[j];
                    SendArea(players[i], a);
                }
            }
        }
Ejemplo n.º 16
0
 public virtual void RemoveAll()
 {
     base.Clear();
     HashList.Clear();
 }
Ejemplo n.º 17
0
 public void CleanUp()
 {
     bodies.Clear();
     arbiter.Clear();
     constraints.Clear();
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Calculate the route from start to end.
        /// </summary>
        /// <param name="start">Start.</param>
        /// <param name="end">End.</param>
        public void Route(T start, T end, List <T> route)
        {
            route.Clear();
            if (start == null || end == null)
            {
                return;
            }

            for (int i = 0, nodesLength = nodes.Length; i < nodesLength; i++)
            {
                var s = nodes[i];
                g[s]      = 0f;
                parent[s] = null;
                inPath[s] = false;
            }
            openset.Clear();
            closedset.Clear();
            path.Clear();

            var current = start;

            openset.Add(current);
            while (openset.Count > 0)
            {
                current = openset[0];
                for (var i = 1; i < openset.Count; i++)
                {
                    var d = g[current].CompareTo(g[openset[i]]);
                    if (d < 0)
                    {
                        current = openset[i];
                    }
                }
                //openset.Sort ((a,b) => g [a].CompareTo (g [b]));
                current = openset[0];
                if (current == end)
                {
                    while (parent[current] != null)
                    {
                        path.Enqueue(current);
                        inPath[current] = true;
                        current         = parent[current];
                        if (path.Count >= nodes.Length)
                        {
                            return;
                        }
                    }
                    inPath[current] = true;
                    path.Enqueue(current);
                    while (path.Count > 0)
                    {
                        route.Add(path.Dequeue());
                    }
                    return;
                }
                openset.Remove(current);
                closedset.Add(current);
                var connectedNodes = current.GetConnectedNodes();
                for (int i = 0, connectedNodesCount = connectedNodes.Count; i < connectedNodesCount; i++)
                {
                    var node = connectedNodes[i];
                    if (closedset.Contains(node))
                    {
                        continue;
                    }
                    if (openset.Contains(node))
                    {
                        var new_g = g[current] + current.CalculateMoveCost(node);
                        if (g[node] > new_g)
                        {
                            g[node]      = new_g;
                            parent[node] = current;
                        }
                    }
                    else
                    {
                        g[node]      = g[current] + current.CalculateMoveCost(node);
                        parent[node] = current;
                        openset.Add(node);
                    }
                }
            }
            return;
        }