public static void add(int x, int y) { if (!BlockDebugInfo.inited) { GridGraph gridGraph = AstarPath.active.astarData.gridGraph; if (gridGraph != null) { BlockDebugInfo.inited = true; foreach (KeyValuePair <int, BlockDebugInfo> current in BlockDebugInfo.InfoMap) { BlockDebugInfo.initPos(current.Value, current.Key); } } } int num = (y << 16) + x; BlockDebugInfo blockDebugInfo = null; if (!BlockDebugInfo.InfoMap.TryGetValue(num, out blockDebugInfo)) { blockDebugInfo = new BlockDebugInfo { cnt = 1, pos = Vector3.zero }; BlockDebugInfo.initPos(blockDebugInfo, num); BlockDebugInfo.InfoMap.Add(num, blockDebugInfo); } else { blockDebugInfo.cnt++; } }
public static void initPos(BlockDebugInfo info, int index) { if (!BlockDebugInfo.inited) { return; } int num = index >> 16; int num2 = index - (num << 16); GridGraph gridGraph = AstarPath.active.astarData.gridGraph; if (gridGraph != null && info != null) { Vector3 center = gridGraph.center; center.x -= gridGraph.nodeSize * (float)gridGraph.Width / 2f; center.z -= gridGraph.nodeSize * (float)gridGraph.Depth / 2f; Vector3 origin = center; origin.x += ((float)num2 + 0.5f) * gridGraph.nodeSize; origin.z += ((float)num + 0.5f) * gridGraph.nodeSize; origin.y += 100f; LayerMask layerMask = Layer.GroundMask; RaycastHit raycastHit; if (Physics.Raycast(origin, Vector3.down, out raycastHit, 100f, layerMask.value)) { origin.y = raycastHit.point.y + 0.25f; } else { origin.y = center.y; } info.pos = origin; } }
private void RemoveBlock(string[] param) { int x = int.Parse(param[1]); int y = int.Parse(param[2]); BlockDebugInfo.remove(x, y); }
private void AddBlock(string[] param) { int x = int.Parse(param[1]); int y = int.Parse(param[2]); BlockDebugInfo.add(x, y); }
public void VerifyBlockIndexes() { Console.WriteLine("Verifying blocks."); VolumeStream.Position = TocOffset + 0x12; ushort blockCount = VolumeStream.ReadUInt16(); BlockInfo block = GetBlock(0); BlockDebugInfo blockDebInfo = new BlockDebugInfo(); blockDebInfo.ReadFromBlockInfo(block); foreach (var entry in blockDebInfo.Entries) { var childIndexBlock = GetBlock(entry.BlockIndex); BlockDebugInfo childblockDebInfo = new BlockDebugInfo(); childblockDebInfo.ReadFromBlockInfo(childIndexBlock); for (int i = 0; i < childblockDebInfo.Entries.Count; i++) { BlockDebugEntryInfo cutoff = childblockDebInfo.Entries[i]; // Get the entries in the middle var prevEntryBlock = GetBlock(cutoff.BlockIndex); BlockDebugInfo prevEntryBlockDebInfo = new BlockDebugInfo(); prevEntryBlockDebInfo.ReadFromBlockInfo(prevEntryBlock); var nextEntryBlock = GetBlock(cutoff.BlockIndex + 1); BlockDebugInfo nextEntryBlockDebInfo = new BlockDebugInfo(); nextEntryBlockDebInfo.ReadFromBlockInfo(nextEntryBlock); var lastEntry = prevEntryBlockDebInfo.Entries[^ 1];
public static void remove(int x, int y) { int key = (y << 16) + x; BlockDebugInfo blockDebugInfo = null; if (BlockDebugInfo.InfoMap.TryGetValue(key, out blockDebugInfo) && --blockDebugInfo.cnt == 0) { BlockDebugInfo.InfoMap.Remove(key); } }