public void PerformAction(IGridAsset participant, Point point) { cooldown = 2.0f; action(participant, point); }
public CollisionHandler(IGridAsset act, CollisionEventHandler a) { actuator = act; action = a; }
private void CoarseGridFill(IGridAsset ent, IGridAssetCongolmerate conglomerate = null) { IGridAsset toFillGrid = ent; if (conglomerate != null) toFillGrid = conglomerate; for (int i = (int)(ent.boundry.Left / gridSize.X); i <= (int)(ent.boundry.Right / gridSize.X); i++) { for (int j = (int)(ent.boundry.Top / gridSize.Y); j <= (int)(ent.boundry.Bottom / gridSize.Y); j++) { Point gridPos = new Point(i, j); if (GridPosValid(gridPos)) { if (!grid[gridPos.X, gridPos.Y].inhabitants.Contains(toFillGrid)) { toFillGrid.gridPositions.Add(gridPos); grid[gridPos.X, gridPos.Y].inhabitants.Add(toFillGrid); if (grid[gridPos.X, gridPos.Y].inhabitants.Count > 1) HandleCollision(grid[gridPos.X, gridPos.Y].inhabitants,gridPos); } } } } }
public void UpdateGridInfo(IGridAsset ent) { if (!enabled) return; Remove(ent); Add(ent); }
public void Remove(IGridAsset ent) { if (!enabled || ent.gridPositions == null) return; foreach (Point gridPos in ent.gridPositions) { if (gridPos.X < width && gridPos.Y < height) grid[gridPos.X, gridPos.Y].inhabitants.Remove(ent); } ent.gridPositions.Clear(); }
public void Add(IGridAsset ent) { if (!enabled) return; CoarseGridFill(ent); }