public static void Assimilate(LSBody body) { if (CachedIDs.Count > 0) { id = CachedIDs.Pop(); } else { id = PeakCount; PeakCount++; } SimObjectExists [id] = true; SimObjects [id] = body; body.ID = id; for (i = 0; i < id; i++) { other = SimObjects [i]; if (!Physics2D.GetIgnoreLayerCollision(other.cachedGameObject.layer, body.cachedGameObject.layer)) { colPairIndex = i * MaxSimObjects + id; pair = CollisionPairs[colPairIndex]; if (pair == null) { pair = new CollisionPair(); CollisionPairs [colPairIndex] = pair; } FastCollisionPairs.Add(pair); pair.Initialize(other, body); CollisionPairCount++; } } for (j = id + 1; j < PeakCount; j++) { other = SimObjects [j]; if (!Physics2D.GetIgnoreLayerCollision(other.cachedGameObject.layer, body.cachedGameObject.layer)) { colPairIndex = id * MaxSimObjects + j; pair = CollisionPairs[colPairIndex]; if (pair == null) { pair = new CollisionPair(); CollisionPairs [colPairIndex] = pair; } FastCollisionPairs.Add(pair); pair.Initialize(body, other); CollisionPairCount++; } } AssimilatedCount++; }
private static CollisionPair CreatePair(LSBody body1, LSBody body2) { int pairIndex = GetCollisionPairIndex(body1.ID, body2.ID); CollisionPair pair = new CollisionPair(); CollisionPairs[pairIndex] = pair; pair.Initialize(body1, body2); return(pair); }
private static void CreatePair(LSBody body1, LSBody body2, int pairIndex) { pair = CollisionPairs [pairIndex]; if (pair == null) { pair = new CollisionPair(); CollisionPairs [pairIndex] = pair; } FastCollisionPairs.Add(pair); pair.Initialize(body1, body2); }