public static void LogGameInstanceCanSave(GameInstance __instance, SaveReason reason)
        {
            List <string> debugLines = new List <string>();

            if ((__instance.Combat == null && __instance.Simulation == null) || __instance.IsMultiplayer)
            {
                debugLines.Add("Return FALSE, No instance of: ");
                debugLines.Add("combat: " + (__instance.Combat == null));
                debugLines.Add("simgame: " + (__instance.Simulation == null));
                debugLines.Add("or is multiplayer: " + __instance.IsMultiplayer);
            }

            if (__instance.SaveManager.GameInstanceSaves.Saving)
            {
                debugLines.Add("Return FALSE, is already Saving");
            }

            if (__instance.Combat != null)
            {
                debugLines.Add("CombatGameState.CanSave returns: " + __instance.Combat.CanSave(false));
            }

            debugLines.Add("SimGameState.CanSave returns: " + __instance.Simulation.CanSave(reason, false));

            Logger.Block(debugLines.ToArray(), MethodBase.GetCurrentMethod());
        }
示例#2
0
 static void Prefix(SaveReason reason, ref Dictionary <SaveReason, SlotGroup> ___mapping)
 {
     foreach (KeyValuePair <SaveReason, SlotGroup> _override in ModSettings.AutosaveMapping)
     {
         ___mapping[_override.Key] = _override.Value;
     }
 }
示例#3
0
 static void Postfix(GameInstance __instance, ref bool __result, SaveReason reason)
 {
     if (reason == SaveReason.MANUAL)
     {
         __result = false;
     }
 }
            public static void Postfix(ref GameInstance __instance, SaveReason reason, Contract __state)
            {
                if (reason != SaveReason.SIM_GAME_CONTRACT_ACCEPTED)
                {
                    return;
                }

                SimGameState simGame          = __instance.Simulation;
                Contract     selectedContract = __state;

                List <ContractData> contractData = new List <ContractData>();

                foreach (ContractData contract in Traverse.Create(simGame).Field("contractBits").GetValue <List <ContractData> >())
                {
                    Logger.Minimal("got me a contractBit");
                    Logger.Minimal("contract name: " + contract.conName);
                    if (selectedContract.Name == contract.conName)
                    {
                        Logger.Minimal("found contract: " + contract.conName);
                        contractData.Add(contract);
                    }
                }

                Traverse.Create(simGame).Field("globalContracts").SetValue(new List <Contract> {
                    selectedContract
                });
                Traverse.Create(simGame).Field("contractBits").SetValue(contractData);
            }
示例#5
0
 static void Postfix(GameInstanceSave __instance, GameInstance gameInstance, SaveReason saveReason)
 {
     try {
         Helper.SaveState(__instance.InstanceGUID, __instance.SaveTime);
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
 public static void Prefix(GameInstance __instance, SaveReason reason, out Contract __state)
 {
     if (reason != SaveReason.SIM_GAME_CONTRACT_ACCEPTED)
     {
         __state = null;
         return;
     }
     __state = __instance.Simulation.SelectedContract;
 }
示例#7
0
 static void Postfix(GameInstanceSave __instance, GameInstance gameInstance, SaveReason saveReason)
 {
     try {
         Helper.SaveState(__instance.InstanceGUID, __instance.SaveTime);
         if (Fields.Deployment)
         {
             gameInstance.Simulation.CurSystem.SystemContracts.Clear();
             gameInstance.Simulation.CurSystem.SystemContracts.AddRange(Fields.DeploymentContracts.Values);
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
示例#8
0
 public static void Postfix(SaveReason reason, SlotGroup __result)
 {
     if (ModSettings.AutosaveMapping.ContainsKey(reason))
     {
         if (ModSettings.AutosaveMapping[reason] != __result)
         {
             Logger.InfoLine(MethodBase.GetCurrentMethod());
             Logger.Minimal("Reason: " + reason);
             Logger.Minimal("SlotGroup expected: " + ModSettings.AutosaveMapping[reason]);
             Logger.Minimal("SlotGroup Actual: " + __result);
             Logger.EndLine();
         }
     }
 }
示例#9
0
        static void Postfix(SlotModel __instance, ref string __result)
        {
            if (Helper.IsIronManCampaign(__instance))
            {
                return;
            }

            __result = "S.O.L. ";

            SaveReason saveReason      = __instance.SaveReason;
            var        autosaveMapping = ModSettings.AutosaveMapping;

            if (autosaveMapping.ContainsKey(saveReason))
            {
                __result += (autosaveMapping[saveReason] == ModSettings.COMBATGAME_SAVES_GROUP) ?
                            "Combat Autosave" : "Sim Autosave";
            }
        }
示例#10
0
    public static bool Save(BalloonSpawner spawner, ConfigPopup configPopup, BalloonSound sound, Data data,
                            SaveReason sr)
    {
        // 에디터에서 간혹 게임 플레이 시작할 때 Load도 호출되기도 전에 Save가 먼저 호출되기도 한다.
        // (OnApplicationPause 통해서)
        // 실제 기기에서도 이럴 수 있나? 이러면 망인데...
        // 그래서 플래그를 하나 추가한다. 이 플래그는 로드가 제대로 한번 됐을 때 true로 변경된다.
        if (spawner.loadedAtLeastOnce == false)
        {
            Debug.LogWarning(
                "****** Save() called before first Load(). There might be an error during Load(). Save() will be skipped to prevent losing your save data.");
            return(false);
        }

        var balloonSaveData2 = new BalloonSaveData2();

        SushiDebug.LogFormat("Saving...");
        balloonSaveData2.version = LatestVersion;

        return(SaveBalloonSaveData2(balloonSaveData2));
    }
示例#11
0
        public static void SimGameOptionsMenu_CanSave_Postfix(GameInstance gameInstance, SaveReason saveReason, bool ironmanPreventsSave, bool logDetails, ref bool __result)
        {
            CombatGameState combatGameState = UnityGameInstance.BattleTechGame.Combat;

            if (combatGameState != null && !combatGameState.TurnDirector.IsMissionOver && combatGameState.TurnDirector.GameHasBegun)
            {
                Mod.Log.Trace("SGOM:CS - in combat.");
                __result = false;
            }
            else
            {
                Mod.Log.Trace("SGOM:CS - outside of combat.");
            }
        }
示例#12
0
        public static void SimGameOptionsMenu_SetSaveTooltip_Postfix(SimGameOptionsMenu __instance, HBSTooltipHBSButton ___saveTooltip, SaveReason ___reason, HBSDOTweenButton ___saveGame)
        {
            if (___saveTooltip == null)
            {
                return;
            }

            GameInstance    battleTechGame = UnityGameInstance.BattleTechGame;
            CombatGameState combat         = battleTechGame.Combat;

            if (combat != null && !combat.TurnDirector.IsMissionOver && combat.TurnDirector.GameHasBegun)
            {
                string             details = "Saving during combat missions disabled to prevent errors and bugs.";
                BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", "Unable to Save", details, null);
                ___saveTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
            }
        }