public static void EndProjectile(LSProjectile projectile) { if (projectile.Deterministic) { int id = projectile.ID; if (!ProjectileBucket.SafeRemoveAt(id, projectile)) { Debug.Log("BOO! This is a terrible bug."); } } else { if (!NDProjectileBucket.SafeRemoveAt(projectile.ID, projectile)) { Debug.Log("BOO! This is a terrible bug."); } } CacheProjectile(projectile); projectile.Deactivate(); }
public static void LateSimulate() { //2 seconds before turning off int inactiveFrameThreshold = 0; for (int i = 0; i < RanCollisionPairs.PeakCount; i++) { if (RanCollisionPairs.arrayAllocation[i]) { var instancePair = RanCollisionPairs[i]; var pair = RanCollisionPairs[i].Pair; if (instancePair.Version != instancePair.Pair._Version) { RanCollisionPairs.RemoveAt(i); pair._ranIndex = -1; } else { if (pair.LastFrame == LockstepManager.FrameCount) { } else if (pair._ranIndex >= 0) { #if false if (!RanCollisionPairs.SafeRemoveAt(pair._ranIndex, instancePair)) { Debug.Log("Removal Failed"); } #else RanCollisionPairs.RemoveAt(pair._ranIndex); #endif pair._ranIndex = -1; InactiveCollisionPairs.Add(instancePair); } } } } while (InactiveCollisionPairs.Count > 0) { var instancePair = InactiveCollisionPairs.Peek(); var pair = instancePair.Pair; if (instancePair.Version != pair._Version) { InactiveCollisionPairs.Remove(); } else { int dif = LockstepManager.FrameCount - pair.LastFrame; if (dif == 0) { InactiveCollisionPairs.Remove(); } else { if (dif >= inactiveFrameThreshold) { FullDeactivateCollisionPair(pair); InactiveCollisionPairs.Remove(); } else { break; } } } } for (int i = 0; i < DynamicSimObjects.PeakCount; i++) { LSBody b1 = DynamicSimObjects.innerArray[i]; if (b1.IsNotNull()) { b1.Simulate(); } } }