예제 #1
0
        public EnvCell(DatLoader.FileTypes.EnvCell envCell) : base()
        {
            Bitfield           = envCell.Bitfield;
            ID                 = envCell.Id;
            ShadowObjectIDs    = envCell.Shadows;
            Pos                = new Position(ID, new AFrame(envCell.Position));
            Portals            = envCell.CellPortals;
            NumPortals         = Portals.Count;
            StaticObjectIDs    = new List <uint>();
            StaticObjectFrames = new List <AFrame>();
            foreach (var staticObj in envCell.StaticObjects)
            {
                StaticObjectIDs.Add(staticObj.Id);
                StaticObjectFrames.Add(new AFrame(staticObj.Frame));
            }
            NumStabs       = StaticObjectIDs.Count;
            VisibleCellIDs = envCell.VisibleCells;
            RestrictionObj = envCell.RestrictionObj;
            SeenOutside    = envCell.SeenOutside;

            EnvironmentID   = envCell.EnvironmentId;
            Environment     = (DatLoader.FileTypes.Environment)DBObj.Get(new QualifiedDataID(16, EnvironmentID));
            CellStructureID = envCell.CellStructure;
            if (Environment.Cells != null && Environment.Cells.ContainsKey(CellStructureID))
            {
                CellStructure = new CellStruct(Environment.Cells[CellStructureID]);
            }
        }
예제 #2
0
        public EnvCell add_visible_cell(uint cellID)
        {
            var envCell = (EnvCell)DBObj.Get(new QualifiedDataID(3, cellID));

            VisibleCells.Add(cellID, envCell);
            return(envCell);
        }
예제 #3
0
파일: LScape.cs 프로젝트: PyrealMote/ACE
        public static Landblock get_all(uint landblockID)
        {
            var landblock = (DatLoader.FileTypes.CellLandblock)DBObj.Get(new QualifiedDataID(1, landblockID));

            if (landblock != null)
            {
                return(new Landblock(landblock));
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
파일: Landblock.cs 프로젝트: PyrealMote/ACE
        public Landblock(CellLandblock landblock)
            : base(landblock)
        {
            Init();

            ID = landblock.Id;
            BlockInfoExists = landblock.HasObjects;
            if (BlockInfoExists)
            {
                Info = (LandblockInfo)DBObj.Get(new QualifiedDataID(2, ID - 1));
            }
            BlockCoord = LandDefs.blockid_to_lcoord(landblock.Id).Value;
            _landblock = landblock;
            get_land_limits();
        }
예제 #5
0
파일: Landblock.cs 프로젝트: paroxysmal/ACE
        public Landblock(CellLandblock landblock)
            : base(landblock)
        {
            Init();

            ID = landblock.Id;
            //Console.WriteLine("Loading landblock " + ID.ToString("X8"));
            BlockInfoExists = landblock.HasObjects;
            if (BlockInfoExists)
            {
                Info = (LandblockInfo)DBObj.Get(new QualifiedDataID(2, ID - 1));
            }
            BlockCoord = LandDefs.blockid_to_lcoord(landblock.Id).Value;
            _landblock = landblock;
            get_land_limits();
        }
예제 #6
0
파일: ObjCell.cs 프로젝트: zarlant/ACE
        public static ObjCell Get(uint cellID)
        {
            if (cellID == 0)
            {
                return(null);
            }

            var objCell = new ObjCell(cellID);

            if (cellID >= 0x100)
            {
                return((EnvCell)DBObj.Get(new QualifiedDataID(3, cellID)));
            }
            else
            {
                return(LandCell.Get(cellID));
            }
        }
예제 #7
0
파일: LScape.cs 프로젝트: paroxysmal/ACE
        public static ObjCell get_landcell(uint blockCellID)
        {
            //Console.WriteLine($"get_landcell({blockCellID:X8}");

            var landblock = get_landblock(blockCellID);

            if (landblock == null)
            {
                return(null);
            }

            var     cellID = blockCellID & 0xFFFF;
            ObjCell cell   = null;

            // outdoor cells
            if (cellID < 0x100)
            {
                var lcoord = LandDefs.gid_to_lcoord(blockCellID, false);
                if (lcoord == null)
                {
                    return(null);
                }
                var landCellIdx = ((int)lcoord.Value.Y % 8) + ((int)lcoord.Value.X % 8) * landblock.SideCellCount;
                landblock.LandCells.TryGetValue(landCellIdx, out cell);
            }
            // indoor cells
            else
            {
                landblock.LandCells.TryGetValue((int)cellID, out cell);
                if (cell != null)
                {
                    return(cell);
                }
                cell = (EnvCell)DBObj.Get(new QualifiedDataID(3, blockCellID));
                landblock.LandCells.Add((int)cellID, cell);
                var envCell = cell as EnvCell;
                envCell.PostInit();
            }
            return(cell);
        }
예제 #8
0
파일: LScape.cs 프로젝트: Cloudxtreme/ACE-1
        /// <summary>
        /// Loads the backing store landblock structure
        /// </summary>
        /// <param name="cellID">Any cellID within the landblock</param>
        public static Landblock get_landblock(uint cellID)
        {
            // client implementation

            /*if (Landblocks == null || Landblocks.Count == 0)
             *  return null;
             *
             * if (!LandDefs.inbound_valid_cellid(cellID) || cellID >= 0x100)
             *  return null;
             *
             * var local_lcoord = LandDefs.blockid_to_lcoord(LoadedCellID);
             * var global_lcoord = LandDefs.gid_to_lcoord(cellID);
             *
             * var xDiff = ((int)global_lcoord.Value.X + 8 * MidRadius - (int)local_lcoord.Value.X) / 8;
             * var yDiff = ((int)global_lcoord.Value.Y + 8 * MidRadius - (int)local_lcoord.Value.Y) / 8;
             *
             * if (xDiff < 0 || yDiff < 0 || xDiff < MidWidth || yDiff < MidWidth)
             *  return null;
             *
             * return Landblocks[yDiff + xDiff * MidWidth];*/

            var landblockID = cellID | 0xFFFF;

            // check if landblock is already cached
            Landblock landblock = null;

            Landblocks.TryGetValue(landblockID, out landblock);
            if (landblock != null)
            {
                return(landblock);
            }

            // if not, load into cache
            landblock = new Landblock((DatLoader.FileTypes.CellLandblock)DBObj.Get(new QualifiedDataID(1, landblockID)));
            Landblocks.Add(landblockID, landblock);
            landblock.PostInit();

            return(landblock);
        }
예제 #9
0
        public static ObjCell get_landcell(uint blockCellID)
        {
            var landblock = get_landblock(blockCellID);

            if (landblock == null)
            {
                return(null);
            }

            var     cellID = blockCellID & 0xFFFF;
            ObjCell cell   = null;

            // outdoor cells
            if (cellID < 0x100)
            {
                var lcoord = LandDefs.gid_to_lcoord(blockCellID, false);
                if (lcoord == null)
                {
                    return(null);
                }
                var landCellIdx = ((int)lcoord.Value.Y % 8) + ((int)lcoord.Value.X % 8) * landblock.SideCellCount;
                landblock.LandCells.TryGetValue(landCellIdx, out cell);
            }
            // indoor cells
            else
            {
                landblock.LandCells.TryGetValue((int)cellID, out cell);
                if (cell != null)
                {
                    return(cell);
                }
                cell = (EnvCell)DBObj.Get(new QualifiedDataID(3, blockCellID));
                landblock.LandCells.Add((int)cellID, cell);
                ((EnvCell)cell).build_visible_cells();
            }
            return(cell);
        }