Beispiel #1
0
        private static void PurgeWhenCan(Collider a, Collider b)
        {
            GameLoopEntry.UpdatePump.BeginInvoke(() =>
            {
                var token = new PairToken(a, b);
                if (token.IsDead)
                {
                    _table.Remove(token);
                    return;
                }

                int cnt;
                if (_table.TryGetValue(token, out cnt))
                {
                    cnt--;
                    if (cnt <= 0)
                    {
                        Physics.IgnoreCollision(token.CollA, token.CollB, false);
                        _table.Remove(token);
                    }
                    else
                    {
                        _table[token] = cnt;
                    }
                }
            });
        }
Beispiel #2
0
        public void EndExclusion()
        {
            var token = new PairToken(_collA, _collB);

            if (token.IsDead)
            {
                _table.Remove(token);
                return;
            }
            if (!_active)
            {
                return;
            }

            int cnt;

            if (_table.TryGetValue(token, out cnt))
            {
                cnt--;
                if (cnt <= 0)
                {
                    Physics.IgnoreCollision(_collA, _collB, false);
                    _table.Remove(token);
                }
                else
                {
                    _table[token] = cnt;
                }
            }
            _active = false;
        }
Beispiel #3
0
        public void BeginExclusion()
        {
            if (_active)
            {
                return;
            }
            if (_collA == null || _collB == null)
            {
                throw new System.InvalidOperationException("One or more referenced collider is null or destroyed.");
            }

            var token = new PairToken(_collA, _collB);
            int cnt;

            if (_table.TryGetValue(token, out cnt))
            {
                _table[token] = cnt + 1;
            }
            else
            {
                Physics.IgnoreCollision(_collA, _collB, true);
                _table[token] = 1;
            }
            _active = true;
        }
Beispiel #4
0
        private static void PurgeWhenCan(IIgnorableCollision a, IIgnorableCollision b)
        {
            GameLoopEntry.UpdateHandle.BeginInvoke(() =>
            {
                var token = new PairToken(a, b);
                if (token.IsDead)
                {
                    _table.Remove(token);
                    return;
                }

                int cnt;
                if (_table.TryGetValue(token, out cnt))
                {
                    cnt--;
                    if (cnt <= 0)
                    {
                        a.IgnoreCollision(b, false);
                        _table.Remove(token);
                    }
                    else
                    {
                        _table[token] = cnt;
                    }
                }
            });
        }
Beispiel #5
0
        public void ForceEndExclusion()
        {
            var token = new PairToken(_collA, _collB);

            if (token.IsDead)
            {
                _table.Remove(token);
                return;
            }

            if (_table.Remove(token))
            {
                _collA.IgnoreCollision(_collB, false);
            }
        }