public static void OnDismantle(BuildTool_Dismantle __instance) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } List <int> objectIds = __instance.DetermineDismantle().ToList(); if (objectIds.Count <= 0) { return; } BlueprintData blueprint = UndoUtils.GenerateBlueprint(objectIds, out Vector3 position); if (blueprint.buildings.Length > 0 && !position.Equals(Vector3.zero)) { PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoDismantle(data, objectIds, blueprint, new[] { position }, 0)); } }
public static void OnPaste(BuildTool_BlueprintPaste __instance) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } List <int> objectIds = new List <int>(__instance.bpCursor); for (int l = 0; l < __instance.bpCursor; l++) { BuildPreview preview = __instance.bpPool[l]; objectIds.Add(preview.objId); } Vector3[] dots = new Vector3[__instance.dotsCursor]; Array.Copy(__instance.dotsSnapped, dots, __instance.dotsCursor); PlayerUndo data = UndoManager.GetCurrentPlayerData(); UndoBlueprint undo = new UndoBlueprint(data, objectIds, __instance.blueprint, dots, __instance.yaw); data.AddUndoItem(undo); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { CodeMatcher matcher = new CodeMatcher(instructions) .End().MatchBack(false, new CodeMatch(OpCodes.Ldarg_0), new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(BuildTool), nameof(BuildTool.buildPreviews))), new CodeMatch(OpCodes.Callvirt)) .Advance(1) .InsertAndAdvance(Transpilers.EmitDelegate <Action <BuildTool_Inserter> >(tool => { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } IEnumerable <int> objectIds = tool.buildPreviews.Select(preview => preview.objId); PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoBuild(data, objectIds)); })) .InsertAndAdvance(new CodeInstruction(OpCodes.Ldarg_0)); return(matcher.InstructionEnumeration()); }
public static void OnPathAddonBuilt(BuildTool_PathAddon __instance) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoPathAddon(data, __instance.handbp.objId)); }
public static void OnDoUpgragePost() { if (NebulaModAPI.IsMultiplayerActive) { IMultiplayerSession session = NebulaModAPI.MultiplayerSession; if (session.LocalPlayer.IsClient) { session.Network.SendPacket(new ClearUndoRequestPacket(session.LocalPlayer.Id)); UIRealtimeTip.Popup("UndoClearedMessage".Translate(), false); VFAudio.Create("cancel-0", null, Vector3.zero, true, 4); return; } } PlayerUndo data = UndoManager.GetPlayerData(UndoManager.GetLocalUserId()); data.ResetUndo(); }
public static void OnClickBuilt(BuildTool_Click __instance) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } IEnumerable <int> objectIds = __instance.buildPreviews.Select(preview => preview.objId); PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoBuild(data, objectIds)); }
public static void OnUpgradePost(BuildTool_Upgrade __instance) { if (UndoManager.IgnoreAllEvents.Value) { return; } if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } RecordUpgrades = false; if (upgradeList.Count > 0) { PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoUpgrade(data, upgradeList)); } }
public UndoBlueprint(PlayerUndo undoData, IEnumerable <int> objectIds, BlueprintData blueprint, Vector3[] dotsSnapped, float yaw) : base(undoData, objectIds) { this.blueprint = blueprint; this.dotsSnapped = dotsSnapped; this.yaw = yaw; }
public UndoBuild(PlayerUndo undoData, IEnumerable <int> objectIds) : base(undoData) { this.objectIds = new List <int>(objectIds); }
public UndoBuild(PlayerUndo undoData, int objectId) : base(undoData) { objectIds = new List <int> { objectId }; }
public UndoPathAddon(PlayerUndo undoData, int objectId) : base(undoData, objectId) { }
private UndoPathAddon(PlayerUndo undoData, IEnumerable <int> objectIds) : base(undoData, objectIds) { }
public UndoDismantle(PlayerUndo undoData, IEnumerable <int> objectIds, BlueprintData blueprint, Vector3[] dotsSnapped, float yaw) : base(undoData, objectIds, blueprint, dotsSnapped, yaw) { }
public UndoUpgrade(PlayerUndo undoData, IEnumerable <UpgradeData> targets) : base(undoData) { this.targets = new List <UpgradeData>(targets); }