Skip to content

Commit

Permalink
BT 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Denadan committed Feb 1, 2019
1 parent 6f7a8a4 commit db4c33c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 8 deletions.
6 changes: 6 additions & 0 deletions source/CCLight/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ internal static bool Is<T>(object target)

internal static string Identifier(object target)
{
if (target == null)
{
Control.Logger.LogError("Error - requested identifier for null!");
return string.Empty;
}

// this is for faster access
if (target is MechComponentDef mechComponentDef)
{
Expand Down
2 changes: 1 addition & 1 deletion source/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void Init(string directory, string settingsJSON)
Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
Validator.RegisterMechValidator(CategoryController.ValidateMech, CategoryController.ValidateMechCanBeFielded);

Logger.Log("Loaded CustomComponents v0.9.1.0 for bt 1.3.2");
Logger.Log("Loaded CustomComponents v0.9.1.1 for bt 1.4");
#if CCDEBUG
Logger.LogDebug("Loading Categories");
#endif
Expand Down
6 changes: 4 additions & 2 deletions source/CustomComponents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\BattleTech_Data\Managed\0Harmony.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\ModTek\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\BattleTech_Data\Managed\Assembly-CSharp.dll</HintPath>
Expand Down Expand Up @@ -88,8 +87,11 @@
<Compile Include="Components\ChassisDefaults.cs" />
<Compile Include="Components\TagColorComponent.cs" />
<Compile Include="DEBUGTOOLS\MechDef_RefreshInventory.cs" />
<Compile Include="Fixes\BTLoadUtils.cs" />
<Compile Include="Fixes\MechDef_InsertFixedEquipmentIntoInventory.cs" />
<Compile Include="Fixes\SimGameState_CreateComponentInstallWorkOrder.cs" />
<Compile Include="Fixes\SkirmishMechBayPanel_RequestResources_Patch.cs" />
<Compile Include="Fixes\SkirmishSettings_Beta_LoadLanceConfiguratorData_Patch.cs" />
<Compile Include="Helpers\DefaultFixer.cs" />
<Compile Include="Interfaces\IAdjustDescription.cs" />
<Compile Include="Interfaces\IDefault.cs" />
Expand Down
21 changes: 21 additions & 0 deletions source/Fixes/BTLoadUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using BattleTech;
using BattleTech.Data;

namespace CustomComponents
{
class BTLoadUtils
{
internal static void PreloadComponents(DataManager manager)
{
var loadRequest = manager.CreateLoadRequest();
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.ProcessRequests();
}
}
}
22 changes: 22 additions & 0 deletions source/Fixes/SkirmishMechBayPanel_RequestResources_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using BattleTech.UI;
using Harmony;

namespace CustomComponents
{
[HarmonyPatch(typeof(SkirmishMechBayPanel), "RequestResources")]
public static class SkirmishMechBayPanel_RequestResources_Patch
{
public static void Prefix(SkirmishMechBayPanel __instance)
{
try
{
BTLoadUtils.PreloadComponents(__instance.dataManager);
}
catch (Exception e)
{
Control.Logger.LogError(e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using BattleTech.UI;
using Harmony;

namespace CustomComponents
{
[HarmonyPatch(typeof(SkirmishSettings_Beta), "LoadLanceConfiguratorData")]
public static class SkirmishSettings_Beta_LoadLanceConfiguratorData_Patch
{
public static void Prefix(SkirmishSettings_Beta __instance, UIManager ___uiManager)
{
try
{
BTLoadUtils.PreloadComponents(___uiManager.dataManager);
}
catch (Exception e)
{
Control.Logger.LogError(e);
}
}
}
}
8 changes: 4 additions & 4 deletions source/Helpers/DefaultFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ public static void FixMech(MechDef mechDef, SimGameState state)
Control.Logger.LogDebug($"---- {changed_deafult[i]}");
#endif

if (Control.Settings.FixWrongDefaults)
{
CategoryController.RemoveExcessDefaults(mechDef);
}
//if (Control.Settings.FixWrongDefaults)
//{
// CategoryController.RemoveExcessDefaults(mechDef);
//}
}

public static MechComponentRef GetReplaceFor(MechDef mech, string categoryId, ChassisLocations location, SimGameState state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CustomComponents.Patches
{
[HarmonyPatch(typeof(SkirmishSettings_Beta), "LanceConfiguratorDataLoaded")]
[HarmonyPatch(typeof(SkirmishSettings_Beta), "OnLoadComplete")]
public class SkirmishSettings_Beta_LanceConfiguratorDataLoaded
{
[HarmonyPrefix]
Expand Down

0 comments on commit db4c33c

Please sign in to comment.