Ejemplo n.º 1
0
            public CellData GetCardinal(Direction direction)
            {
                Dictionary <Direction, Vector3> dirs = new Dictionary <Direction, Vector3>()
                {
                    { Direction.East, new Vector3(1f, 0f, 0f) },
                    { Direction.South, new Vector3(0f, 0f, 1f) },
                    { Direction.West, new Vector3(-1f, 0f, 0f) },
                    { Direction.North, new Vector3(0f, 0f, -1f) },
                };

                if (dirs.ContainsKey(direction))
                {
                    Cell cardinal = World.inst.GetCellData(cell.Center + dirs[direction]);
                    if (cardinal != null)
                    {
                        string id = ElevationManager.GetCellMarkID(cardinal);
                        if (!string.IsNullOrEmpty(id))
                        {
                            if (cellsData.ContainsKey(id))
                            {
                                return(cellsData[id]);
                            }
                        }
                    }
                }
                return(new CellData()
                {
                    empty = true
                });
            }
Ejemplo n.º 2
0
 public static int GetTileRegion(Cell cell)
 {
     if (cellsData.ContainsKey(ElevationManager.GetCellMarkID(cell)))
     {
         return(cellsData[ElevationManager.GetCellMarkID(cell)].region);
     }
     return(-1);
 }
Ejemplo n.º 3
0
        public static void DoRegionSearch(List <CellMark> data)
        {
            Pruned = false;
            regionData.Clear();
            cellsData.Clear();

            List <CellMark> groundLevel = new List <CellMark>();

            for (int landmass = 0; landmass < World.inst.NumLandMasses; landmass++)
            {
                foreach (Cell cell in World.inst.cellsToLandmass[landmass].data)
                {
                    if (cell != null)
                    {
                        CellMark mark = ElevationManager.GetCellMark(cell);
                        if (mark != null)
                        {
                            if (mark.elevationTier == 0)
                            {
                                groundLevel.Add(mark);
                            }
                        }
                    }
                }
            }


            // Preperation
            foreach (CellMark node in data)
            {
                CellData nodeData = new CellData()
                {
                    cell   = node.cell,
                    mark   = node,
                    region = -1
                };

                cellsData.Add(ElevationManager.GetCellMarkID(node.cell), nodeData);
            }



            // First Pass: Assigning all ground-level tiles their own region
            regionData.Add(0, new List <CellData>());
            foreach (CellData node in cellsData.Values)
            {
                if (node.mark.elevationTier == 0)
                {
                    node.region = 0;
                }
            }

            // Second Pass: Iterate on all ground-level nodes.
            foreach (CellData node in cellsData.Values)
            {
                IterateNode(node);
            }

            ReformatRegions();
            MarkPruned();
            Mod.Log("Blocked Regions Pruned");
        }