示例#1
0
 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();
         }
     }
 }
示例#2
0
        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}");
            }
        }
示例#3
0
 protected UndoAction(PlayerUndo undoData)
 {
     this.undoData = undoData;
 }
示例#4
0
 private void button10_Click(object sender, EventArgs e)
 {
     PlayerUndo?.Invoke();
     FillCells();
     WinnerDeclare();
 }