コード例 #1
0
ファイル: ObjCell.cs プロジェクト: roidzilla/ACE
        public static ObjCell find_cell_list(Position position, int numSphere, List <Sphere> sphere, CellArray cellArray, ObjCell currCell, SpherePath path)
        {
            cellArray.NumCells     = 0;
            cellArray.AddedOutside = false;

            var cell = GetVisible(position.ObjCellID);

            if ((position.ObjCellID & 0xFFFF) >= 0x100)
            {
                if (path != null)
                {
                    path.HitsInteriorCell = true;
                }

                cellArray.add_cell(position.ObjCellID, cell);
            }
            else
            {
                LandCell.add_all_outside_cells(position, numSphere, sphere, cellArray);
            }

            if (cell != null && numSphere != 0)
            {
                foreach (var otherCell in cellArray.Cells)
                {
                    if (otherCell != null)
                    {
                        otherCell.find_transit_cells(position, numSphere, sphere, cellArray, path);
                    }
                }
                if (currCell != null)
                {
                    foreach (var otherCell in cellArray.Cells)
                    {
                        var blockOffset = LandDefs.GetBlockOffset(position.ObjCellID, otherCell.ID);
                        var localPoint  = sphere[0].Center - blockOffset;

                        if (otherCell.point_in_cell(localPoint) && (otherCell.ID & 0xFFFF) >= 0x100)
                        {
                            if (path != null)
                            {
                                path.HitsInteriorCell = true;
                            }
                            return(otherCell);
                        }
                    }
                }
            }
            if (!cellArray.LoadCells && (position.ObjCellID & 0xFFFF) >= 0x100)
            {
                foreach (var otherCell in cellArray.Cells)
                {
                    if (cell.ID != otherCell.ID)
                    {
                        continue;
                    }

                    var found = false;
                    foreach (var stab in cell.StabList)
                    {
                        if (otherCell.ID == stab)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        cellArray.remove_cell(otherCell);
                    }
                }
            }
            return(null);
        }
コード例 #2
0
        public static void find_cell_list(Position position, int numSphere, List <Sphere> sphere, CellArray cellArray, ref ObjCell currCell, SpherePath path)
        {
            cellArray.NumCells     = 0;
            cellArray.AddedOutside = false;

            var visibleCell = GetVisible(position.ObjCellID);

            if ((position.ObjCellID & 0xFFFF) >= 0x100)
            {
                if (path != null)
                {
                    path.HitsInteriorCell = true;
                }

                cellArray.add_cell(position.ObjCellID, visibleCell);
            }
            else
            {
                LandCell.add_all_outside_cells(position, numSphere, sphere, cellArray);
            }

            if (visibleCell != null && numSphere != 0)
            {
                for (var i = 0; i < cellArray.Cells.Count; i++)
                {
                    var cell = cellArray.Cells.Values.ElementAt(i);
                    if (cell == null)
                    {
                        continue;
                    }

                    cell.find_transit_cells(position, numSphere, sphere, cellArray, path);
                }
                //var checkCells = cellArray.Cells.Values.ToList();
                //foreach (var cell in checkCells)
                //cell.find_transit_cells(position, numSphere, sphere, cellArray, path);

                if (currCell != null)
                {
                    currCell = null;
                    foreach (var cell in cellArray.Cells.Values)
                    {
                        if (cell == null)
                        {
                            continue;
                        }

                        var blockOffset = LandDefs.GetBlockOffset(position.ObjCellID, cell.ID);
                        var localPoint  = sphere[0].Center - blockOffset;

                        if (cell.point_in_cell(localPoint))
                        {
                            currCell = cell;
                            if ((cell.ID & 0xFFFF) >= 0x100)
                            {
                                if (path != null)
                                {
                                    path.HitsInteriorCell = true;
                                }
                                return;     // break?
                            }
                        }
                    }
                }
            }
            if (!cellArray.LoadCells && (position.ObjCellID & 0xFFFF) >= 0x100)
            {
                var cells = cellArray.Cells.Values.ToList();
                foreach (var cell in cells)
                {
                    if (cell == null)
                    {
                        continue;
                    }

                    if (visibleCell.ID == cell.ID)
                    {
                        continue;
                    }

                    var found = false;

                    foreach (var stab in ((EnvCell)visibleCell).VisibleCells.Values)
                    {
                        if (stab == null)
                        {
                            continue;
                        }

                        if (cell.ID == stab.ID)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        cellArray.remove_cell(cell);
                    }
                }
            }
        }