void UnloadPatch(string patchName, Action callback = null) { if (!patchName.StartsWith(PatchConfiguration.PatchIdentifier, StringComparison.OrdinalIgnoreCase)) { return; } var s = SceneManager.GetSceneByName(patchName); if (Application.isPlaying) { if (s.IsValid() && s.isLoaded) { if (!IsPatchLocked(patchName) && !QueueContains(patchName, PatchAction.PatchActionType.Unload)) { _queuedActions.Enqueue(PatchAction.Unload(patchName, callback)); } } } else { #if UNITY_EDITOR if (s.IsValid() && s.isLoaded) { EditorSceneManager.CloseScene(s, true); } #endif } }
void LoadPatch(int x, int z, bool skipUnlock, Action onFinishedCallback = null) { var patchName = PatchConfiguration.FormatPatchName(x, z); if (!PatchConfiguration.CanPatchBeLoaded(x, z)) { return; } if (Application.isPlaying) { var scene = SceneManager.GetSceneByName(patchName); if (!skipUnlock) { UnlockPatch(patchName); } if (scene.IsValid() && scene.isLoaded) { return; } if (!QueueContains(patchName, PatchAction.PatchActionType.Load)) { _queuedActions.Enqueue(PatchAction.Load(patchName, onFinishedCallback)); } } else { #if UNITY_EDITOR EditorSceneManager.OpenScene(PatchConfiguration.FormatLocalAssetPathPatchName(x, z), OpenSceneMode.Additive); #endif } }
public static (PatchAction Mode, int Length, int Start) FindNextRun(ReadOnlySpan <byte> source, ReadOnlySpan <byte> target, int targetPosition) { PatchAction mode = PatchAction.TargetRead; int longestRun = 3; int longestStart = -1; // Check For Source Read if (targetPosition < source.Length) { (int length, bool reachedEnd) = CheckRun(source.Slice(targetPosition), target.Slice(targetPosition)); if (length > longestRun) { mode = PatchAction.SourceRead; longestRun = length; if (reachedEnd) { return(mode, longestRun, -1); } } } // Check for Source Copy { (int length, int start, bool reachedEnd) = FindBestRun(source, target.Slice(targetPosition), longestRun + 1); if (length > longestRun) { mode = PatchAction.SourceCopy; longestRun = length; longestStart = start; if (reachedEnd) { return(mode, longestRun, start); } } } // Check for Target Copy { (int length, int start, bool reachedEnd) = FindBestRun(target, target.Slice(targetPosition), longestRun + 1); if (length > longestRun) { mode = PatchAction.TargetCopy; longestRun = length; longestStart = start; if (reachedEnd) { return(mode, longestRun, start); } } } return(mode, longestRun, longestStart); }
private static bool Save(XmlNode xGroupNode, PatchAction patchAction, string ID) { patchAction.Id = "PA_" + ID; XmlNode xPatchAction = xGroupNode.InsertCompressedElement(SST.PatchAction); xPatchAction.CreateAttribute(SST.PatchType, patchAction.PatchActionType.ToString()); xPatchAction.CreateAttribute(SST.ID, patchAction.Id); xPatchAction.CreateAttribute(SST.Name, patchAction.Name); return(patchAction.Save(xPatchAction)); }
private void SetAction(PatchAction action, bool applyRefresh) { foreach (Control c in mPatchAction.Controls) { c.Dispose(); } mPatchAction.Controls.Clear(); var aHolder = new EntryBlockHolder(action, editorFactory, SwooshParent); mPatchAction.Controls.Add(aHolder); aHolder.Dock = DockStyle.Fill; if (applyRefresh) { ReloadPools(); glmFinder.InvokeResize(); } }
public PatchEntry(DataStruct dataStruct) : base(dataStruct) { FinderChain = new List <TargetFinder>(); PatchAction = null; Name = string.Empty; }