diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 2a5d3f5..886758f 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -6,6 +6,7 @@ using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using UnityEngine; +using UnityEngine.UI; using UnityEngine.SceneManagement; using TNHQoLImprovements; @@ -33,18 +34,32 @@ public class MeatKitPlugin : BaseUnityPlugin #pragma warning disable 414 private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); #pragma warning restore 414 + public static AssetBundle bundle; public static Font fontAgencyFB; - public static ConfigEntry cfgShowLPC; + public static Font fontBombardier; + + public static GameObject playerCamera; + + // BepInEx configuration + //--- Health Counter ---// public static ConfigEntry cfgSolidifyHPText; public static ConfigEntry cfgShowHPBackground; public static ConfigEntry cfgHPBackgroundOpacity; + //--- Take and Hold Info ---// + public static ConfigEntry cfgShowLPC; public static ConfigEntry cfgShowTokens; public static ConfigEntry cfgShowHolds; + public static ConfigEntry cfgShowNumbersAtShop; + public static ConfigEntry cfgShowInfoOnGameOver; + public static ConfigEntry cfgShowWaves; + //--- Misc. ---// public static ConfigEntry cfgHealthCrystalIndicator; + // Take and Hold modifications private static InPlay instance; + // Searching for old leaderboards player count mod to disable private bool lpcModGone = false; private float lpcModSearchTimeEnd; @@ -52,14 +67,7 @@ public class MeatKitPlugin : BaseUnityPlugin private void SceneChanged(Scene from, Scene to) { - var healthCounter = FindObjectOfType(); - if (healthCounter != null) - { - if (cfgShowHPBackground.Value || cfgSolidifyHPText.Value) - HPReadability.ImproveHPTextReadability(healthCounter.transform.GetChild(0).gameObject); - } - - if(GameObject.Find("_GameManager") != null || FindObjectOfType() != null) + if (GameObject.Find("_GameManager") != null || FindObjectOfType() != null) { Logger.LogInfo("We are in a TNH game!"); instance = new GameObject().AddComponent(); @@ -69,6 +77,37 @@ public class MeatKitPlugin : BaseUnityPlugin Logger.LogInfo("We are NOT in a TNH game!"); Destroy(instance); } + + playerCamera = GameObject.FindGameObjectWithTag("MainCamera"); + + // apply health readability globally + var healthCounter = FindObjectOfType(); + if (healthCounter != null) + { + if (cfgShowHPBackground.Value || cfgSolidifyHPText.Value) + HPReadability.ImproveHPTextReadability(healthCounter.transform.GetChild(0).gameObject); + } + + // grab Agency FB from game if it's not set + if(fontAgencyFB == null) + { + if (healthCounter != null) + { + fontAgencyFB = healthCounter.transform.GetChild(0).GetChild(0).GetComponent().font; + } + else + { + var query = FindObjectsOfType(); + foreach (Text itm in query) + { + if (itm.font.name == "AGENCYR") + { + fontAgencyFB = itm.font; + break; + } + } + } + } } public MeatKitPlugin(): base() @@ -81,14 +120,17 @@ public class MeatKitPlugin : BaseUnityPlugin // MeatKit requirement LoadAssets(); - // get Agency FB from system - fontAgencyFB = Font.CreateDynamicFontFromOSFont("Agency FB", 16); + // get Agency FB from system (BAD IDEA, NOT EVERYONE WILL HAVE IT) + //fontAgencyFB = Font.CreateDynamicFontFromOSFont("Agency FB", 16); // load asset bundle bundle = AssetBundle.LoadFromFile(Path.Combine(BasePath, "tnh_qol_improvements")); SceneManager.activeSceneChanged += SceneChanged; + fontBombardier = MeatKitPlugin.bundle.LoadAsset("Bombardier"); + // setup configuration + //--- Health Counter ---// cfgShowHPBackground = Config.Bind("Health Counter", "Background enabled", true, @@ -101,6 +143,7 @@ public class MeatKitPlugin : BaseUnityPlugin "Solidify HP text", true, "Set opacity of HP text to full and give it a shadow."); + //--- Take and Hold Info ---// cfgShowLPC = Config.Bind("Take and Hold Info", "Show player count in online leaderboards", true, @@ -113,6 +156,19 @@ public class MeatKitPlugin : BaseUnityPlugin "Show Holds", true, "Shows how many holds the player has completed by their radar hand."); + cfgShowWaves = Config.Bind("Take and Hold Info", + "Show Waves", + true, + "Shows how many waves the player has completed on the current hold by their radar hand."); + cfgShowInfoOnGameOver = Config.Bind("Take and Hold Info", + "Show Extra Info at Game Over", + true, + "Show enabled extra game information at the game over area."); + cfgShowNumbersAtShop = Config.Bind("Take and Hold Info", + "Show Numbers for Tokens at Item Station", + true, + "At the item station, add a numberical representation to costs and player's tokens."); + //--- Misc. ---// cfgHealthCrystalIndicator = Config.Bind("Misc.", "Show expiration of Health Crystals", HealthExpireIndicationType.Flashing, @@ -139,16 +195,22 @@ public class MeatKitPlugin : BaseUnityPlugin if (cfgShowLPC.Value) LeaderboardPlayerCountPatch.Patch(harmony); - // for counting wins/loses + // for counting wins/loses for TNHInfo.holdCounter if (cfgShowHolds.Value) HoldCounterPatch.Patch(harmony); // stick stats to hand after game over if (cfgShowHolds.Value || cfgShowTokens.Value) InPlay.Patch(harmony); - - WavePatch.Patch(harmony); - ShopCostPatch.Patch(harmony); + + // show numerical representation of shop values + if (cfgShowNumbersAtShop.Value) + { + // costs + ShopCostPatch.Patch(harmony); + // player tokens + ShopTokenPatch.Patch(harmony); + } } /// diff --git a/Assets/README.md b/Assets/README.md index 3083209..3874511 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -1,19 +1,30 @@ # TNH Quality of Life Improvements -This mod adds quality of life improvements to the *Take and Hold* experience. +Ever got frustrated checking your HP against a bright ceiling in TNH? +Have you forgotten how many Holds you're playing for, so you don't know if you should spend all your tokens? +And... wait, which hold are you on again? +**This mod adds quality of life improvements to the *Take and Hold* experience that help with these questions, and then some.** ## Features -* Better Health counter visibility -* Token and hold counter on wrist +* Better health counter visibility +* Token, hold, and wave counter on radar hand * Player count for online leaderboards; see how you stack up! * Won't work with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/) installed +* Numerical representation of tokens at item stations +* Expiration indication for health crystals (configurable to multiple types) +* ...and possibly more! -Enable/disable these features in your mod manager's *Config editor*. +Toggle and customize these features in your mod manager's *Config editor*. For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page). ## Changelog 1.1.0 -* Added Health Crystals expiration indicator +* [TNH] Added win/lose count on hold counter +* [TNH] Added enemy waves counter (substitutes token counter during hold if enabled) +* [TNH] Added token numerical representation to shop +* [TNH] Extra info from this mod now shows in game over +* Added expiration indicators to Health Crystals +* Health readability now applies outside of Take and Hold 1.0.1 * Fixed the in-play improvements only applying to Classic Hallways map (whoops!!) diff --git a/Assets/_Fonts.meta b/Assets/_Fonts.meta index da4de23..3462f50 100644 --- a/Assets/_Fonts.meta +++ b/Assets/_Fonts.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 623ce5e3a46127b4492d42d663741c3c folderAsset: yes -timeCreated: 1642676798 +timeCreated: 1643540751 licenseType: Free DefaultImporter: userData: diff --git a/Assets/_Fonts/AGENCYR.TTF b/Assets/_Fonts/AGENCYR.TTF deleted file mode 100644 index f0f7e95..0000000 Binary files a/Assets/_Fonts/AGENCYR.TTF and /dev/null differ diff --git a/Assets/_Fonts/Bombardier.ttf b/Assets/_Fonts/Bombardier.ttf new file mode 100644 index 0000000..fc7a5dc Binary files /dev/null and b/Assets/_Fonts/Bombardier.ttf differ diff --git a/Assets/_Fonts/Bombardier.ttf.meta b/Assets/_Fonts/Bombardier.ttf.meta new file mode 100644 index 0000000..4578898 --- /dev/null +++ b/Assets/_Fonts/Bombardier.ttf.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: db8c1f9217651f543827c4f8bb8fda6e +timeCreated: 1643449316 +licenseType: Free +TrueTypeFontImporter: + serializedVersion: 4 + fontSize: 16 + forceTextureCase: -2 + characterSpacing: 0 + characterPadding: 1 + includeFontData: 1 + fontName: Bombardier + fontNames: + - Bombardier + fallbackFontReferences: [] + customCharacters: + fontRenderingMode: 0 + ascentCalculationMode: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Fonts/Gewtymol.ttf b/Assets/_Fonts/Gewtymol.ttf new file mode 100644 index 0000000..f4ba315 Binary files /dev/null and b/Assets/_Fonts/Gewtymol.ttf differ diff --git a/Assets/_Fonts/AGENCYR.TTF.meta b/Assets/_Fonts/Gewtymol.ttf.meta similarity index 78% rename from Assets/_Fonts/AGENCYR.TTF.meta rename to Assets/_Fonts/Gewtymol.ttf.meta index b081385..2928388 100644 --- a/Assets/_Fonts/AGENCYR.TTF.meta +++ b/Assets/_Fonts/Gewtymol.ttf.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 05d48c500227c8a4bbb7c02e3ccbb0b3 -timeCreated: 1642730970 +guid: bd993af5e164abe478f9fb24772e9e5d +timeCreated: 1643449316 licenseType: Free TrueTypeFontImporter: serializedVersion: 4 @@ -9,9 +9,9 @@ TrueTypeFontImporter: characterSpacing: 0 characterPadding: 1 includeFontData: 1 - fontName: Agency FB + fontName: Gewtymol fontNames: - - Agency FB + - Gewtymol fallbackFontReferences: [] customCharacters: fontRenderingMode: 0 diff --git a/Assets/_Prefabs/HoldCounter.prefab b/Assets/_Prefabs/HoldCounter.prefab index 215418f..280ae04 100644 --- a/Assets/_Prefabs/HoldCounter.prefab +++ b/Assets/_Prefabs/HoldCounter.prefab @@ -104,10 +104,10 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} m_FontSize: 70 m_FontStyle: 0 - m_BestFit: 0 + m_BestFit: 1 m_MinSize: 10 m_MaxSize: 70 m_Alignment: 7 @@ -211,12 +211,12 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 164 + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} + m_FontSize: 178 m_FontStyle: 0 - m_BestFit: 0 + m_BestFit: 1 m_MinSize: 0 - m_MaxSize: 200 + m_MaxSize: 231 m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 @@ -244,8 +244,8 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 49 + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} + m_FontSize: 56 m_FontStyle: 0 m_BestFit: 0 m_MinSize: 10 @@ -256,7 +256,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 0 0 + m_Text: 'W: 0 L: 0' --- !u!114 &114972162530505676 MonoBehaviour: m_ObjectHideFlags: 1 @@ -326,8 +326,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -12.550003} - m_SizeDelta: {x: 0, y: -100.3} + m_AnchoredPosition: {x: 0, y: -11.854996} + m_SizeDelta: {x: 0, y: -97.490005} m_Pivot: {x: 0.5, y: 0.5} --- !u!224 &224364969672532764 RectTransform: @@ -342,11 +342,11 @@ RectTransform: m_Father: {fileID: 224724389550513542} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 105.9} - m_SizeDelta: {x: 0, y: -211.8} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 180} + m_SizeDelta: {x: 0, y: 90} + m_Pivot: {x: 0.5, y: 1} --- !u!224 &224420167260936368 RectTransform: m_ObjectHideFlags: 1 @@ -363,7 +363,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 308.5, y: 64.57} + m_SizeDelta: {x: 498.43, y: 76.42} m_Pivot: {x: 0.5, y: 0} --- !u!224 &224724389550513542 RectTransform: @@ -372,7 +372,7 @@ RectTransform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1421894940388160} m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0, z: 150.00005} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 224364969672532764} @@ -384,5 +384,5 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 500, y: 300} + m_SizeDelta: {x: 580, y: 360} m_Pivot: {x: 1, y: 1} diff --git a/Assets/_Prefabs/Store.asset b/Assets/_Prefabs/Store.asset index a4aaadb..a222e35 100644 --- a/Assets/_Prefabs/Store.asset +++ b/Assets/_Prefabs/Store.asset @@ -18,3 +18,5 @@ MonoBehaviour: - {fileID: 1395656030192232, guid: 6085354c72844664589bb5f21f9872b1, type: 2} - {fileID: 1634027973393822, guid: a97af7648bcd6394b867989bf8fb9ed0, type: 2} - {fileID: 1106932692061560, guid: 9c96f08f84c4ede44ae45ae4afd1901b, type: 2} + - {fileID: 12800000, guid: db8c1f9217651f543827c4f8bb8fda6e, type: 3} + - {fileID: 1484126367028484, guid: 5a8f723d4ab4740458cbb4df16bf2c5e, type: 2} diff --git a/Assets/_Prefabs/TokenCounter.prefab b/Assets/_Prefabs/TokenCounter.prefab index c0f8e54..b80c72b 100644 --- a/Assets/_Prefabs/TokenCounter.prefab +++ b/Assets/_Prefabs/TokenCounter.prefab @@ -159,13 +159,13 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 252 + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} + m_FontSize: 225 m_FontStyle: 0 m_BestFit: 0 m_MinSize: 1 m_MaxSize: 274 - m_Alignment: 0 + m_Alignment: 3 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 @@ -247,11 +247,11 @@ RectTransform: m_Father: {fileID: 224329896993820026} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 73.2, y: 49.6} - m_SizeDelta: {x: -146.4, y: 49.599907} - m_Pivot: {x: 0.5, y: 1} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 373.2, y: 0} + m_SizeDelta: {x: 353.6, y: 370} + m_Pivot: {x: 0.5, y: 0.5} --- !u!224 &224145026042435474 RectTransform: m_ObjectHideFlags: 1 @@ -265,11 +265,11 @@ RectTransform: m_Father: {fileID: 224329896993820026} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -46} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 50, y: 0} m_SizeDelta: {x: 120, y: 120} - m_Pivot: {x: 0, y: 1} + m_Pivot: {x: 0, y: 0.5} --- !u!224 &224329896993820026 RectTransform: m_ObjectHideFlags: 1 @@ -277,7 +277,7 @@ RectTransform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1428988585174978} m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0, z: 150.00002} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 224145026042435474} @@ -288,5 +288,5 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 500, y: 300} + m_SizeDelta: {x: 500, y: 360} m_Pivot: {x: 0, y: 1} diff --git a/Assets/_Prefabs/WaveCounter.prefab b/Assets/_Prefabs/WaveCounter.prefab index 4a39eca..901c615 100644 --- a/Assets/_Prefabs/WaveCounter.prefab +++ b/Assets/_Prefabs/WaveCounter.prefab @@ -40,7 +40,7 @@ GameObject: - component: {fileID: 223350672124862004} - component: {fileID: 114814645303408290} - component: {fileID: 114323534746903312} - - component: {fileID: 114698421110497518} + - component: {fileID: 114211714150175156} m_Layer: 5 m_Name: WaveCounter m_TagString: Untagged @@ -66,6 +66,17 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!114 &114211714150175156 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484126367028484} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c0c3423ff90fccc45bc00c97177b33fb, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!114 &114225475503413820 MonoBehaviour: m_ObjectHideFlags: 1 @@ -116,30 +127,19 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 177 + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} + m_FontSize: 178 m_FontStyle: 0 - m_BestFit: 0 + m_BestFit: 1 m_MinSize: 0 - m_MaxSize: 203 + m_MaxSize: 290 m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 - m_HorizontalOverflow: 1 + m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: -1 / -1 ---- !u!114 &114698421110497518 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1484126367028484} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c0c3423ff90fccc45bc00c97177b33fb, type: 3} - m_Name: - m_EditorClassIdentifier: + m_Text: "-1 / \u221E" --- !u!114 &114774221110400688 MonoBehaviour: m_ObjectHideFlags: 1 @@ -195,10 +195,10 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} + m_Font: {fileID: 12800000, guid: c51b17758851dcc44b27cae745b28eaa, type: 3} m_FontSize: 70 m_FontStyle: 0 - m_BestFit: 0 + m_BestFit: 1 m_MinSize: 10 m_MaxSize: 70 m_Alignment: 7 @@ -253,11 +253,11 @@ RectTransform: m_Father: {fileID: 224505954339385570} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 105.9} - m_SizeDelta: {x: 0, y: -211.8} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 180} + m_SizeDelta: {x: 0, y: 90} + m_Pivot: {x: 0.5, y: 1} --- !u!224 &224505954339385570 RectTransform: m_ObjectHideFlags: 1 @@ -265,7 +265,7 @@ RectTransform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1484126367028484} m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0, z: 150.00005} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 224426227895944482} @@ -275,8 +275,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: -500, y: 0} - m_SizeDelta: {x: 500, y: 300} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 580, y: 360} m_Pivot: {x: 0, y: 1} --- !u!224 &224892970170756718 RectTransform: @@ -293,6 +293,6 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -39.525} - m_SizeDelta: {x: 0, y: -79.05} + m_AnchoredPosition: {x: 0, y: -30.3} + m_SizeDelta: {x: 0, y: -60.6} m_Pivot: {x: 0.5, y: 0.5} diff --git a/Assets/_Scripts/HPReadability.cs b/Assets/_Scripts/HPReadability.cs index eacc111..d49d968 100644 --- a/Assets/_Scripts/HPReadability.cs +++ b/Assets/_Scripts/HPReadability.cs @@ -7,7 +7,6 @@ namespace TNHQoLImprovements { public static void ImproveHPTextReadability(GameObject gObjHUD) { - Debug.Log("gObjHUD: " + gObjHUD); var canvas = gObjHUD.GetComponent(); var gObjBG = new GameObject(); Transform[] tranHPText = { diff --git a/Assets/_Scripts/HoldCounter.cs b/Assets/_Scripts/HoldCounter.cs index 9aea42a..a191886 100644 --- a/Assets/_Scripts/HoldCounter.cs +++ b/Assets/_Scripts/HoldCounter.cs @@ -22,7 +22,8 @@ namespace TNHQoLImprovements private Text lblWinLose; public static int[] winLose = { -1, 1 }; - public const string WIN_LOSE_TEXT = "{0} {1}"; + public const string WIN_LOSE_TEXT = "W: {0} L: {1}"; + //public const string WIN_LOSE_TEXT = "{0} {1}"; public static void OnHoldEnd(TNH_HoldPoint p, bool success) { @@ -34,11 +35,13 @@ namespace TNHQoLImprovements void Start() { - transform.localPosition = new Vector3(-333, 0, -450); - lblHoldCount = transform.GetChild(1).GetComponent(); lblWinLose = transform.GetChild(2).GetComponent(); + transform.GetChild(0).GetComponent().font = MeatKitPlugin.fontAgencyFB; + lblHoldCount.font = MeatKitPlugin.fontAgencyFB; + lblWinLose.font = MeatKitPlugin.fontAgencyFB; + winLose[0] = 0; winLose[1] = 0; } diff --git a/Assets/_Scripts/InPlay.cs b/Assets/_Scripts/InPlay.cs index 49608c6..4e072f9 100644 --- a/Assets/_Scripts/InPlay.cs +++ b/Assets/_Scripts/InPlay.cs @@ -16,6 +16,15 @@ namespace TNHQoLImprovements private static Transform[] hands; private static GameObject tnhInfo; + public static bool InHold() + { + if (tnhManager == null) + return false; + + return tnhManager.Phase == TNH_Phase.Hold; + } + + // Bring extra info into game over public static void Patch(Harmony harmony) { var original = typeof(TNH_Manager).GetMethod("SetPhase", BindingFlags.NonPublic | BindingFlags.Instance); @@ -38,7 +47,6 @@ namespace TNHQoLImprovements } } - // Use this for initialization void Start() { tnhManager = GameObject.Find("_GameManager").GetComponent(); diff --git a/Assets/_Scripts/ShopCostPatch.cs b/Assets/_Scripts/ShopCostPatch.cs index 17a2a97..f1ece8e 100644 --- a/Assets/_Scripts/ShopCostPatch.cs +++ b/Assets/_Scripts/ShopCostPatch.cs @@ -12,45 +12,46 @@ namespace TNHQoLImprovements public static void Patch(Harmony harmony) { var original = typeof(TNH_ObjectConstructorIcon).GetMethod("Init", BindingFlags.Public | BindingFlags.Instance); - var postfix = typeof(ShopCostPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static); + var postfix = typeof(ShopCostPatch).GetMethod("AddCostNumber", BindingFlags.NonPublic | BindingFlags.Static); harmony.Patch(original, new HarmonyMethod(postfix)); } - private static void AddNumericalRepresentation(TNH_ObjectConstructorIcon __instance) + private static void AddCostNumber(TNH_ObjectConstructorIcon __instance) { foreach (Transform curTran in __instance.gameObject.transform) { if (curTran.name.Contains("Cost")) - curTran.gameObject.AddComponent(); + curTran.gameObject.AddComponent(); } } } - public class ShopCostNumber : MonoBehaviour + public class CostNumber : MonoBehaviour { - private TNH_ObjectConstructorIcon objConstructor; + private TNH_ObjectConstructorIcon objConstructorIcon; private Text text; public void Awake() { - objConstructor = transform.parent.GetComponent(); + objConstructorIcon = transform.parent.GetComponent(); } public void Start() { var textTran = new GameObject().transform; textTran.SetParent(transform, false); - textTran.localPosition = new Vector2(0, -245); + textTran.localPosition = new Vector2(0, 245); text = textTran.gameObject.AddComponent(); - text.font = MeatKitPlugin.fontAgencyFB; - text.alignment = TextAnchor.MiddleCenter; - text.fontSize = 50; + text.font = MeatKitPlugin.fontBombardier; + text.alignment = TextAnchor.MiddleCenter; + text.fontSize = 72; } public void Update() { - text.text = objConstructor.Cost.ToString(); + text.text = objConstructorIcon.Cost.ToString(); + text.color = objConstructorIcon.GetComponent().color; } } } \ No newline at end of file diff --git a/Assets/_Scripts/ShopTokenPatch.cs b/Assets/_Scripts/ShopTokenPatch.cs new file mode 100644 index 0000000..200b8f9 --- /dev/null +++ b/Assets/_Scripts/ShopTokenPatch.cs @@ -0,0 +1,47 @@ +using HarmonyLib; +using System.Reflection; +using UnityEngine; +using UnityEngine.UI; +using FistVR; + +namespace TNHQoLImprovements +{ + public static class ShopTokenPatch + { + public static void Patch(Harmony harmony) + { + var original = typeof(TNH_ObjectConstructor).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance); + var postfix = typeof(ShopTokenPatch).GetMethod("Postfix", BindingFlags.NonPublic | BindingFlags.Static); + harmony.Patch(original, postfix: new HarmonyMethod(postfix)); + } + private static void Postfix(TNH_ObjectConstructor __instance) + { + // add component to 1st token icon + __instance.transform.GetChild(0).GetChild(0).GetChild(2).GetChild(0).gameObject.AddComponent(); + } + } + + // child of TopCell (the 0th child) + class ShopTokenNumber : MonoBehaviour + { + private Text text; + + private void Start() + { + var gObjText = new GameObject("TokenCounter"); + gObjText.transform.SetParent(transform, false); + gObjText.transform.localPosition = new Vector3(0, -4, 0); + + text = gObjText.AddComponent(); + text.alignment = TextAnchor.MiddleCenter; + text.font = MeatKitPlugin.fontBombardier; + text.fontSize = 55; + text.color = new Color(0.1307786f, 0.2461715f, 0.359f); + } + private void Update() + { + int tokens = InPlay.tnhManager.GetNumTokens(); + text.text = tokens.ToString(); + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/ShopTokenPatch.cs.meta b/Assets/_Scripts/ShopTokenPatch.cs.meta new file mode 100644 index 0000000..b5c35b6 --- /dev/null +++ b/Assets/_Scripts/ShopTokenPatch.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 54fa5d5e1f85520468a10f9556e53456 +timeCreated: 1643446256 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/TNHInfo.cs b/Assets/_Scripts/TNHInfo.cs index afcfe36..ca510ce 100644 --- a/Assets/_Scripts/TNHInfo.cs +++ b/Assets/_Scripts/TNHInfo.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using HarmonyLib; +using UnityEngine; using FistVR; namespace TNHQoLImprovements @@ -7,6 +8,7 @@ namespace TNHQoLImprovements { private GameObject holdCounter; private GameObject tokenCounter; + private GameObject waveCounter; public void Start() { @@ -14,7 +16,10 @@ namespace TNHQoLImprovements holdCounter = Instantiate(MeatKitPlugin.bundle.LoadAsset("HoldCounter"), transform); if (MeatKitPlugin.cfgShowTokens.Value) tokenCounter = Instantiate(MeatKitPlugin.bundle.LoadAsset("TokenCounter"), transform); + if (MeatKitPlugin.cfgShowWaves.Value) + waveCounter = Instantiate(MeatKitPlugin.bundle.LoadAsset("WaveCounter"), transform); + PlayPos(); } public void PlayPos() @@ -24,6 +29,9 @@ namespace TNHQoLImprovements if (tokenCounter != null) tokenCounter.transform.localPosition = new Vector3(333, 0, -450); + + if (waveCounter != null) + waveCounter.transform.localPosition = new Vector3(333, 0, -450); } public void GameOverPos() @@ -33,6 +41,41 @@ namespace TNHQoLImprovements if (tokenCounter != null) tokenCounter.transform.localPosition = new Vector3(250, 0, 0); + + if (waveCounter != null) + { + waveCounter.gameObject.GetComponent().pivot = new Vector2(0.5f, 0); + waveCounter.transform.localPosition = new Vector3(0, 0, 140); + } + } + + public void Update() + { + if (InPlay.tnhManager.Phase == TNH_Phase.Dead) + { + if (tokenCounter != null) + tokenCounter.SetActive(true); + + return; + } + + // we're in a hold; hide token count + if(InPlay.tnhManager.Phase == TNH_Phase.Hold) + { + if (tokenCounter != null) + tokenCounter.SetActive(false); + + if (waveCounter != null) + waveCounter.SetActive(true); + } + else // show token count + { + if (tokenCounter != null) + tokenCounter.SetActive(true); + + if (waveCounter != null) + waveCounter.SetActive(false); + } } } } diff --git a/Assets/_Scripts/TokenCounter.cs b/Assets/_Scripts/TokenCounter.cs index d2ade60..5ebb81f 100644 --- a/Assets/_Scripts/TokenCounter.cs +++ b/Assets/_Scripts/TokenCounter.cs @@ -7,9 +7,12 @@ namespace TNHQoLImprovements { public class TokenCounter : MonoBehaviour { + private Text text; + void Start() { - transform.localPosition = new Vector3(333, 0, -450); + text = transform.GetChild(1).GetComponent(); + text.font = MeatKitPlugin.fontAgencyFB; StartCoroutine(SetTokenImage()); } @@ -18,7 +21,7 @@ namespace TNHQoLImprovements { int debug_iterations = 0; Sprite tokenSprite = null; - while (tokenSprite == null) // END: loop until Token sprite is found + while (tokenSprite == null) // loop until Token sprite is found { var obj = GameObject.Find("_TNH_ObjectConstructor(Clone)/_CanvasHolder/_UITest_Canvas/Icon_0/Cost_1/Image"); if (obj != null) @@ -38,7 +41,7 @@ namespace TNHQoLImprovements void Update() { int tokens = InPlay.tnhManager.GetNumTokens(); - transform.GetChild(1).GetComponent().text = tokens.ToString(); + text.text = tokens.ToString(); } } } \ No newline at end of file diff --git a/Assets/_Scripts/UIRingTimer.cs b/Assets/_Scripts/UIRingTimer.cs index 2466d81..618ab7f 100644 --- a/Assets/_Scripts/UIRingTimer.cs +++ b/Assets/_Scripts/UIRingTimer.cs @@ -29,5 +29,7 @@ public class UIRingTimer : MonoBehaviour { float amount = (endTime - Time.time) / length; ringImg.fillAmount = Mathf.Clamp01(amount); + + transform.LookAt(MeatKitPlugin.playerCamera.transform); } } diff --git a/Assets/_Scripts/WaveCounter.cs b/Assets/_Scripts/WaveCounter.cs index df3e64d..effdab6 100644 --- a/Assets/_Scripts/WaveCounter.cs +++ b/Assets/_Scripts/WaveCounter.cs @@ -1,54 +1,38 @@ -using System.Reflection; -using HarmonyLib; +using HarmonyLib; using UnityEngine; -using UnityEngine.Events; +using UnityEngine.UI; using FistVR; namespace TNHQoLImprovements { - public static class WavePatch - { - public static void Patch(Harmony harmony) - { - var original = typeof(TNH_Manager).GetMethod("HoldPointStarted", BindingFlags.Public | BindingFlags.Instance); - var patch = typeof(WavePatch).GetMethod("OnHoldStart", BindingFlags.NonPublic | BindingFlags.Static); - harmony.Patch(original, postfix: new HarmonyMethod(patch)); - } - - private static void OnHoldStart(TNH_HoldPoint p) - { - WaveCounter.WaveStarted.Invoke(p); - } - } - public class WaveCounter : MonoBehaviour { - [System.Serializable] - public class WaveStartedEvent : UnityEvent { } - public static WaveStartedEvent WaveStarted = new WaveStartedEvent(); + private TNH_HoldPoint curHoldPoint; + private Traverse trCurPhaseIdx; + private Traverse trMaxPhases; - private bool initialized = false; - - private TNH_HoldPoint holdPoint; + private Text text; // Use this for initialization void Start() { - - } - - void Init(TNH_Manager manager) - { - holdPoint = manager.m_curHoldPoint; - - initialized = true; - } + text = transform.GetChild(1).GetComponent(); + } // Update is called once per frame void Update() { - if (!initialized) - return; - } + if (InPlay.tnhManager.Phase != TNH_Phase.Hold) + return; + + if(!ReferenceEquals(curHoldPoint, InPlay.tnhManager.m_curHoldPoint)) + { + Debug.Log("Hold point updated!"); + curHoldPoint = InPlay.tnhManager.m_curHoldPoint; + trCurPhaseIdx = Traverse.Create(curHoldPoint).Field("m_phaseIndex"); + trMaxPhases = Traverse.Create(curHoldPoint).Field("m_maxPhases"); + } + text.text = string.Format("{0} / {1}", trCurPhaseIdx.Value, trMaxPhases.Value); + } } } \ No newline at end of file