-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed preloading of components so AutoFixer works again.
- Loading branch information
Showing
4 changed files
with
30 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using BattleTech; | ||
using BattleTech; | ||
using BattleTech.Data; | ||
using System; | ||
|
||
namespace CustomComponents | ||
{ | ||
class BTLoadUtils | ||
{ | ||
internal static void PreloadComponents(DataManager manager) | ||
internal static LoadRequest CreateLoadRequest(DataManager dataManager, Action<LoadRequest> loadCompleteCallback, bool filterByOwnership) | ||
{ | ||
var loadRequest = manager.CreateLoadRequest(); | ||
var loadRequest = dataManager.CreateLoadRequest(loadCompleteCallback, filterByOwnership); | ||
loadRequest.AddAllOfTypeLoadRequest<HeatSinkDef>(BattleTechResourceType.HeatSinkDef, null); | ||
loadRequest.AddAllOfTypeLoadRequest<UpgradeDef>(BattleTechResourceType.UpgradeDef, null); | ||
loadRequest.AddAllOfTypeLoadRequest<WeaponDef>(BattleTechResourceType.WeaponDef, null); | ||
loadRequest.AddAllOfTypeLoadRequest<AmmunitionBoxDef>(BattleTechResourceType.AmmunitionBoxDef, null); | ||
loadRequest.AddAllOfTypeLoadRequest<JumpJetDef>(BattleTechResourceType.AmmunitionBoxDef, null); | ||
loadRequest.ProcessRequests(); | ||
return loadRequest; | ||
} | ||
} | ||
} |
25 changes: 9 additions & 16 deletions
25
source/Fixes/SimGameState_RequestDataManagerResources_Patch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using BattleTech; | ||
using BattleTech; | ||
using BattleTech.Data; | ||
using Harmony; | ||
using System.Collections.Generic; | ||
|
||
namespace CustomComponents.Fixes | ||
{ | ||
[HarmonyPatch(typeof(SimGameState), "RequestDataManagerResources")] | ||
public static class SimGameState_RequestDataManagerResources_Patch | ||
{ | ||
[HarmonyPrefix] | ||
public static void Preload(SimGameState __instance) | ||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
try | ||
{ | ||
BTLoadUtils.PreloadComponents(__instance.DataManager); | ||
} | ||
catch (Exception e) | ||
{ | ||
Control.LogError(e); | ||
} | ||
|
||
return instructions | ||
.MethodReplacer( | ||
AccessTools.Method(typeof(DataManager), nameof(DataManager.CreateLoadRequest)), | ||
AccessTools.Method(typeof(BTLoadUtils), nameof(BTLoadUtils.CreateLoadRequest)) | ||
); | ||
} | ||
} | ||
} |
18 changes: 8 additions & 10 deletions
18
source/Fixes/SkirmishMechBayPanel_RequestResources_Patch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
using System; | ||
using BattleTech.Data; | ||
using BattleTech.UI; | ||
using Harmony; | ||
using System.Collections.Generic; | ||
|
||
namespace CustomComponents | ||
{ | ||
[HarmonyPatch(typeof(SkirmishMechBayPanel), "RequestResources")] | ||
public static class SkirmishMechBayPanel_RequestResources_Patch | ||
{ | ||
public static void Prefix(SkirmishMechBayPanel __instance) | ||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
try | ||
{ | ||
BTLoadUtils.PreloadComponents(__instance.dataManager); | ||
} | ||
catch (Exception e) | ||
{ | ||
Control.LogError(e); | ||
} | ||
return instructions | ||
.MethodReplacer( | ||
AccessTools.Method(typeof(DataManager), nameof(DataManager.CreateLoadRequest)), | ||
AccessTools.Method(typeof(BTLoadUtils), nameof(BTLoadUtils.CreateLoadRequest)) | ||
); | ||
} | ||
} | ||
} |
18 changes: 8 additions & 10 deletions
18
source/Fixes/SkirmishSettings_Beta_LoadLanceConfiguratorData_Patch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
using System; | ||
using BattleTech.Data; | ||
using BattleTech.UI; | ||
using Harmony; | ||
using System.Collections.Generic; | ||
|
||
namespace CustomComponents | ||
{ | ||
[HarmonyPatch(typeof(SkirmishSettings_Beta), "LoadLanceConfiguratorData")] | ||
public static class SkirmishSettings_Beta_LoadLanceConfiguratorData_Patch | ||
{ | ||
public static void Prefix(SkirmishSettings_Beta __instance, UIManager ___uiManager) | ||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
try | ||
{ | ||
BTLoadUtils.PreloadComponents(___uiManager.dataManager); | ||
} | ||
catch (Exception e) | ||
{ | ||
Control.LogError(e); | ||
} | ||
return instructions | ||
.MethodReplacer( | ||
AccessTools.Method(typeof(DataManager), nameof(DataManager.CreateLoadRequest)), | ||
AccessTools.Method(typeof(BTLoadUtils), nameof(BTLoadUtils.CreateLoadRequest)) | ||
); | ||
} | ||
} | ||
} |