private void SpreadEnvironment(Point position, IAreaMapCellInternal cell, CellPairsStorage mergedCells) { TrySpreadEnvironment(position, Direction.North, cell, mergedCells); TrySpreadEnvironment(position, Direction.South, cell, mergedCells); TrySpreadEnvironment(position, Direction.West, cell, mergedCells); TrySpreadEnvironment(position, Direction.East, cell, mergedCells); }
private void MergeCellEnvironment(Point position, IAreaMapCellInternal cell, CellPairsStorage mergedCells) { if (cell.BlocksEnvironment) { return; } SpreadEnvironment(position, cell, mergedCells); }
private void PostUpdateCells() { var mergedCells = new CellPairsStorage(Width, Height); for (var y = 0; y < cells.Length; y++) { for (var x = 0; x < cells[y].Length; x++) { var position = new Point(x, y); var cell = GetOriginalCell(x, y); cell.Environment.Update(position, cell); MergeCellEnvironment(position, cell, mergedCells); cell.PostUpdate(this, position); cell.ResetDynamicObjectsState(); } } }
private void TrySpreadEnvironment(Point position, Direction direction, IAreaMapCellInternal cell, CellPairsStorage mergedCells) { var nextPosition = Point.GetPointInDirection(position, direction); if (!ContainsCell(nextPosition)) { return; } var nextCell = GetOriginalCell(nextPosition.X, nextPosition.Y); if (mergedCells.ContainsPair(position, direction)) { return; } mergedCells.RegisterPair(position, direction); if (nextCell.BlocksEnvironment) { return; } cell.CheckSpreading(nextCell); cell.Environment.Balance(cell, nextCell); }