diff --git a/Assets/MeatKit/MeatKitPlugin.cs b/Assets/MeatKit/MeatKitPlugin.cs index 1bbc749..2a5d3f5 100644 --- a/Assets/MeatKit/MeatKitPlugin.cs +++ b/Assets/MeatKit/MeatKitPlugin.cs @@ -34,13 +34,15 @@ public class MeatKitPlugin : BaseUnityPlugin 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 ConfigEntry cfgSolidifyHPText; public static ConfigEntry cfgShowHPBackground; public static ConfigEntry cfgHPBackgroundOpacity; public static ConfigEntry cfgShowTokens; public static ConfigEntry cfgShowHolds; - + public static ConfigEntry cfgHealthCrystalIndicator; + private static InPlay instance; private bool lpcModGone = false; @@ -50,9 +52,13 @@ public class MeatKitPlugin : BaseUnityPlugin private void SceneChanged(Scene from, Scene to) { - //Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name)); - Logger.LogInfo("_GameManager present: " + (GameObject.Find("_GameManager") != null)); - Logger.LogInfo("TNH_Manager object present: " + (FindObjectOfType() != null)); + 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) { Logger.LogInfo("We are in a TNH game!"); @@ -72,10 +78,15 @@ public class MeatKitPlugin : BaseUnityPlugin private void Awake() { + // MeatKit requirement + LoadAssets(); + + // get Agency FB from system + fontAgencyFB = Font.CreateDynamicFontFromOSFont("Agency FB", 16); + // load asset bundle bundle = AssetBundle.LoadFromFile(Path.Combine(BasePath, "tnh_qol_improvements")); SceneManager.activeSceneChanged += SceneChanged; - LoadAssets(); // setup configuration cfgShowHPBackground = Config.Bind("Health Counter", @@ -90,34 +101,55 @@ public class MeatKitPlugin : BaseUnityPlugin "Solidify HP text", true, "Set opacity of HP text to full and give it a shadow."); - cfgShowLPC = Config.Bind("Game Info", + cfgShowLPC = Config.Bind("Take and Hold Info", "Show player count in online leaderboards", true, "Shows the number of players in the currently selected TNH leaderboard."); - cfgShowTokens = Config.Bind("Game Info", + cfgShowTokens = Config.Bind("Take and Hold Info", "Show Tokens", true, "Shows how many tokens the player has by their radar hand."); - cfgShowHolds = Config.Bind("Game Info", + cfgShowHolds = Config.Bind("Take and Hold Info", "Show Holds", true, "Shows how many holds the player has completed by their radar hand."); + cfgHealthCrystalIndicator = Config.Bind("Misc.", + "Show expiration of Health Crystals", + HealthExpireIndicationType.Flashing, + "Add a visual indication on the Health Crystal's despawn timer."); + + // give 120 seconds to search for old mod, which we want to kill + lpcModSearchTimeEnd = Time.time + 120; + + RunPatches(); + } + // DO NOT EDIT. + private void LoadAssets() {} + + private void RunPatches() + { + if (harmony == null) + return; // patch KillAll code (only acts w/ health crystals) - TimedHealthCrystalPatch.Patch(harmony); + if (cfgHealthCrystalIndicator.Value != HealthExpireIndicationType.None) + TimedHealthCrystalPatch.Patch(harmony); // patch leaderboard code if (cfgShowLPC.Value) LeaderboardPlayerCountPatch.Patch(harmony); - - if(cfgShowHolds.Value) - HoldCounter.Patch(harmony); - // give 120 seconds to search for old mod, which we want to kill - lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120; + // for counting wins/loses + 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); } - // DO NOT EDIT. - private void LoadAssets() {} /// /// Its only purpose: to kill the deprecated TNH Leaderboard Player Count mod. diff --git a/Assets/_Prefabs/HoldCounter.prefab b/Assets/_Prefabs/HoldCounter.prefab index 95ba49b..215418f 100644 --- a/Assets/_Prefabs/HoldCounter.prefab +++ b/Assets/_Prefabs/HoldCounter.prefab @@ -105,11 +105,11 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 30 + m_FontSize: 70 m_FontStyle: 0 - m_BestFit: 1 + m_BestFit: 0 m_MinSize: 10 - m_MaxSize: 67 + m_MaxSize: 70 m_Alignment: 7 m_AlignByGeometry: 0 m_RichText: 1 @@ -212,12 +212,12 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 200 + m_FontSize: 164 m_FontStyle: 0 - m_BestFit: 1 - m_MinSize: 2 + m_BestFit: 0 + m_MinSize: 0 m_MaxSize: 200 - m_Alignment: 1 + m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 @@ -245,9 +245,9 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 26 + m_FontSize: 49 m_FontStyle: 0 - m_BestFit: 1 + m_BestFit: 0 m_MinSize: 10 m_MaxSize: 100 m_Alignment: 7 diff --git a/Assets/_Prefabs/Store.asset b/Assets/_Prefabs/Store.asset index 629e3d0..a4aaadb 100644 --- a/Assets/_Prefabs/Store.asset +++ b/Assets/_Prefabs/Store.asset @@ -17,3 +17,4 @@ MonoBehaviour: - {fileID: 1421894940388160, guid: 2e88fb286dba59a45b49fb0ae7d9449b, type: 2} - {fileID: 1395656030192232, guid: 6085354c72844664589bb5f21f9872b1, type: 2} - {fileID: 1634027973393822, guid: a97af7648bcd6394b867989bf8fb9ed0, type: 2} + - {fileID: 1106932692061560, guid: 9c96f08f84c4ede44ae45ae4afd1901b, type: 2} diff --git a/Assets/_Prefabs/TNHInfo.prefab b/Assets/_Prefabs/TNHInfo.prefab new file mode 100644 index 0000000..96be050 --- /dev/null +++ b/Assets/_Prefabs/TNHInfo.prefab @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1106932692061560} + m_IsPrefabParent: 1 +--- !u!1 &1106932692061560 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4863261474150994} + - component: {fileID: 114110489569638852} + m_Layer: 0 + m_Name: TNHInfo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4863261474150994 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1106932692061560} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &114110489569638852 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1106932692061560} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0d549cfce77855f4e9d9778d4c602f21, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/_Prefabs/TNHInfo.prefab.meta b/Assets/_Prefabs/TNHInfo.prefab.meta new file mode 100644 index 0000000..bebc5f0 --- /dev/null +++ b/Assets/_Prefabs/TNHInfo.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9c96f08f84c4ede44ae45ae4afd1901b +timeCreated: 1643333802 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Prefabs/TokenCounter.prefab b/Assets/_Prefabs/TokenCounter.prefab index 3e44b31..c0f8e54 100644 --- a/Assets/_Prefabs/TokenCounter.prefab +++ b/Assets/_Prefabs/TokenCounter.prefab @@ -160,12 +160,12 @@ MonoBehaviour: Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: 05d48c500227c8a4bbb7c02e3ccbb0b3, type: 3} - m_FontSize: 200 + m_FontSize: 252 m_FontStyle: 0 - m_BestFit: 1 + m_BestFit: 0 m_MinSize: 1 - m_MaxSize: 200 - m_Alignment: 3 + m_MaxSize: 274 + m_Alignment: 0 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 @@ -249,9 +249,9 @@ RectTransform: 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: 0} - m_SizeDelta: {x: -146.4, y: 0} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 73.2, y: 49.6} + m_SizeDelta: {x: -146.4, y: 49.599907} + m_Pivot: {x: 0.5, y: 1} --- !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.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -122, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: -46} m_SizeDelta: {x: 120, y: 120} - m_Pivot: {x: 1, y: 0.5} + m_Pivot: {x: 0, y: 1} --- !u!224 &224329896993820026 RectTransform: m_ObjectHideFlags: 1 diff --git a/Assets/_Prefabs/WaveCounter.prefab b/Assets/_Prefabs/WaveCounter.prefab new file mode 100644 index 0000000..4a39eca --- /dev/null +++ b/Assets/_Prefabs/WaveCounter.prefab @@ -0,0 +1,298 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1484126367028484} + m_IsPrefabParent: 1 +--- !u!1 &1284361357339212 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224892970170756718} + - component: {fileID: 222469931575018544} + - component: {fileID: 114369350517400038} + - component: {fileID: 114774221110400688} + m_Layer: 5 + m_Name: Text (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1484126367028484 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224505954339385570} + - component: {fileID: 223350672124862004} + - component: {fileID: 114814645303408290} + - component: {fileID: 114323534746903312} + - component: {fileID: 114698421110497518} + m_Layer: 5 + m_Name: WaveCounter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1767730806891424 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224426227895944482} + - component: {fileID: 222191868559757652} + - component: {fileID: 114991591682320102} + - component: {fileID: 114225475503413820} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &114225475503413820 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1767730806891424} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EffectColor: {r: 0, g: 0, b: 0, a: 0.734} + m_EffectDistance: {x: 3.5, y: -3.5} + m_UseGraphicAlpha: 1 +--- !u!114 &114323534746903312 +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: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &114369350517400038 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1284361357339212} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + 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_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 203 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + 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: +--- !u!114 &114774221110400688 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1284361357339212} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EffectColor: {r: 0, g: 0, b: 0, a: 0.734} + m_EffectDistance: {x: 3.5, y: -3.5} + m_UseGraphicAlpha: 1 +--- !u!114 &114814645303408290 +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: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!114 &114991591682320102 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1767730806891424} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + 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: 70 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 70 + m_Alignment: 7 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: WAVES COMPLETED +--- !u!222 &222191868559757652 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1767730806891424} +--- !u!222 &222469931575018544 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1284361357339212} +--- !u!223 &223350672124862004 +Canvas: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484126367028484} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &224426227895944482 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1767730806891424} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + 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} +--- !u!224 &224505954339385570 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + 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_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224426227895944482} + - {fileID: 224892970170756718} + m_Father: {fileID: 0} + m_RootOrder: 0 + 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_Pivot: {x: 0, y: 1} +--- !u!224 &224892970170756718 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1284361357339212} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224505954339385570} + 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: 0, y: -39.525} + m_SizeDelta: {x: 0, y: -79.05} + m_Pivot: {x: 0.5, y: 0.5} diff --git a/Assets/_Prefabs/WaveCounter.prefab.meta b/Assets/_Prefabs/WaveCounter.prefab.meta new file mode 100644 index 0000000..0b743c7 --- /dev/null +++ b/Assets/_Prefabs/WaveCounter.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5a8f723d4ab4740458cbb4df16bf2c5e +timeCreated: 1643271770 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/._ShopCostPatch.cs b/Assets/_Scripts/._ShopCostPatch.cs new file mode 100644 index 0000000..f7d7b2f Binary files /dev/null and b/Assets/_Scripts/._ShopCostPatch.cs differ diff --git a/Assets/_Scripts/._TimedHealthCrystalPatch.cs b/Assets/_Scripts/._TimedHealthCrystalPatch.cs new file mode 100644 index 0000000..dc7e568 Binary files /dev/null and b/Assets/_Scripts/._TimedHealthCrystalPatch.cs differ diff --git a/Assets/_Scripts/HPReadability.cs b/Assets/_Scripts/HPReadability.cs new file mode 100644 index 0000000..eacc111 --- /dev/null +++ b/Assets/_Scripts/HPReadability.cs @@ -0,0 +1,45 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace TNHQoLImprovements +{ + public static class HPReadability + { + public static void ImproveHPTextReadability(GameObject gObjHUD) + { + Debug.Log("gObjHUD: " + gObjHUD); + var canvas = gObjHUD.GetComponent(); + var gObjBG = new GameObject(); + Transform[] tranHPText = { + gObjHUD.transform.Find("Label_Title (1)"), + gObjHUD.transform.Find("Label_Title") + }; + + // apply background + if (MeatKitPlugin.cfgShowHPBackground.Value) + { + gObjBG.transform.parent = gObjHUD.transform; + gObjBG.transform.SetSiblingIndex(0); + gObjBG.transform.localPosition = new Vector3(0, 1, 0); + gObjBG.transform.localRotation = Quaternion.identity; + gObjBG.transform.localScale = tranHPText[0].localScale; + var rawImage = gObjBG.AddComponent(); + rawImage.color = new Color(0, 0, 0, MeatKitPlugin.cfgHPBackgroundOpacity.Value); + rawImage.rectTransform.SetWidth(100); + rawImage.rectTransform.SetHeight(52); + } + if (MeatKitPlugin.cfgSolidifyHPText.Value) + { + foreach (var text in tranHPText) + { + // full alpha + text.GetComponent().color = Color.white; + // drop shadow + var shadow = text.gameObject.AddComponent(); + shadow.effectColor = new Color(0, 0, 0, .95f); + shadow.effectDistance = new Vector2(0.5f, -0.5f); + } + } + } + } +} diff --git a/Assets/_Scripts/HPReadability.cs.meta b/Assets/_Scripts/HPReadability.cs.meta new file mode 100644 index 0000000..d61c610 --- /dev/null +++ b/Assets/_Scripts/HPReadability.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 13876b4618c99394bbb2838f5c26cd19 +timeCreated: 1643268023 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/HoldCounter.cs b/Assets/_Scripts/HoldCounter.cs index f27a649..9aea42a 100644 --- a/Assets/_Scripts/HoldCounter.cs +++ b/Assets/_Scripts/HoldCounter.cs @@ -6,7 +6,17 @@ using FistVR; namespace TNHQoLImprovements { - public class HoldCounter : MonoBehaviour + public static class HoldCounterPatch + { + public static void Patch(Harmony harmony) + { + var original = typeof(TNH_Manager).GetMethod("HoldPointCompleted", BindingFlags.Public | BindingFlags.Instance); + var patch = typeof(HoldCounter).GetMethod("OnHoldEnd"); + harmony.Patch(original, postfix: new HarmonyMethod(patch)); + } + } + + public class HoldCounter : MonoBehaviour { private Text lblHoldCount; private Text lblWinLose; @@ -14,21 +24,6 @@ namespace TNHQoLImprovements public static int[] winLose = { -1, 1 }; public const string WIN_LOSE_TEXT = "{0} {1}"; - - private void OnDeath(bool _) - { - Debug.Log("I died!"); - // TODO: bind stats to controller hand - } - - // TODO: win/lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted - public static void Patch(Harmony harmony) - { - var original = typeof(TNH_Manager).GetMethod("HoldPointCompleted", BindingFlags.Public | BindingFlags.Instance); - var patch = typeof(HoldCounter).GetMethod("OnHoldEnd"); - Debug.Log(string.Format("Original: {0} // Patch: {1}", original, patch)); - harmony.Patch(original, postfix: new HarmonyMethod(patch)); - } public static void OnHoldEnd(TNH_HoldPoint p, bool success) { if (success) @@ -39,17 +34,13 @@ namespace TNHQoLImprovements void Start() { - transform.localPosition = new Vector3(-1f, 0, -.5f); - transform.localRotation = Quaternion.Euler(90, 0, 0); - transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); + transform.localPosition = new Vector3(-333, 0, -450); lblHoldCount = transform.GetChild(1).GetComponent(); lblWinLose = transform.GetChild(2).GetComponent(); winLose[0] = 0; winLose[1] = 0; - - FindObjectOfType().PlayerDeathEvent += OnDeath; } void Update() diff --git a/Assets/_Scripts/InPlay.cs b/Assets/_Scripts/InPlay.cs index ec0053f..49608c6 100644 --- a/Assets/_Scripts/InPlay.cs +++ b/Assets/_Scripts/InPlay.cs @@ -1,4 +1,5 @@ -using System.Collections; +using HarmonyLib; +using System.Reflection; using UnityEngine; using UnityEngine.UI; using FistVR; @@ -10,42 +11,30 @@ namespace TNHQoLImprovements /// public class InPlay : MonoBehaviour { - private GameObject gObjHUD; public static TNH_Manager tnhManager; - void ImproveHPTextReadability() - { - var canvas = gObjHUD.GetComponent(); - var gObjBG = new GameObject(); - Transform[] tranHPText = { - gObjHUD.transform.Find("Label_Title (1)"), - gObjHUD.transform.Find("Label_Title") - }; + private static Transform[] hands; + private static GameObject tnhInfo; - // apply background - if (MeatKitPlugin.cfgShowHPBackground.Value) + public static void Patch(Harmony harmony) + { + var original = typeof(TNH_Manager).GetMethod("SetPhase", BindingFlags.NonPublic | BindingFlags.Instance); + var patch = typeof(InPlay).GetMethod("MoveStatsToController", BindingFlags.NonPublic | BindingFlags.Static); + harmony.Patch(original, postfix: new HarmonyMethod(patch)); + } + + private static void MoveStatsToController(TNH_Phase p) + { + if (tnhManager == null) + return; + + if (p == TNH_Phase.Dead || p == TNH_Phase.Completed) { - gObjBG.transform.parent = gObjHUD.transform; - gObjBG.transform.SetSiblingIndex(0); - gObjBG.transform.localPosition = new Vector3(0, 1, 0); - gObjBG.transform.localRotation = Quaternion.identity; - gObjBG.transform.localScale = tranHPText[0].localScale; - var rawImage = gObjBG.AddComponent(); - rawImage.color = new Color(0, 0, 0, MeatKitPlugin.cfgHPBackgroundOpacity.Value); - rawImage.rectTransform.SetWidth(100); - rawImage.rectTransform.SetHeight(52); - } - if (MeatKitPlugin.cfgSolidifyHPText.Value) - { - foreach (var text in tranHPText) - { - // full alpha - text.GetComponent().color = Color.white; - // drop shadow - var shadow = text.gameObject.AddComponent(); - shadow.effectColor = new Color(0, 0, 0, .95f); - shadow.effectDistance = new Vector2(0.5f, -0.5f); - } + int handSide = tnhManager.RadarHand == TNH_RadarHand.Left ? 0 : 1; + + tnhInfo.transform.SetParent(hands[handSide], false); + tnhInfo.transform.localScale = new Vector3(.0002f, .0002f, .0002f); + tnhInfo.GetComponent().GameOverPos(); } } @@ -53,14 +42,14 @@ namespace TNHQoLImprovements void Start() { tnhManager = GameObject.Find("_GameManager").GetComponent(); - gObjHUD = GameObject.Find("HealthBar(Clone)/f"); - if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value) - ImproveHPTextReadability(); - if (MeatKitPlugin.cfgShowTokens.Value) - Instantiate(MeatKitPlugin.bundle.LoadAsset("TokenCounter"), FindObjectOfType().transform.GetChild(3)); - if (MeatKitPlugin.cfgShowHolds.Value) - Instantiate(MeatKitPlugin.bundle.LoadAsset("HoldCounter"), FindObjectOfType().transform.GetChild(3)); + var rig = Object.FindObjectOfType().transform; + hands = new Transform[] { + rig.transform.GetChild(1), rig.transform.GetChild(0) + }; + + tnhInfo = Instantiate(MeatKitPlugin.bundle.LoadAsset("TNHInfo"), FindObjectOfType().transform.GetChild(3)); + tnhInfo.transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); } } } \ No newline at end of file diff --git a/Assets/_Scripts/ShopCostPatch.cs b/Assets/_Scripts/ShopCostPatch.cs new file mode 100644 index 0000000..17a2a97 --- /dev/null +++ b/Assets/_Scripts/ShopCostPatch.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Reflection; +using HarmonyLib; +using UnityEngine; +using UnityEngine.UI; +using FistVR; + +namespace TNHQoLImprovements +{ + public class ShopCostPatch : MonoBehaviour + { + 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); + harmony.Patch(original, new HarmonyMethod(postfix)); + } + + private static void AddNumericalRepresentation(TNH_ObjectConstructorIcon __instance) + { + foreach (Transform curTran in __instance.gameObject.transform) + { + if (curTran.name.Contains("Cost")) + curTran.gameObject.AddComponent(); + } + } + } + + public class ShopCostNumber : MonoBehaviour + { + private TNH_ObjectConstructorIcon objConstructor; + private Text text; + + public void Awake() + { + objConstructor = transform.parent.GetComponent(); + } + + public void Start() + { + var textTran = new GameObject().transform; + textTran.SetParent(transform, false); + textTran.localPosition = new Vector2(0, -245); + + text = textTran.gameObject.AddComponent(); + text.font = MeatKitPlugin.fontAgencyFB; + text.alignment = TextAnchor.MiddleCenter; + text.fontSize = 50; + } + + public void Update() + { + text.text = objConstructor.Cost.ToString(); + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/ShopCostPatch.cs.meta b/Assets/_Scripts/ShopCostPatch.cs.meta new file mode 100644 index 0000000..8ba0461 --- /dev/null +++ b/Assets/_Scripts/ShopCostPatch.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 51b19459f850a654488e4057bf5dbb1f +timeCreated: 1643424482 +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 new file mode 100644 index 0000000..afcfe36 --- /dev/null +++ b/Assets/_Scripts/TNHInfo.cs @@ -0,0 +1,38 @@ +using UnityEngine; +using FistVR; + +namespace TNHQoLImprovements +{ + class TNHInfo : MonoBehaviour + { + private GameObject holdCounter; + private GameObject tokenCounter; + + public void Start() + { + if (MeatKitPlugin.cfgShowHolds.Value) + holdCounter = Instantiate(MeatKitPlugin.bundle.LoadAsset("HoldCounter"), transform); + if (MeatKitPlugin.cfgShowTokens.Value) + tokenCounter = Instantiate(MeatKitPlugin.bundle.LoadAsset("TokenCounter"), transform); + + } + + public void PlayPos() + { + if (holdCounter != null) + holdCounter.transform.localPosition = new Vector3(-333, 0, -450); + + if (tokenCounter != null) + tokenCounter.transform.localPosition = new Vector3(333, 0, -450); + } + + public void GameOverPos() + { + if (holdCounter != null) + holdCounter.transform.localPosition = new Vector3(-250, 0, 0); + + if (tokenCounter != null) + tokenCounter.transform.localPosition = new Vector3(250, 0, 0); + } + } +} diff --git a/Assets/_Scripts/TNHInfo.cs.meta b/Assets/_Scripts/TNHInfo.cs.meta new file mode 100644 index 0000000..8e3b984 --- /dev/null +++ b/Assets/_Scripts/TNHInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0d549cfce77855f4e9d9778d4c602f21 +timeCreated: 1643333500 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/TimedHealthCrystalPatch.cs b/Assets/_Scripts/TimedHealthCrystalPatch.cs index b669c73..1244904 100644 --- a/Assets/_Scripts/TimedHealthCrystalPatch.cs +++ b/Assets/_Scripts/TimedHealthCrystalPatch.cs @@ -5,6 +5,11 @@ using FistVR; namespace TNHQoLImprovements { + public enum HealthExpireIndicationType + { + None, Flashing, CircularGraphic + } + /// /// If KillAfter is attached to a HealthCrystal, show visual representation of expiration. /// @@ -29,27 +34,20 @@ namespace TNHQoLImprovements if (__instance.transform.GetComponentInChildren() == null) return; - Debug.Log("KillAfter will expire in " + __instance.DieTime + " seconds."); - GameObject timer; Transform healthCrystal = __instance.transform.Find("HealthCrystal"); - switch (VISUAL_APPROACH) + switch (MeatKitPlugin.cfgHealthCrystalIndicator.Value) { - case 0: // ring above + case HealthExpireIndicationType.CircularGraphic: // ring above timer = GameObject.Instantiate(timerAsset, healthCrystal); timer.GetComponent().Init(__instance.DieTime); timer.transform.localScale = new Vector2(0.001f, 0.001f); timer.transform.localPosition = new Vector3(0, .9f, 0); + // TODO: disable scoring? break; - case 1: // ring around - timer = GameObject.Instantiate(timerAsset, healthCrystal); - timer.GetComponent().Init(__instance.DieTime); - timer.transform.localScale = new Vector2(0.0035f, 0.0035f); - timer.transform.localPosition = Vector3.zero; - break; - case 2: // flashing crystal + case HealthExpireIndicationType.Flashing: // flashing crystal var flicker = healthCrystal.gameObject.AddComponent(); - flicker.Init(.4f, 0.6f, __instance.DieTime - 3f); + flicker.Init(.6f, .7f, __instance.DieTime - 3); break; } } diff --git a/Assets/_Scripts/TokenCounter.cs b/Assets/_Scripts/TokenCounter.cs index 28d6f17..d2ade60 100644 --- a/Assets/_Scripts/TokenCounter.cs +++ b/Assets/_Scripts/TokenCounter.cs @@ -9,11 +9,9 @@ namespace TNHQoLImprovements { void Start() { - transform.localPosition = new Vector3(1, 0, -.5f); - transform.localRotation = Quaternion.Euler(90, 0, 0); - transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); + transform.localPosition = new Vector3(333, 0, -450); - StartCoroutine(SetTokenImage()); + StartCoroutine(SetTokenImage()); } private IEnumerator SetTokenImage() diff --git a/Assets/_Scripts/WaveCounter.cs b/Assets/_Scripts/WaveCounter.cs new file mode 100644 index 0000000..df3e64d --- /dev/null +++ b/Assets/_Scripts/WaveCounter.cs @@ -0,0 +1,54 @@ +using System.Reflection; +using HarmonyLib; +using UnityEngine; +using UnityEngine.Events; +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 bool initialized = false; + + private TNH_HoldPoint holdPoint; + + // Use this for initialization + void Start() + { + + } + + void Init(TNH_Manager manager) + { + holdPoint = manager.m_curHoldPoint; + + initialized = true; + } + + // Update is called once per frame + void Update() + { + if (!initialized) + return; + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/WaveCounter.cs.meta b/Assets/_Scripts/WaveCounter.cs.meta new file mode 100644 index 0000000..4b454e3 --- /dev/null +++ b/Assets/_Scripts/WaveCounter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c0c3423ff90fccc45bc00c97177b33fb +timeCreated: 1643271842 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: