/// <summary> /// CollisionSkin moved /// </summary> /// <param name="skin"></param> public override void CollisionSkinMoved(CollisionSkin skin) { GridEntry entry = (GridEntry)skin.ExternalData; if (entry == null) { System.Diagnostics.Debug.WriteLine("Warning skin has grid entry null!"); return; } int gridIndex = CalcGridIndexForSkin(skin); // see if it's moved grid if (gridIndex == entry.GridIndex) { return; } GridEntry start; if (gridIndex >= 0) { start = gridEntries[gridIndex]; } else { start = overflowEntries; } GridEntry.RemoveGridEntry(entry); GridEntry.InsertGridEntryAfter(entry, start); }
/// <summary> /// Adds a CollisionSkin /// </summary> /// <param name="skin"></param> public override void AddCollisionSkin(CollisionSkin skin) { if (skins.Contains(skin)) { System.Diagnostics.Debug.WriteLine("Warning: tried to add skin to CollisionSkinGrid but it's already registered"); } else { skins.Add(skin); } skin.CollisionSystem = this; if (freeGrids.Count == 0) { freeGrids.Push(new GridEntry()); } // also do the grid stuff - for now put it on the overflow list GridEntry entry = freeGrids.Pop(); skin.ExternalData = entry; entry.Skin = skin; // add entry to the start of the list GridEntry.InsertGridEntryAfter(entry, overflowEntries); CollisionSkinMoved(skin); }