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; } } }); }
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; }
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; }
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; } } }); }
public void ForceEndExclusion() { var token = new PairToken(_collA, _collB); if (token.IsDead) { _table.Remove(token); return; } if (_table.Remove(token)) { _collA.IgnoreCollision(_collB, false); } }