public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
        {
            if (__instance.CompanyStats.ContainsStatistic("BtSaveEdit.Version"))
            {
                string value = __instance.CompanyStats.GetValue <string>("BtSaveEdit.Version");
                SimGameState.logger.Log(string.Format("The save for this career/campaign has been edited by Save Editor version: {0}", (object)value));

                if (__instance.CompanyStats.ContainsStatistic("BtSaveEdit.LogCount"))
                {
                    int logCount = __instance.CompanyStats.GetValue <int>("BtSaveEdit.LogCount");
                    if (logCount > 0)
                    {
                        SimGameState.logger.Log("Most recent save edits:");
                        for (int i = 0; i < logCount; i++)
                        {
                            if (__instance.CompanyStats.ContainsStatistic(string.Format("BtSaveEdit.LogItem{0}", (object)i)))
                            {
                                string log = __instance.CompanyStats.GetValue <string>(string.Format("BtSaveEdit.LogItem{0}", (object)i));
                                SimGameState.logger.Log(string.Format("{0}: {1}", (object)i, (object)log));
                            }
                        }
                    }
                }
            }
        }
            public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
            {
                SimGameSave save = gameInstanceSave.SimGameSave;


                if (!save.GlobalReferences.HasItem(ModSettings.MOD_SAVE_REFERENCECONTAINER_KEY))
                {
                    return;
                }

                Contract selectedContract = save.GlobalReferences.GetItem <Contract>(ModSettings.MOD_SAVE_REFERENCECONTAINER_KEY);

                if (selectedContract == null)
                {
                    return;
                }
                // __instance.SetSelectedContract(selectedContract);

                //Traverse.Create(__instance).Field("activeBreadcrumb").SetValue(selectedContract);
                Logger.Minimal("loaded selected Contract: " + selectedContract.Name);
                Logger.Minimal("selected contract accepted: " + selectedContract.Accepted);
                Logger.Minimal("selected contract can negogiate : " + selectedContract.CanNegotiate);
                Logger.Minimal("selected contract carry over negotiate values : " + selectedContract.CarryOverNegotationValues);
                Logger.Minimal("selected contract cbills: " + selectedContract.PercentageContractValue);
                Logger.Minimal("selected contract salvage: " + selectedContract.PercentageContractSalvage);
                Logger.Minimal("selected contract rep: " + selectedContract.PercentageContractReputation);
                //__instance.PrepareBreadcrumb(selectedContract);
                selectedContract.Accept(true);
            }
Exemplo n.º 3
0
 public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     if (BiggerDrops.settings.allowUpgrades)
     {
         BiggerDrops.settings.setCompanyStats(__instance.CompanyStats);
     }
 }
Exemplo n.º 4
0
 public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     if (DropManagement.settings.allowUpgrades)
     {
         DropManagement.settings.setCompanyStats(__instance.CompanyStats);
     }
 }
Exemplo n.º 5
0
        static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
        {
            LogDebug("Rehydrate");
            var sim = UnityGameInstance.BattleTechGame.Simulation;

            if (sim.IsCampaign && !sim.CompanyTags.Contains("story_complete"))
            {
                LogDebug("Aborting GaW loading");
                return;
            }

            try
            {
                if (__instance.CompanyTags.Any(tag => tag.StartsWith("GalaxyAtWarSave")))
                {
                    DeserializeWar();
                    RebuildState();
                }
                else
                {
                    LogDebug("Spawning new instance");
                    Core.WarStatus = new WarStatus();
                    Core.SystemDifficulty();
                    Core.WarTick(true, true);
                }
            }
            catch (Exception ex)
            {
                LogDebug(ex);
            }
        }
Exemplo n.º 6
0
        public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
        {
            PilotAffinityManager.Instance.setCompanyStats(__instance.CompanyStats);
            PilotAffinityManager.Instance.setDataManager(__instance.DataManager);

            PilotQuirkManager.Instance.setCompanyStats(__instance.CompanyStats);

            List <MechDef> mechs = __instance.DataManager.MechDefs.Select(pair => pair.Value).ToList();

            foreach (MechDef mech in mechs)
            {
                PilotAffinityManager.Instance.addToChassisPrefabLut(mech);
            }

            if (Main.settings.enablePilotQuirks)
            {
                foreach (Pilot pilot in __instance.PilotRoster.ToList())
                {
                    PilotQuirkManager.Instance.proccessPilot(pilot.pilotDef, true);
                    pilot.FromPilotDef(pilot.pilotDef);
                }
                // the commander is not part of the roster, so need to specifically call it.
                PilotQuirkManager.Instance.proccessPilot(__instance.Commander.pilotDef, true);
                __instance.Commander.FromPilotDef(__instance.Commander.pilotDef);
            }
        }
        public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave,
                                   ref List <Contract> ___globalContracts)
        {
            SimGameSave save = gameInstanceSave.SimGameSave;

            if (!save.GlobalReferences.HasItem(ModSettings.MOD_SAVE_REFERENCECONTAINER_KEY))
            {
                return;
            }

            Contract selectedContract = save.GlobalReferences.GetItem <Contract>(ModSettings.MOD_SAVE_REFERENCECONTAINER_KEY);

            if (selectedContract == null)
            {
                return;
            }

            //LanceConfiguration lastLance = Traverse.Create(__instance).Method("GetLastLance").GetValue<LanceConfiguration>();
            //selectedContract.SetLanceConfiguration(lastLance);
            //selectedContract.Override.disableLanceConfiguration = false;

            selectedContract.Override.disableNegotations  = true;
            selectedContract.Override.disableCancelButton = true;
            selectedContract.Override.negotiatedSalary    = selectedContract.PercentageContractValue;
            selectedContract.Override.negotiatedSalvage   = selectedContract.PercentageContractSalvage;

            __instance.SetSelectedContract(selectedContract);
        }
Exemplo n.º 8
0
 static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     if (!__instance.CompanyTags.Contains("AbilifierLoaded"))
     {
         __instance.CompanyTags.Add("AbilifierLoaded");
     }
 }
        private static void Prefix(SimGameState __instance, GameInstanceSave gameInstanceSave)
        {
            // check the consumed milestones in the save file, and reset the save file's difficulty according to the highest milestone trigger
            StaticSystemSkulls.Log("Validating save file global difficulty...");
            float         currentDiff = gameInstanceSave.SimGameSave.CompanyStats.GetValue <float>("Difficulty");
            float         newDiff     = 1;
            List <string> consumed    = gameInstanceSave.SimGameSave.ConsumedMilestones;

            for (int idx = m_milestones.Count - 1; idx >= 0; idx--)
            {
                if (consumed.Contains(m_milestones.Values[idx]))
                {
                    StaticSystemSkulls.Log("  last critical story milestone " + m_milestones.Values[idx].ToString() + " " + m_milestones.Keys[idx].ToString());
                    newDiff = m_milestones.Keys[idx];
                    break;
                }
            }

            if (currentDiff != newDiff)
            {
                gameInstanceSave.SimGameSave.CompanyStats.Set("Difficulty", newDiff);
                StaticSystemSkulls.Log(string.Format("  reset global difficulty from {0} to {1}.", currentDiff, newDiff));
            }
            else
            {
                StaticSystemSkulls.Log("  no global difficulty change required.");
            }
        }
Exemplo n.º 10
0
        public static void LoadFlareups(GameInstanceSave gameInstanceSave, SimGameState __instance)
        {
            try {
                WIIC.sim = __instance;
                WIIC.modLog.Debug?.Write("Loading Flareups");
                WIIC.flareups.Clear();
                WIIC.sim.CompanyTags.Add("WIIC_enabled");

                WIIC.readFromJson("WIIC_ephemeralSystemControl.json", true);

                foreach (StarSystem system in __instance.StarSystems)
                {
                    string tag = system.Tags.ToList().Find(Flareup.isSerializedFlareup);
                    if (tag != null)
                    {
                        system.Tags.Remove(tag);

                        Flareup flareup = Flareup.Deserialize(tag);
                        WIIC.flareups[system.ID] = flareup;
                    }

                    tag = system.Tags.ToList().Find(Utilities.isControlTag);
                    if (tag != null)
                    {
                        system.Tags.Remove(tag);
                        WIIC.systemControl[system.ID] = tag;
                    }
                }

                WIIC.modLog.Debug?.Write($"Loaded {WIIC.flareups.Keys.Count} flareups and {WIIC.systemControl.Keys.Count} system control tags");
                Utilities.redrawMap();
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
Exemplo n.º 11
0
 static void Postfix(GameInstanceSave __instance, GameInstance gameInstance, SaveReason saveReason)
 {
     try {
         Helper.SaveState(__instance.InstanceGUID, __instance.SaveTime);
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Exemplo n.º 12
0
 static void Prefix(GameInstanceSave save)
 {
     try {
         Helper.LoadState(save.InstanceGUID, save.SaveTime);
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Exemplo n.º 13
0
            public static void Postfix(GameInstanceSave save)
            {
                if (!modSettings.SaveState)
                {
                    return;
                }

                fileID = save.FileID;
            }
                public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
                {
                    SimGameSave save = gameInstanceSave.SimGameSave;

                    List <string> debugLines = new List <string>();

                    if (save.ActiveContractName != null)
                    {
                        Logger.Minimal("active contract not null");
                        __instance.SetSelectedContract(save.GlobalContracts[0]);
                    }
                }
 static void Postfix(GameInstanceSave __instance)
 {
     try
     {
         Holder.SerializeStorageJson(__instance.InstanceGUID, __instance.SaveTime);
     }
     catch
     {
         // TODO: should do something here if the holder reports an error trying to serialize
         return;
     }
 }
 static void Prefix(GameInstance __instance, GameInstanceSave save)
 {
     try
     {
         Holder.Resync(save.SaveTime);
     }
     catch
     {
         // TODO: should do something here if the holder reports an error trying to serialize
         return;
     }
 }
Exemplo n.º 17
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);
     }
 }
Exemplo n.º 18
0
            static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
            {
                var sim = UnityGameInstance.BattleTechGame.Simulation;

                if (Main.Settings.DependsOnArgoUpgrade && !sim.PurchasedArgoUpgrades.Contains(Main.Settings.ArgoUpgrade))
                {
                    return;
                }

                if (sim.CompanyTags.Any(x => x.StartsWith("SOSAVE{")))
                {
                    DeserializeSO();
                }
            }
Exemplo n.º 19
0
        static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
        {
            try {
                if (__instance.HasTravelContract && Fields.warmission)
                {
                    __instance.GlobalContracts.Add(__instance.ActiveTravelContract);
                }
                foreach (Contract contract in __instance.GlobalContracts)
                {
                    contract.Override.contractDisplayStyle = ContractDisplayStyle.BaseCampaignStory;
                    int maxPriority = Mathf.FloorToInt(7 / __instance.Constants.Salvage.PrioritySalvageModifier);
                    contract.Override.salvagePotential  = Mathf.Min(maxPriority, Mathf.RoundToInt(contract.SalvagePotential * Fields.settings.priorityContactPayPercentage));
                    contract.Override.negotiatedSalvage = 1f;
                }
                //tags:

                /* FundsAddedAction = 'BtSaveEdit.FundsAdded'
                 * InventoryAddedAction = 'BtSaveEdit.InventoryAdded'
                 * InventoryDeletedAction = 'BtSaveEdit.InventoryDeleted'
                 * PilotChangedAction = 'BtSaveEdit.PilotChanged'
                 * ReputationChangedAction = 'BtSaveEdit.ReputationChanged'
                 * SaveCleanedAction = 'BtSaveEdit.SaveCleaned'
                 * StarSystemsDeletedAction = 'BtSaveEdit.StarSystemsDeleted'
                 * ContractsDeletedAction = 'BtSaveEdit.ContractsDeleted'
                 * MechsRemovedAction = 'BtSaveEdit.MechsRemoved'
                 * MechsAddedAction = 'BtSaveEdit.MechsAdded'
                 * BlackMarketChangedAction = 'BtSaveEdit.BlackMarketAccessChanged'
                 * CompanyTagsChangedAction = 'BtSaveEdit.CompanyTagsChanged'
                 * StarSystemWarpAction = 'BtSaveEdit.ChangedCurrentStarSystem'*/
                List <string> saveedits = new List <string>()
                {
                    "BtSaveEdit.FundsAdded", "BtSaveEdit.InventoryAdded", "BtSaveEdit.ReputationChanged",
                    "BtSaveEdit.MechsAdded"
                };
                foreach (string cheat in saveedits)
                {
                    if (__instance.CompanyStats.ContainsStatistic(cheat))
                    {
                        Fields.cheater = true;
                        SimGameInterruptManager interruptQueue = (SimGameInterruptManager)AccessTools.Field(typeof(SimGameState), "interruptQueue").GetValue(__instance);
                        interruptQueue.QueueGenericPopup_NonImmediate("Save Edited!", "You have edited your save file in a way that disqualifies you from the war game, your missions wont be influenceing the war. All other fucntions work as normally.", true);
                        break;
                    }
                }
            }
            catch (Exception e) {
                PersistentMapClient.Logger.LogError(e);
            }
        }
Exemplo n.º 20
0
 static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     try {
         foreach (Contract contract in __instance.GlobalContracts)
         {
             contract.Override.contractDisplayStyle = ContractDisplayStyle.BaseCampaignStory;
             int maxPriority = Mathf.FloorToInt(7 / __instance.Constants.Salvage.PrioritySalvageModifier);
             contract.Override.salvagePotential  = Mathf.Min(maxPriority, Mathf.RoundToInt(contract.SalvagePotential * Fields.settings.priorityContactPayPercentage));
             contract.Override.negotiatedSalvage = 1f;
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Exemplo n.º 21
0
            static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
            {
                if (!__instance.CompanyTags.Contains("BTR_BugFix_LocustFPFixed") && __instance.CompanyTags.Contains("fp_legUp_kickingTheNest_Complete") &&
                    !__instance.CompanyTags.Contains("company_blackMarket_ON"))
                {
                    if (__instance.CompanyTags.Contains("company_blackMarket_OFF"))
                    {
                        __instance.CompanyTags.Remove("company_blackMarket_OFF");
                    }
                }

                if (!__instance.CompanyTags.Contains("BTR_BugFix_LocustFPFixed"))
                {
                    __instance.CompanyTags.Add("BTR_BugFix_LocustFPFixed");
                }
            }
Exemplo n.º 22
0
            static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
            {
                bool NewPQ = true;

                foreach (string tag in __instance.CompanyTags)
                {
                    if (tag.StartsWith("PilotQuirksSave{"))
                    {
                        NewPQ = false;
                    }
                }
                if (!NewPQ)
                {
                    DeserializePilotQuirks();
                    CheckForDuplicateTattoos();
                }
            }
Exemplo n.º 23
0
        public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave, ref List <string> ___ignoredContractTargets)
        {
            var save = gameInstanceSave.SimGameSave;

            if (save.IgnoredContractTargets == null)
            {
                return;
            }
            ___ignoredContractTargets = new List <string>();
            foreach (var factionID2 in save.IgnoredContractTargets)
            {
                var factionValue = FactionEnumeration.GetFactionByID(factionID2);
                if (!factionValue.IsCareerIgnoredContractTarget)
                {
                    Mod.Log.Info?.Write($"FactionValueFix: {factionValue.Name} is no longer IsCareerIgnoredContractTarget = true, removing from ignoredContractTargets.");
                    ___ignoredContractTargets.RemoveAll(x => x == factionValue.Name);
                }
            }
        }
Exemplo n.º 24
0
        public static void LoadShops(GameInstanceSave gameInstanceSave, SimGameState __instance)
        {
            Control.State.CurrentSystem = __instance.CurSystem;
            Control.State.Sim           = __instance;

            SerializableReferenceContainer globalReferences = gameInstanceSave.GlobalReferences;

            Control.LogDebug(DInfo.SaveLoad, "Loading Shops");
            foreach (var shop in Control.Shops)
            {
                if (shop is ISaveShop save)
                {
                    var name = "Shop" + shop.Name;
                    Control.LogDebug(DInfo.SaveLoad, "- " + shop.Name);
                    try
                    {
                        var Shop = globalReferences.GetItem <Shop>(name);
                        save.SetLoadedShop(Shop);

                        Control.LogDebug(DInfo.SaveLoad, "-- " + shop.Name + " Loaded");
                        Control.LogDebug(DInfo.SaveLoad, $"-- total {Shop.ActiveInventory.Count} items");
                    }
                    catch (Exception)
                    {
                        Control.LogError($"Error finding {name} Create new");
                        shop.RefreshShop();
                        Control.LogDebug(DInfo.SaveLoad, "-- total " + save.GetShopToSave().ActiveInventory.Count + " items");
                    }
                }
                else
                {
                    shop.RefreshShop();
                }
            }

            //Control.Log($"Hated: {__instance.Constants.Story.HatedRepShopAdjustment}");
            //Control.Log($"Disliked: {__instance.Constants.Story.DislikedRepShopAdjustment}");
            //Control.Log($"Indifferent: {__instance.Constants.Story.IndifferentRepShopAdjustment}");
            //Control.Log($"Liked: {__instance.Constants.Story.LikedRepShopAdjustment}");
            //Control.Log($"Friendly: {__instance.Constants.Story.FriendlyRepShopAdjustment}");
            //Control.Log($"Honored: {__instance.Constants.Story.HonoredRepShopAdjustment}");
        }
Exemplo n.º 25
0
 static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     try {
         if (Fields.Deployment)
         {
             Fields.DeploymentContracts = new Dictionary <string, Contract>();
             foreach (Contract contract in __instance.CurSystem.SystemContracts)
             {
                 contract.Override.salvagePotential   = Fields.DeploymentSalvage;
                 contract.Override.disableNegotations = true;
                 SimGameEventResult  simGameEventResult  = new SimGameEventResult();
                 SimGameResultAction simGameResultAction = new SimGameResultAction();
                 int num2 = 11;
                 simGameResultAction.Type                 = SimGameResultAction.ActionType.System_StartNonProceduralContract;
                 simGameResultAction.value                = contract.mapName;
                 simGameResultAction.additionalValues     = new string[num2];
                 simGameResultAction.additionalValues[0]  = __instance.CurSystem.ID;
                 simGameResultAction.additionalValues[1]  = contract.mapPath;
                 simGameResultAction.additionalValues[2]  = contract.encounterObjectGuid;
                 simGameResultAction.additionalValues[3]  = contract.Override.ID;
                 simGameResultAction.additionalValues[4]  = (!contract.Override.useTravelCostPenalty).ToString();
                 simGameResultAction.additionalValues[5]  = Fields.DeploymentEmployer.ToString();
                 simGameResultAction.additionalValues[6]  = Fields.DeploymentTarget.ToString();
                 simGameResultAction.additionalValues[7]  = contract.Difficulty.ToString();
                 simGameResultAction.additionalValues[8]  = "true";
                 simGameResultAction.additionalValues[9]  = Fields.DeploymentEmployer.ToString();
                 simGameResultAction.additionalValues[10] = contract.Override.travelSeed.ToString();
                 simGameEventResult.Actions               = new SimGameResultAction[1];
                 simGameEventResult.Actions[0]            = simGameResultAction;
                 contract.Override.OnContractSuccessResults.Add(simGameEventResult);
                 if (!gameInstanceSave.HasCombatData)
                 {
                     AccessTools.Field(typeof(SimGameState), "activeBreadcrumb").SetValue(__instance, contract);
                 }
                 Fields.DeploymentContracts.Add(contract.Name, contract);
             }
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Exemplo n.º 26
0
 static void Prefix(GameInstanceSave save)
 {
     Helper.LoadState(save.InstanceGUID, save.SaveTime);
 }
Exemplo n.º 27
0
 static void Postfix(GameInstanceSave __instance)
 {
     Helper.SaveState(__instance.InstanceGUID, __instance.SaveTime);
 }
Exemplo n.º 28
0
 private static void Prefix(GameInstanceSave save) => Resync(save.SaveTime);
Exemplo n.º 29
0
 static void Rehydrate_Pre(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     gameInstanceSave.SimGameSave.AvailableFlashpointList.RemoveAll(item => item.Def == null);
 }
Exemplo n.º 30
0
 static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave)
 {
     DeserializeXXX();
 }