Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,78 +174,78 @@ protected override void CheckColliders(uint localTick)

current.Add(hit);
}
}

/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider> enteredColliders))
{
CollectionCaches<Collider>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}
/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider> enteredColliders))
{
CollectionCaches<Collider>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}

const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;
const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;

_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider> lastEnteredColliders);
_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider> lastEnteredColliders);

/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;
/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;

/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
//Invoke OnEnter for every collider in current.
foreach (Collider c in current)
InvokeOnEnter(c, localTick);
}
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
foreach (Collider c in current)
{
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
InvokeOnEnter(c, localTick);
}
}
/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
//Invoke OnEnter for every collider in current.
foreach (Collider c in current)
InvokeOnEnter(c, localTick);
}
//If current is empty the collection can be stored.
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
CollectionCaches<Collider>.Store(current);
foreach (Collider c in current)
{
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
InvokeOnEnter(c, localTick);
}
}
}
//If current is empty the collection can be stored.
else
{
CollectionCaches<Collider>.Store(current);
}

/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
{
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider c in lastEnteredColliders)
{
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider c in lastEnteredColliders)
{
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
}

/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
{
if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider> lEnteredColliders))
{
if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider> lEnteredColliders))
{
CollectionCaches<Collider>.Store(lEnteredColliders);
_enteredColliders.Remove(lastTick);
}
CollectionCaches<Collider>.Store(lEnteredColliders);
_enteredColliders.Remove(lastTick);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,78 +172,78 @@ protected override void CheckColliders(uint localTick)

current.Add(hit);
}
}

/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider2D> enteredColliders))
{
CollectionCaches<Collider2D>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}
/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider2D> enteredColliders))
{
CollectionCaches<Collider2D>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}

const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;
const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;

_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lastEnteredColliders);
_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lastEnteredColliders);

/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;
/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;

/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
//Invoke OnEnter for every collider in current.
foreach (Collider2D c in current)
InvokeOnEnter(c, localTick);
}
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
foreach (Collider2D c in current)
{
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
InvokeOnEnter(c, localTick);
}
}
/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
//Invoke OnEnter for every collider in current.
foreach (Collider2D c in current)
InvokeOnEnter(c, localTick);
}
//If current is empty the collection can be stored.
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
CollectionCaches<Collider2D>.Store(current);
foreach (Collider2D c in current)
{
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
InvokeOnEnter(c, localTick);
}
}
}
//If current is empty the collection can be stored.
else
{
CollectionCaches<Collider2D>.Store(current);
}

/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
{
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider2D c in lastEnteredColliders)
{
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider2D c in lastEnteredColliders)
{
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
}

/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
{
if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lEnteredColliders))
{
if (lastTick is not unsetLastTick && _enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lEnteredColliders))
{
CollectionCaches<Collider2D>.Store(lEnteredColliders);
_enteredColliders.Remove(lastTick);
}
CollectionCaches<Collider2D>.Store(lEnteredColliders);
_enteredColliders.Remove(lastTick);
}
}
}
Expand Down