private NativeArray <Data.Node> GetNodes() { NativeArray <Data.Node> nativeNodeArray = new NativeArray <Data.Node>(Info.Map.Area, Allocator.TempJob); for (int x = -Info.Map.Size; x <= Info.Map.Size; x++) { for (int y = -Info.Map.Size; y <= Info.Map.Size; y++) { Data.Cell cell = mapSystem.GetCell(x, y); Data.Node node = new Data.Node { Index = cell.Index, PreviousIndex = -1, FCost = int.MaxValue, GCost = int.MaxValue, HCost = int.MaxValue, Position = cell.Position, Solid = cell.Solid, }; nativeNodeArray[node.Index] = node; } } return(nativeNodeArray); }
private void Start() { for (int i = 0; i < Info.Entity.NumberOfSeedColonists; i++) { Data.Cell cellData = mapSystem.GetFreeCell(); GenerateColonist(cellData.Position); } }
public void SetCellSolid(int2 position, bool solid = true) { if (Util.Map.OnMap(position)) { Data.Cell cellData = GetCell(position); cellData.Solid = solid; SetCell(position, cellData); } }
public void SetupOverlay(int2 position, Type.Overlay overlayType) { if (Util.Map.OnMap(position)) { Data.Cell cell = GetCell(position); cell.OverlayType = overlayType; SetCell(position, cell); } }
public void SetupGround(int2 position, Type.Ground groundType) { if (Util.Map.OnMap(position)) { Data.Cell cellData = GetCell(position); cellData.GroundType = groundType; SetCell(position, cellData); } }
public Data.Cell GetFreeCell() { Data.Cell cellData = GetCell(Util.Map.GetRandomMapPosition()); while (cellData.Solid) { cellData = GetCell(Util.Map.GetRandomMapPosition()); } return(cellData); }
public void SetupStructure(int2 position, Type.Structure structureType, bool solid = true) { if (Util.Map.OnMap(position)) { Data.Cell cellData = GetCell(position); cellData.Solid = solid; cellData.StructureType = structureType; SetCell(position, cellData); } }
private void SetupCells() { selectedCell = new int2(); for (int i = 0; i < Info.Map.Area; i++) { Data.Cell cellData = cells[i]; cellData.Index = i; cellData.Position = Util.Map.IndexToPosition(i); cells[i] = cellData; } }
public List <bool> GetSolidData() { List <bool> solidData = new List <bool>(cells.Count); for (int i = 0; i < cells.Count; i++) { Data.Cell cellData = cells[i]; solidData.Add(cellData.Solid); } return(solidData); }
public List <int> GetEdgeData() { if (!edgesValid) { ResetEdges(); for (int x = -Info.Map.Size + 2; x <= Info.Map.Size - 2; x++) { for (int y = -Info.Map.Size + 2; y <= Info.Map.Size - 2; y++) { Data.Cell currentCell = GetCell(x, y); if (currentCell.Solid) { continue; } foreach (KeyValuePair <Type.Direction, int2> keyValuePair in MapSystem.Directions) { Type.Direction neighborDirection = keyValuePair.Key; int2 neighborOffset = keyValuePair.Value; int2 neighborPosition = currentCell.Position + neighborOffset; if (Util.Map.OnMap(neighborPosition)) { Data.Cell neighborCell = GetCell(neighborPosition); if (neighborCell.Solid) { continue; } if (ValidEdge(neighborCell, neighborDirection)) { int currentCellIndex = Util.Map.PositionToIndex(currentCell.Position); int neighborCellIndex = Util.Map.PositionToIndex(neighborCell.Position); edges[currentCellIndex + Info.Map.Area * neighborCellIndex] = 1; edges[neighborCellIndex + Info.Map.Area * currentCellIndex] = 1; } } } } } edgesValid = true; } return(edges); }
public void SelectCell(int2 cellPosition) { if (uiData.Mode == Type.UIMode.Main) { return; } ClearSelection(); mapSystem.ClearSelection(); mapSystem.SelectCell(cellPosition); Data.Cell cellData = mapSystem.GetCell(cellPosition); infoWindow.ActivateCellMode(cellData); }
private bool ValidEdge(Data.Cell neighborCell, Type.Direction neighborDirection) { int2 northPosition = neighborCell.Position + MapSystem.Directions[Type.Direction.NN]; int2 eastPosition = neighborCell.Position + MapSystem.Directions[Type.Direction.EE]; int2 southPosition = neighborCell.Position + MapSystem.Directions[Type.Direction.SS]; int2 westPosition = neighborCell.Position + MapSystem.Directions[Type.Direction.WW]; bool northSolid = !Util.Map.OnMap(northPosition) || cells[Util.Map.PositionToIndex(northPosition)].Solid; bool eastSolid = !Util.Map.OnMap(eastPosition) || cells[Util.Map.PositionToIndex(eastPosition)].Solid; bool southSolid = !Util.Map.OnMap(southPosition) || cells[Util.Map.PositionToIndex(southPosition)].Solid; bool westSolid = !Util.Map.OnMap(westPosition) || cells[Util.Map.PositionToIndex(westPosition)].Solid; if (neighborDirection == Type.Direction.NE) { if (northSolid || eastSolid) { return(false); } } if (neighborDirection == Type.Direction.SE) { if (southSolid || eastSolid) { return(false); } } if (neighborDirection == Type.Direction.NW) { if (northSolid || westSolid) { return(false); } } if (neighborDirection == Type.Direction.SW) { if (southSolid || westSolid) { return(false); } } return(true); }
public void SetCell(int2 position, Data.Cell cellData) { SetCell(position.x, position.y, cellData); }
// Set Methods public void SetCell(int x, int y, Data.Cell cellData) { cells[Util.Map.PositionToIndex(x, y)] = cellData; }