private static ushort CreateBuilding(BuildingTool _this, BuildingInfo info, Vector3 position, float angle, int relocating, bool needMoney, bool fixedHeight) { Debug.Log("BuildIndex is : " + Singleton <SimulationManager> .instance.m_currentBuildIndex); //call original method try { RICOBuildingManager.AddBuilding(info, Singleton <SimulationManager> .instance.m_currentBuildIndex); } catch (Exception e) { Debug.LogException(e); } CreateBuildingRedirector.Revert(); CreateBuildingAlt(_this, info, position, angle, relocating, needMoney, fixedHeight); CreateBuildingRedirector.Apply(); //Add plopped building to RICOBuildingManager ushort num = 0; return(num); //no clue why it needs to return a ushort, source code doesnt appear to do anything with it. }
[RedirectMethod(true)] // Detour reason: Load extra zone data before method is executed public static void UpdateData(TerrainManager _this, SimulationManager.UpdateMode mode) { DataExtension.instance.OnUpdateData(); // Call original method UpdateDataRedirector.Revert(); _this.UpdateData(mode); UpdateDataRedirector.Apply(); }
[RedirectMethod(true)] // Detour reason: Keep cachedBlockIDs in sync public static void ReleaseBlock(ZoneManager _this, ushort block) { if (_this.m_blocks.m_buffer[block].m_flags != 0u) { cachedBlockIDs.Add(block); } // Call original method ReleaseBlockRedirector.Revert(); _this.ReleaseBlock(block); ReleaseBlockRedirector.Apply(); }
[RedirectMethod(true)] // Detour reason: Keep cachedBlockIDs in sync private static void SimulationStepImpl(ZoneManager _this, int subStep) { bool blocksUpdated = _this.m_blocksUpdated; // Call original method SimulationStepImplRedirector.Revert(); SimulationStepImplAlt(_this, subStep); SimulationStepImplRedirector.Apply(); if (blocksUpdated) { cachedBlockIDs.Clear(); } }
public static void ReleaseSegment(NetManager _this, ushort segmentID, bool keepNodes) { var segment = _this.m_segments.m_buffer[segmentID]; int columnCount = 0; FindColumnCount(segment.m_blockEndLeft, ref columnCount); FindColumnCount(segment.m_blockEndRight, ref columnCount); FindColumnCount(segment.m_blockStartLeft, ref columnCount); FindColumnCount(segment.m_blockStartRight, ref columnCount); var caller = new System.Diagnostics.StackFrame(1).GetMethod().Name; //Debug.Log($"ReleaseSegment called by {caller}, id: {segmentID}, type: {segment.Info.name}"); switch (caller) { case "MoveMiddleNode": // segment that was modified because user added network, keep data until replacement segments were created // Save segment id MoveMiddleNode_releasedColumnCount = columnCount; break; case "SplitSegment": // segment that was split by new node, keep data until replacement segments were created // Save segment id SplitSegment_releasedColumnCount = columnCount; break; default: // unknown caller break; } // Call original method ReleaseSegmentRedirector.Revert(); _this.ReleaseSegment(segmentID, keepNodes); ReleaseSegmentRedirector.Apply(); }
public static bool CreateSegment(NetManager _this, out ushort segmentID, ref Randomizer randomizer, NetInfo info, ushort startNode, ushort endNode, Vector3 startDirection, Vector3 endDirection, uint buildIndex, uint modifiedIndex, bool invert) { var ai = info.m_netAI as RoadAI; if (ai != null && ai.m_enableZoning) { var caller = new System.Diagnostics.StackFrame(1).GetMethod().Name; switch (caller) { case "MoveMiddleNode": // segment that was modified because user added network, apply style of previous segment newBlockColumnCount = MoveMiddleNode_releasedColumnCount >= 0 ? MoveMiddleNode_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount; break; case "SplitSegment": // segment that was split by new node, apply style of previous segment newBlockColumnCount = SplitSegment_releasedColumnCount >= 0 ? SplitSegment_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount; break; default: // unknown caller (e.g. new road placed), set to depth selected by user newBlockColumnCount = InputThreadingExtension.userSelectedColumnCount; SplitSegment_releasedColumnCount = -1; MoveMiddleNode_releasedColumnCount = -1; break; } } // Call original method CreateSegmentRedirector.Revert(); var success = _this.CreateSegment(out segmentID, ref randomizer, info, startNode, endNode, startDirection, endDirection, buildIndex, modifiedIndex, invert); CreateSegmentRedirector.Apply(); return(success); }
[RedirectMethod(true)] // Detour Reason: Deeper zones data storage, custom depth public static bool CreateBlock(ZoneManager _this, out ushort block, ref Randomizer randomizer, Vector3 position, float angle, int rows, uint buildIndex) { bool result; var columns = NetManagerDetour.newBlockColumnCount; if (columns == 0) // create no blocks if desired zone depth is 0 { block = 0; result = false; } else { // Call original method CreateBlockRedirector.Revert(); result = _this.CreateBlock(out block, ref randomizer, position, angle, rows, buildIndex); CreateBlockRedirector.Apply(); if (result) { // --- support for larger zones --- if (DataExtension.zones3 != null) { DataExtension.zones3[block] = 0UL; } if (DataExtension.zones4 != null) { DataExtension.zones4[block] = 0UL; } // --- dynamic column count --- // TODO should only affect new roads, not ones replaced or splitted by the game (see Network Skins source code) ZoneBlockDetour.SetColumnCount(ref _this.m_blocks.m_buffer[(int)block], columns); } } return(result); }