public EnvCell add_visible_cell(uint cellID) { var envCell = DBObj.GetEnvCell(cellID); VisibleCells.Add(cellID, envCell); return(envCell); }
/// <summary>s /// Gets the landcell from a landblock. If the cell is an indoor cell and hasn't been loaded, it will be loaded.<para /> /// This function is thread safe /// </summary> public static ObjCell get_landcell(ulong iBlockCellID) { /*if ((iBlockCellID | 0xFFFF) == 0x1D9FFFF) * { * Console.WriteLine(System.Environment.StackTrace); * var debug = true; * }*/ //Console.WriteLine($"get_landcell({blockCellID:X8}"); var landblock = get_landblock(iBlockCellID); if (landblock == null) { return(null); } var cellID = iBlockCellID & 0xFFFF; ObjCell cell = null; // outdoor cells if (cellID < 0x100) { var lcoord = LandDefs.gid_to_lcoord((uint)iBlockCellID, 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 { if (landblock.LandCells.TryGetValue((int)cellID, out cell)) { return(cell); } lock (landblock.LandCellMutex) { if (landblock.LandCells.TryGetValue((int)cellID, out cell)) { return(cell); } cell = DBObj.GetEnvCell((uint)iBlockCellID); cell.CurLandblock = landblock; landblock.LandCells.TryAdd((int)cellID, cell); var envCell = (EnvCell)cell; envCell.PostInit(); } } return(cell); }
/// <summary> /// Gets the landcell from a landblock. If the cell is an indoor cell and hasn't been loaded, it will be loaded.<para /> /// This function is thread safe /// </summary> 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 { if (landblock.LandCells.TryGetValue((int)cellID, out cell)) { return(cell); } lock (landblock.LandCellMutex) { if (landblock.LandCells.TryGetValue((int)cellID, out cell)) { return(cell); } cell = DBObj.GetEnvCell(blockCellID); landblock.LandCells.TryAdd((int)cellID, cell); var envCell = (EnvCell)cell; envCell.PostInit(); } } return(cell); }
public static ObjCell Get(uint cellID) { if (cellID == 0) { return(null); } var objCell = new ObjCell(cellID); if (cellID >= 0x100) { return(DBObj.GetEnvCell(cellID)); } return(LandCell.Get(cellID)); }