public Edge(CrystalBombDetonator parent, Vector2 a, Vector2 b) { Parent = parent; A = a; B = b; Min = new Vector2(Math.Min(A.X, B.X), Math.Min(A.Y, B.Y)); Max = new Vector2(Math.Max(A.X, B.X), Math.Max(A.Y, B.Y)); Normal = (B - A).SafeNormalize(); Perpendicular = -Normal.Perpendicular(); Length = (A - B).Length(); }
// Add a field to the tracker public void Track(CrystalBombDetonator block) { trackedFields.Add(block); if (tiles == null) { levelTileBounds = (Scene as Level).TileBounds; tiles = new VirtualMap <bool>(levelTileBounds.Width, levelTileBounds.Height, false); } for (int xTile = (int)block.X / 8; xTile < (block.Right / 8f); xTile++) { for (int yTile = (int)block.Y / 8; yTile < (block.Bottom / 8f); yTile++) { tiles[xTile - levelTileBounds.X, yTile - levelTileBounds.Y] = true; } } dirty = true; }
public void Untrack(CrystalBombDetonator block) { trackedFields.Remove(block); if (trackedFields.Count <= 0) { tiles = null; } else { for (int xTile = (int)block.X / 8; xTile < (block.Right / 8f); xTile++) { for (int yTile = (int)block.Y / 8; yTile < (block.Bottom / 8f); yTile++) { tiles[xTile - levelTileBounds.X, yTile - levelTileBounds.Y] = false; } } } dirty = true; }