Skip to content

Commit

Permalink
Merge pull request #404 from CWolfs/develop
Browse files Browse the repository at this point in the history
v1.1.2
  • Loading branch information
CWolfs authored Jul 29, 2020
2 parents 29143b3 + 4e95469 commit 4306b47
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Mission Control",
"Enabled": true,
"Version": "1.1.1",
"Version": "1.1.2",
"Description": "A HBS BattleTech mod that adds custom contract types and varies the encounter specifics such as encounter boundary size, spawn locations, lance numbers and objectives",
"Author": "CWolf",
"Contact": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Data/LogicState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public void Set(string key, bool flag) {
}

public void Set(string key, List<string> keys) {
objectState.Add(key, keys);
objectState[key] = keys;
}

public void Set(string key, List<string[]> keys) {
objectState.Add(key, keys);
objectState[key] = keys;
}

public bool GetBool(string key) {
Expand Down
32 changes: 23 additions & 9 deletions src/Core/MissionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public static MissionControl Instance {

public bool IsContractValid { get; private set; } = false;
public bool IsMCLoadingFinished { get; set; } = false;
public bool IsLoadingFromSave { get; set; } = false;
public bool IsLoadingFromSave {
get {
if (UnityGameInstance.Instance.Game.Combat == null) return false;
return UnityGameInstance.Instance.Game.Combat.IsLoadingFromSave;
}
}

private Dictionary<string, List<Type>> AvailableEncounters = new Dictionary<string, List<Type>>();

Expand Down Expand Up @@ -247,14 +252,18 @@ public void SetActiveAdditionalLances(Contract contract) {
}

public void SetContractSettingsOverride() {
string contractId = CurrentContract.Override.ID;
string type = IsAnyFlashpointContract() ? "flashpoint" : "contract";
if (!IsSkirmish(CurrentContract)) {
string contractId = CurrentContract.Override.ID;
string type = IsAnyFlashpointContract() ? "flashpoint" : "contract";

if (Main.Settings.ContractSettingsOverrides.ContainsKey(contractId)) {
Main.Logger.Log($"[MissionControl] Setting a {type} MC settings override for '{contractId}'.");
Main.Settings.ActiveContractSettings = Main.Settings.ContractSettingsOverrides[contractId];
if (Main.Settings.ContractSettingsOverrides.ContainsKey(contractId)) {
Main.Logger.Log($"[MissionControl] Setting a {type} MC settings override for '{contractId}'.");
Main.Settings.ActiveContractSettings = Main.Settings.ContractSettingsOverrides[contractId];
} else {
Main.Logger.Log($"[MissionControl] No {type} MC settings override found for '{contractId}'.");
Main.Settings.ActiveContractSettings = new Config.ContractSettingsOverrides();
}
} else {
Main.Logger.Log($"[MissionControl] No {type} MC settings override found for '{contractId}'.");
Main.Settings.ActiveContractSettings = new Config.ContractSettingsOverrides();
}
}
Expand Down Expand Up @@ -463,8 +472,13 @@ public FactionDef GetFactionFromTeamType(string teamType) {
return null;
}

public bool AllowMissionControl() {
if (IsLoadingFromSave) return false;
public bool AllowMissionControl(bool SkipFromSaveCheck = false) {
if (CurrentContract == null) return false;

if (!SkipFromSaveCheck) {
if (IsLoadingFromSave) return false;
}

if (CurrentContract.IsStoryContract) return false;
if (CurrentContract.IsRestorationContract) return false;
if (!IsAnyFlashpointContract()) return true;
Expand Down
2 changes: 1 addition & 1 deletion src/MissionControl.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<OutputType>Library</OutputType>
<TargetFramework>net471</TargetFramework>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/Patches/ContractBeginPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace MissionControl.Patches {
public class ContractBeginPatch {
public static void Prefix(Contract __instance) {
if (!__instance.Accepted) return;
MissionControl.Instance.IsLoadingFromSave = UnityGameInstance.Instance.Game.Combat.IsLoadingFromSave;

PathFinderManager.Instance.FullReset();

Main.Logger.Log($"[ContractBeginPatch Postfix] Patching Begin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static bool IsIgnoredBundle(string bundleName) {
}

public static void Postfix(AssetBundleManager __instance, string assetName, string bundleName, ref GameObject __result) {
if (MissionControl.Instance.AllowMissionControl() && !IsIgnoredBundle(bundleName)) {
if (MissionControl.Instance.IsLoadingFromSave && MissionControl.Instance.AllowMissionControl(SkipFromSaveCheck: true) && !IsIgnoredBundle(bundleName)) {
if (__result == null) {
Main.LogDebug($"[AssetBundleManagerGetAssetFromBundlePatch Postfix] Final stage of trying to load an asset bundle. Attempted to recovery before critical failure.");
if (lookup.ContainsKey(assetName)) {
Expand Down

This file was deleted.

0 comments on commit 4306b47

Please sign in to comment.