/// <summary> /// Reverses our redirects from ours back to C/O's /// </summary> public static void ReveseSetup() { if (Mod.IsTMDetoured == false & Mod.IsPushDetoured == false) { return; } if (redirectDic.Count == 0) { if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("No state entries exists to revert."); } return; } try { foreach (var keypair in redirectDic) { RedirectionHelper.RevertRedirect(keypair.Key, keypair.Value); } redirectDic.Clear(); Mod.IsTMDetoured = false; Mod.IsPushDetoured = false; if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("Reverted redirected calls."); } } catch (Exception exception1) { Helper.dbgLog("ReverseSetup error:", exception1, true); } }
private IEnumerator CreateBuilding_Short() { //Debug.Log("CreateBuilding detour"); UndoMod.Instsance.BeginObserving("Build building", "Vanilla"); IEnumerator result = null; RedirectionHelper.RevertRedirect(createBuilding_originalShort, state); state = RedirectionHelper.RedirectCalls(shortPatch, createBuilding_originalShort); try { // This is a genius piece of code. No joking! //result = (IEnumerator) createBuilding_originalShort.Invoke(ToolsModifierControl.GetTool<BuildingTool>(), new object[] {}); result = CreateBuilding_Short(); AsyncTask asyncTask = new AsyncTask(result, null); asyncTask.Execute(); } catch (Exception e) { Debug.LogError(e); UndoMod.Instsance.InvalidateAll(); } finally { RedirectionHelper.RevertRedirect(shortPatch, state); state = RedirectionHelper.RedirectCalls(createBuilding_originalShort, shortPatch); } //Singleton<SimulationManager>.instance.AddAction(() => { UndoMod.Instsance.EndObserving(); //}); yield return(0); yield break; }
private IEnumerator CreateProp() { Debug.Log("CreateProp detour"); UndoMod.Instsance.BeginObserving("Build prop", "Vanilla"); IEnumerator result = null; RedirectionHelper.RevertRedirect(createProp_original, state); try { result = (IEnumerator)createProp_original.Invoke(ToolsModifierControl.GetTool <PropTool>(), new object[] { }); AsyncTask asyncTask = new AsyncTask(result, null); asyncTask.Execute(); } catch (Exception e) { Debug.LogError(e); UndoMod.Instsance.InvalidateAll(); } state = RedirectionHelper.RedirectCalls(createProp_original, patch); //Singleton<SimulationManager>.instance.AddAction(() => { UndoMod.Instsance.EndObserving(); //}); yield return(0); yield break; }
/// <summary> /// Reverses our redirects from ours back to C/O's /// </summary> public static void RemoveRedirects() { if (m_isActive == false) { if (Mod.DEBUG_LOG_ON) { Logger.dbgLog("Redirects are not active no need to reverse."); } return; } if (redirectDic.Count == 0) { if (Mod.DEBUG_LOG_ON) { Logger.dbgLog("No state entries exists to revert. clearing state?"); } m_isActive = false; return; } try { foreach (var keypair in redirectDic) { RedirectionHelper.RevertRedirect(keypair.Key, keypair.Value); } redirectDic.Clear(); m_isActive = false; if (Mod.DEBUG_LOG_ON) { Logger.dbgLog("Reverted redirected calls."); } } catch (Exception exception1) { Logger.dbgLog("Reversing of Detours error:", exception1, true); } }
public void Restore(bool revertDetour) { if (m_prefab == null) { return; } if (m_detoured && revertDetour) { m_detoured = false; foreach (KeyValuePair <MethodInfo, RedirectCallsState> current in m_redirections) { RedirectionHelper.RevertRedirect(current.Key, current.Value); } } if (m_singleMode) { singleMode = false; return; } if (m_hasElevation) { m_roadAI.info = m_prefab; m_roadAI.elevated = m_elevated; m_roadAI.bridge = m_bridge; m_roadAI.slope = m_slope; m_roadAI.tunnel = m_tunnel; } }
public override void OnLevelUnloading() { base.OnLevelUnloading(); foreach (RedirectCallsState redirectState in redirectStates) { RedirectionHelper.RevertRedirect(redirectState); } }
public void DisableHooks() { foreach (var kvp in redirects) { RedirectionHelper.RevertRedirect(kvp.Key, kvp.Value); } redirects.Clear(); }
public static void Revert() { if (m_deployed) { RedirectionHelper.RevertRedirect(from, m_state); m_deployed = false; } }
public static void Revert() { if (!_deployed) { return; } RedirectionHelper.RevertRedirect(From, _state); _deployed = false; }
public static void Revert() { if (!m_deployed) { return; } RedirectionHelper.RevertRedirect(@from, m_state); m_deployed = false; }
public static void Revert() { if (_redirects == null) { return; } foreach (var redirect in _redirects) { RedirectionHelper.RevertRedirect(redirect.Key, redirect.Value); } _redirects = null; }
public static void Revert() { if (!_deployed) { return; } if (_originalInfo != null && _detourInfo != null) { RedirectionHelper.RevertRedirect(_originalInfo, _state); } _deployed = false; }
private static void RevertRedirect() { if (redirects == null) { return; } foreach (var kvp in redirects) { RedirectionHelper.RevertRedirect(kvp.Key, kvp.Value); } redirects.Clear(); }
private static void RevertRedirect(bool onCreated) { var redirects = onCreated ? redirectsOnCreated : redirectsOnLoaded; if (redirects == null) { return; } foreach (var kvp in redirects) { RedirectionHelper.RevertRedirect(kvp.Key, kvp.Value); } redirects.Clear(); }
public void RevertDetour() { if (DetourInited) { DebugLog.LogToFileOnly("Revert detours"); Detours.Reverse(); foreach (Detour d in Detours) { RedirectionHelper.RevertRedirect(d.OriginalMethod, d.Redirect); } DetourInited = false; Detours.Clear(); DebugLog.LogToFileOnly("Reverting detours finished."); } }
public static void Revert() { if (_deployed) { try { RedirectionHelper.RevertRedirect(BeginEventMethod, _state); } catch (Exception exception) { Debug.LogException(exception); } _deployed = false; } }
public static void Revert() { if (_redirects == null) { return; } foreach (var redirect in _redirects) { RedirectionHelper.RevertRedirect(redirect.Key, redirect.Value); } _redirects = null; initialized = false; camera = null; cachedFreeCamera = false; }
public static void Revert() { if (_redirects == null) { return; } foreach (var redirect in _redirects) { RedirectionHelper.RevertRedirect(redirect.Key, redirect.Value); } _redirects = null; noCalmCounter = 0; targetCalm = 0; currentCalm = 0; initialized = false; }
public void RevertDetour() { if (DetourInited) { Debug.Log("Revert detours"); Detours.Reverse(); foreach (Detour d in Detours) { RedirectionHelper.RevertRedirect(d.OriginalMethod, d.Redirect); } DetourInited = false; Threading.isFirstTime = true; Detours.Clear(); Debug.Log("Reverting detours finished."); } }
public static void Revert() { if (deployed) { RedirectionHelper.RevertRedirect(_Building_SetWidth_original, _Building_SetWidth_state); _Building_SetWidth_original = null; _Building_SetWidth_detour = null; RedirectionHelper.RevertRedirect(_Building_SetLength_original, _Building_SetLength_state); _Building_SetLength_original = null; _Building_SetLength_detour = null; deployed = false; UnityEngine.Debug.Log("LargerFootprints: Building Methods restored!"); } }
public static void Revert() { if (deployed) { RedirectionHelper.RevertRedirect(_AI_GetWidthRange_original, _AI_GetWidthRange_state); _AI_GetWidthRange_original = null; _AI_GetWidthRange_detour = null; RedirectionHelper.RevertRedirect(_AI_GetLengthRange_original, _AI_GetLengthRange_state); _AI_GetLengthRange_original = null; _AI_GetLengthRange_detour = null; deployed = false; Debug.LogFormat("LargerFootprints: {0} Methods restored!", typeof(A).Name); } }
public static void Revert() { if (!deployed) { return; } RedirectionHelper.RevertRedirect(_NetManager_CreateSegment_original, _NetManager_CreateSegment_state); _NetManager_CreateSegment_original = null; _NetManager_CreateSegment_detour = null; RedirectionHelper.RevertRedirect(_NetManager_ReleaseSegment_original, _NetManager_ReleaseSegment_state); _NetManager_ReleaseSegment_original = null; _NetManager_ReleaseSegment_detour = null; deployed = false; }
public override void OnLevelUnloading() { base.OnLevelUnloading(); LoadingExtension.Instance.UI.DestroyPanels(); foreach (RedirectCallsState rcs in m_redirectionStates) { RedirectionHelper.RevertRedirect(rcs); } TrafficPriority.prioritySegments.Clear(); CustomRoadAI.nodeDictionary.Clear(); TrafficLightsManual.ManualSegments.Clear(); TrafficLightsTimed.timedScripts.Clear(); LoadingExtension.Instance.nodeSimulationLoaded = false; SerializableDataExtension.configLoaded = false; roadManagerInitialized = false; //ToolsModifierControl.SetTool<DefaultTool>(); }
public static void Revert() { if (!_deployed) { return; } try { RedirectionHelper.RevertRedirect(Method1, _state1); RedirectionHelper.RevertRedirect(Method2, _state2); } catch (Exception e) { Debug.LogException(e); } _deployed = false; }
public new void ReleaseSegment(ushort segment, bool keepNodes) { var caller = new System.Diagnostics.StackFrame(1).GetMethod().Name; //Debug.Log("ReleaseSegment (" + NetManager.instance.m_segments.m_buffer[segment].Info.name + ") called by " + caller); switch (caller) { case "MoveMiddleNode": // segment that was modified because user added network, keep data until replacement segments were created // Delete data of last moved segment if (MoveMiddleNode_releasedSegment > 0) { EventSegmentRelease?.Invoke(MoveMiddleNode_releasedSegment); } // Save segment id MoveMiddleNode_releasedSegment = segment; break; case "SplitSegment": // segment that was split by new node, keep data until replacement segments were created // Delete data of last splitted segment if (SplitSegment_releasedSegment > 0) { EventSegmentRelease?.Invoke(SplitSegment_releasedSegment); } // Save segment id SplitSegment_releasedSegment = segment; break; case "DeleteSegmentImpl": // segment deleted with bulldozer by user, delete data case "ReleasePaths": // segment deleted because user bulldozed building with integrated networks, delete data default: // unknown caller, delete data EventSegmentRelease?.Invoke(segment); break; } // Call original method RedirectionHelper.RevertRedirect(_NetManager_ReleaseSegment_original, _NetManager_ReleaseSegment_state); NetManager.instance.ReleaseSegment(segment, keepNodes); RedirectionHelper.RedirectCalls(_NetManager_ReleaseSegment_original, _NetManager_ReleaseSegment_detour); }
private void CalculateImplementation1(ushort blockID, ushort segmentID, ref NetSegment data, ref ulong valid, float minX, float minZ, float maxX, float maxZ) { if (data.Info.m_flattenTerrain) { RedirectionHelper.RevertRedirect(from, m_state); fixed(void *pointer = &this) { ZoneBlock *block = (ZoneBlock *)pointer; object[] param = new object[] { blockID, segmentID, data, valid, minX, minZ, maxX, maxZ }; from.Invoke(*block, param); valid = (ulong)param[3]; } m_state = RedirectionHelper.RedirectCalls(from, to); } }
public static void Revert() { if (!_deployed) { return; } try { RedirectionHelper.RevertRedirect( typeof(MonumentAI).GetMethod("CanBeBuilt"), _state ); } catch (Exception e) { UnityEngine.Debug.LogException(e); } _deployed = false; }
private bool CreateNodeImpl(bool switchDirection) { //Debug.Log("CreateNode detour"); UndoMod.Instsance.BeginObserving("Build roads", "Vanilla"); bool result = false; RedirectionHelper.RevertRedirect(createNode_original, state); state = RedirectionHelper.RedirectCalls(patch, createNode_original); try { //result = (bool)createNode_original.Invoke(ToolsModifierControl.GetTool<NetTool>(), new object[] { switchDirection }); result = CreateNodeImpl(switchDirection); } catch (Exception e) { Debug.LogError(e); UndoMod.Instsance.InvalidateAll(); } RedirectionHelper.RevertRedirect(patch, state); state = RedirectionHelper.RedirectCalls(createNode_original, patch); UndoMod.Instsance.EndObserving(); return(result); }
public static void Unpatch() { RedirectionHelper.RevertRedirect(releaseProp_original, releasePropState); RedirectionHelper.RevertRedirect(createProp_original, createPropState); }
public static void Unpatch() { RedirectionHelper.RevertRedirect(createBuilding_originalShort, state); //_harmony.Unpatch(createBuilding_originalLong, prefix); //_harmony.Unpatch(createBuilding_originalLong, postfix); }