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]); } }
public EnvCell add_visible_cell(uint cellID) { var envCell = (EnvCell)DBObj.Get(new QualifiedDataID(3, cellID)); VisibleCells.Add(cellID, envCell); return(envCell); }
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); } }
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(); }
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(); }
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)); } }
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); }
/// <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); }
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); }