Skip to content

Commit

Permalink
- Update to modtek / CC icon loading via DataManager
Browse files Browse the repository at this point in the history
  • Loading branch information
IceRaptor committed Feb 4, 2020
1 parent 9598355 commit 235ad40
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
9 changes: 5 additions & 4 deletions SkillBasedInit/SkillBasedInit/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace SkillBasedInit {

public static class ModIcons {
public const string Stopwatch = "@sbi_stopwatch";
}

public static class ModStats {

}
Expand All @@ -18,6 +14,11 @@ public class ModConfig {
// If true, all the logs will be printed
public bool Trace = false;

public class IconOpts {
public string Stopwatch = "sbi_stopwatch";
}
public IconOpts Icons = new IconOpts { };

// The init malus when a unit starts the round prone (from a knockdown)
public int ProneModifier = -9;

Expand Down
4 changes: 2 additions & 2 deletions SkillBasedInit/SkillBasedInit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.1.0")]
[assembly: AssemblyFileVersion("0.8.1.0")]
[assembly: AssemblyVersion("0.8.2.0")]
[assembly: AssemblyFileVersion("0.8.2.0")]
4 changes: 2 additions & 2 deletions SkillBasedInit/SkillBasedInit/SkillBasedInit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
</Reference>
<Reference Include="CustomComponents, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\..\Steam\steamapps\common\BATTLETECH\Mods\CustomComponents\CustomComponents.dll</HintPath>
<HintPath>E:\steam\SteamApps\common\BATTLETECH\Mods\CustomComponents\CustomComponents.dll</HintPath>
</Reference>
<Reference Include="IRBTModUtils">
<HintPath>..\..\..\IRBTModUtils\IRBTModUtils\IRBTModUtils\bin\Debug\IRBTModUtils.dll</HintPath>
</Reference>
<Reference Include="MechEngineer, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\..\Steam\steamapps\common\BATTLETECH\Mods\MechEngineer\MechEngineer.dll</HintPath>
<HintPath>E:\steam\SteamApps\common\BATTLETECH\Mods\MechEngineer\MechEngineer.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
13 changes: 13 additions & 0 deletions SkillBasedInit/SkillBasedInit/patches/CombatGameStatePatches.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
using BattleTech;
using BattleTech.Data;
using Harmony;
using SVGImporter;

namespace SkillBasedInit.patches {

[HarmonyPatch(typeof(CombatGameState), "_Init")]
public static class CombatGameState__Init {
public static void Postfix(CombatGameState __instance) {
Mod.Log.Trace("CGS:_I entered.");
Mod.Log.Debug("Caching CombatGameState");
ModState.Combat = __instance;

// Pre-load our required icons, otherwise DM will unload them as they aren't necessary
DataManager dm = UnityGameInstance.BattleTechGame.DataManager;
LoadRequest loadRequest = dm.CreateLoadRequest();

// Need to load each unique icon
Mod.Log.Info("LOADING EFFECT ICONS...");
loadRequest.AddLoadRequest<SVGAsset>(BattleTechResourceType.SVGAsset, Mod.Config.Icons.Stopwatch, null);
loadRequest.ProcessRequests();
Mod.Log.Info(" ICON LOADING COMPLETE!");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BattleTech;
using BattleTech.Data;
using BattleTech.UI;
using Harmony;
using HBS;
Expand All @@ -25,10 +26,8 @@ public static void Postfix(CombatHUDStatusPanel __instance) {
Type[] iconMethodParams = new Type[] { typeof(SVGAsset), typeof(Text), typeof(Text), typeof(Vector3), typeof(bool) };
Traverse showBuffIconMethod = Traverse.Create(__instance).Method("ShowBuff", iconMethodParams);

Traverse svgAssetT = Traverse.Create(__instance.DisplayedCombatant.Combat.DataManager).Property("SVGCache");
object svgCache = svgAssetT.GetValue();
Traverse svgCacheT = Traverse.Create(svgCache).Method("GetAsset", new Type[] { typeof(string) });
SVGAsset icon = svgCacheT.GetValue<SVGAsset>(new object[] { ModIcons.Stopwatch });
DataManager dm = __instance.DisplayedCombatant.Combat.DataManager;
SVGAsset icon = dm.GetObjectOfType<SVGAsset>(Mod.Config.Icons.Stopwatch, BattleTechResourceType.SVGAsset);
showBuffIconMethod.GetValue(new object[]
{ icon, new Text(Mod.Config.LocalizedText[ModConfig.LT_TT_TITLE]), new Text(BuildTooltipText(actor)), __instance.effectIconScale, false }
);
Expand Down
16 changes: 6 additions & 10 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
{
"Name": "SkillBasedInit",
"Enabled": true,
"Version": "0.8.1",
"Version": "0.8.2",
"Description": "Changes the initiative system to be pilot-skill focused.",
"Author": "IceRaptor",
"Website": "https://github.com/IceRaptor/SkillBasedInit",
"Contact": "",
"DLL": "SkillBasedInit.dll",
"DependsOn" : [ "IRBTModUtils", "CustomComponents", "MechEngineer" ],
"CustomResourceTypes": [ "CustomSVGIcon" ],
"Manifest": [
{
"Type": "CustomSVGIcon",
"Path": "icons/",
"ShouldMergeJSON": false
}
],
"Manifest": [ { "Type": "SVGAsset", "Path": "icons/",} ],
"Settings": {
"Debug" : true,
"Debug" : false,
"Trace" : false,
"Icons" : {
"Stopwatch" : "sbi_stopwatch"
},
"ProneModifier" : -9,
"ShutdownModifier" : -6,
"CrippledMovementModifier" : -13,
Expand Down

0 comments on commit 235ad40

Please sign in to comment.