public override void ProcessPacket(ClearUndoRequestPacket packet, INebulaConnection conn) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost) { PlayerUndo data = UndoManager.GetPlayerData(packet.AuthorId); using (NebulaModAPI.MultiplayerSession.Factories.IsIncomingRequest.On()) { data.ResetUndo(); } } }
private static void GenerateUndoData(PlanetFactory factory, List <int> targetIds) { if (NebulaModAPI.IsMultiplayerActive) { if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) { return; } } try { List <int> filteredIds = targetIds.Where(objId => { if (objId < 0) { int modelIndex = factory.prebuildPool[-objId].modelIndex; ModelProto modelProto = LDB.models.Select(modelIndex); return(modelProto != null); } if (objId > 0) { int modelIndex = factory.entityPool[objId].modelIndex; ModelProto modelProto = LDB.models.Select(modelIndex); return(modelProto != null); } return(false); }).ToList(); BlueprintData blueprint = UndoUtils.GenerateBlueprint(filteredIds, out Vector3 position); if (blueprint.buildings.Length > 0 && !position.Equals(Vector3.zero)) { PlayerUndo data = UndoManager.GetCurrentPlayerData(); data.AddUndoItem(new UndoDismantle(data, filteredIds, blueprint, new[] { position }, 0)); } } catch (Exception e) { BlueprintTweaksPlugin.logger.LogWarning($"Failed to generate undo for drag dismantle: {e.Message}, stacktrace:\n{e.StackTrace}"); } }
protected UndoAction(PlayerUndo undoData) { this.undoData = undoData; }
private void button10_Click(object sender, EventArgs e) { PlayerUndo?.Invoke(); FillCells(); WinnerDeclare(); }