win/lose hold stats, hp crystal expiration

This commit is contained in:
msk
2022-01-26 01:23:39 -08:00
parent 6f938e95c8
commit fcea383739
22 changed files with 657 additions and 60 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
PackageName: TNH_Quality_of_Life_Improvements PackageName: TNH_Quality_of_Life_Improvements
Author: muskit Author: muskit
Version: 1.0.1 Version: 1.1.0
Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3} Icon: {fileID: 2800000, guid: 785b7946398f5314b95bf593d2d77d67, type: 3}
ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3} ReadMe: {fileID: 102900000, guid: ab1d6dea017447a48ac348db588a6f35, type: 3}
WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements WebsiteURL: https://github.com/muskit/TNH-Quality-of-Life-Improvements
+16 -3
View File
@@ -1,4 +1,5 @@
#if H3VR_IMPORTED #if H3VR_IMPORTED
using HarmonyLib;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using BepInEx; using BepInEx;
@@ -42,10 +43,11 @@ public class MeatKitPlugin : BaseUnityPlugin
private static InPlay instance; private static InPlay instance;
private LeaderboardPlayerCountPatch lpc;
private bool lpcModGone = false; private bool lpcModGone = false;
private float lpcModSearchTimeEnd; private float lpcModSearchTimeEnd;
private Harmony harmony;
private void SceneChanged(Scene from, Scene to) private void SceneChanged(Scene from, Scene to)
{ {
//Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name)); //Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name));
@@ -63,6 +65,11 @@ public class MeatKitPlugin : BaseUnityPlugin
} }
} }
public MeatKitPlugin(): base()
{
harmony = new Harmony("muskit.TNHQualityOfLifeImprovements");
}
private void Awake() private void Awake()
{ {
// load asset bundle // load asset bundle
@@ -96,11 +103,17 @@ public class MeatKitPlugin : BaseUnityPlugin
true, true,
"Shows how many holds the player has completed by their radar hand."); "Shows how many holds the player has completed by their radar hand.");
// patch KillAll code (only acts w/ health crystals)
TimedHealthCrystalPatch.Patch(harmony);
// patch leaderboard code // patch leaderboard code
if (cfgShowLPC.Value) if (cfgShowLPC.Value)
lpc = new LeaderboardPlayerCountPatch(); LeaderboardPlayerCountPatch.Patch(harmony);
// give 120 seconds to search for old mod if(cfgShowHolds.Value)
HoldCounter.Patch(harmony);
// give 120 seconds to search for old mod, which we want to kill
lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120; lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120;
} }
// DO NOT EDIT. // DO NOT EDIT.
+5 -2
View File
@@ -12,12 +12,15 @@ Enable/disable 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). For any issues/ideas, please create an issue on the GitHub repo (linked on Thunderstore page).
## Changelog ## Changelog
1.1.0
* Added Health Crystals expiration indicator
1.0.1 1.0.1
* Fixed the in-play improvements only applying in Classic Hallways map (whoops!!) * Fixed the in-play improvements only applying to Classic Hallways map (whoops!!)
* Added option to enable/disable showing player count of online leaderboards * Added option to enable/disable showing player count of online leaderboards
* Added option to enable/disable HP text opacity/shadow change * Added option to enable/disable HP text opacity/shadow change
* (Surprisingly, the HP text normally doesn't have full opacity) * (Surprisingly, the HP text normally doesn't have full opacity)
* Searching for TNH Leaderboards Player Count now stops after 120s * Searching for the deprecated TNH Leaderboards Player Count mod to kill now stops after 120s
1.0.0 1.0.0
+187
View File
@@ -0,0 +1,187 @@
%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: 1634027973393822}
m_IsPrefabParent: 1
--- !u!1 &1475934434838188
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224853189626207054}
- component: {fileID: 222684863573680672}
- component: {fileID: 114673309682266402}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1634027973393822
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224077453978722080}
- component: {fileID: 223544683124447678}
- component: {fileID: 114094006499494552}
- component: {fileID: 114774830210974956}
- component: {fileID: 114654661998195444}
m_Layer: 5
m_Name: HealthCrystalTimer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114094006499494552
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1634027973393822}
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 &114654661998195444
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1634027973393822}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c0cc182175a3417499d53e43378f028c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114673309682266402
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1475934434838188}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, 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_Sprite: {fileID: 21300000, guid: 3677786155d617b4cb39bf42eddd24ad, type: 3}
m_Type: 3
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 0
m_FillOrigin: 2
--- !u!114 &114774830210974956
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1634027973393822}
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!222 &222684863573680672
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1475934434838188}
--- !u!223 &223544683124447678
Canvas:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1634027973393822}
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 &224077453978722080
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1634027973393822}
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:
- {fileID: 224853189626207054}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 574, y: 308.5}
m_SizeDelta: {x: 468, y: 472}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224853189626207054
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1475934434838188}
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: 224077453978722080}
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: 0, y: 0}
m_SizeDelta: {x: 468, y: 472}
m_Pivot: {x: 0.5, y: 0.5}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a97af7648bcd6394b867989bf8fb9ed0
timeCreated: 1643099434
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
+92 -2
View File
@@ -66,6 +66,24 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!1 &1774018057659698
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224420167260936368}
- component: {fileID: 222388691975761020}
- component: {fileID: 114828117127462556}
- component: {fileID: 114042133408737726}
m_Layer: 5
m_Name: Text (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114032145135548160 --- !u!114 &114032145135548160
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -99,6 +117,20 @@ MonoBehaviour:
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: HOLDS COMPLETED m_Text: HOLDS COMPLETED
--- !u!114 &114042133408737726
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1774018057659698}
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 &114133878122943296 --- !u!114 &114133878122943296
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -192,6 +224,39 @@ MonoBehaviour:
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: "-1 / \u221E" m_Text: "-1 / \u221E"
--- !u!114 &114828117127462556
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1774018057659698}
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: 26
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 10
m_MaxSize: 100
m_Alignment: 7
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: <color=#10ff10>0</color> <color=red>0</color>
--- !u!114 &114972162530505676 --- !u!114 &114972162530505676
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -208,6 +273,12 @@ MonoBehaviour:
m_BlockingMask: m_BlockingMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 4294967295 m_Bits: 4294967295
--- !u!222 &222388691975761020
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1774018057659698}
--- !u!222 &222541359112789466 --- !u!222 &222541359112789466
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -255,8 +326,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -45} m_AnchoredPosition: {x: 0, y: -12.550003}
m_SizeDelta: {x: 0, y: -90} m_SizeDelta: {x: 0, y: -100.3}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224364969672532764 --- !u!224 &224364969672532764
RectTransform: RectTransform:
@@ -276,6 +347,24 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 105.9} m_AnchoredPosition: {x: 0, y: 105.9}
m_SizeDelta: {x: 0, y: -211.8} m_SizeDelta: {x: 0, y: -211.8}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224420167260936368
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1774018057659698}
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: 224724389550513542}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
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_Pivot: {x: 0.5, y: 0}
--- !u!224 &224724389550513542 --- !u!224 &224724389550513542
RectTransform: RectTransform:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@@ -288,6 +377,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 224364969672532764} - {fileID: 224364969672532764}
- {fileID: 224142695019321682} - {fileID: 224142695019321682}
- {fileID: 224420167260936368}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
@@ -113,9 +113,9 @@ MonoBehaviour:
m_AlignByGeometry: 0 m_AlignByGeometry: 0
m_RichText: 1 m_RichText: 1
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
m_VerticalOverflow: 0 m_VerticalOverflow: 1
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: LOADING PLAYER COUNT m_Text: RETRIEVING PLAYER COUNT
--- !u!222 &222658238543524802 --- !u!222 &222658238543524802
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
+1
View File
@@ -16,3 +16,4 @@ MonoBehaviour:
- {fileID: 1428988585174978, guid: c034a3fdd4eaa554bb81a9a202bf37dd, type: 2} - {fileID: 1428988585174978, guid: c034a3fdd4eaa554bb81a9a202bf37dd, type: 2}
- {fileID: 1421894940388160, guid: 2e88fb286dba59a45b49fb0ae7d9449b, type: 2} - {fileID: 1421894940388160, guid: 2e88fb286dba59a45b49fb0ae7d9449b, type: 2}
- {fileID: 1395656030192232, guid: 6085354c72844664589bb5f21f9872b1, type: 2} - {fileID: 1395656030192232, guid: 6085354c72844664589bb5f21f9872b1, type: 2}
- {fileID: 1634027973393822, guid: a97af7648bcd6394b867989bf8fb9ed0, type: 2}
+33 -8
View File
@@ -1,5 +1,5 @@
using System.Collections; using System.Reflection;
using System.Collections.Generic; using HarmonyLib;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using FistVR; using FistVR;
@@ -8,37 +8,62 @@ namespace TNHQoLImprovements
{ {
public class HoldCounter : MonoBehaviour public class HoldCounter : MonoBehaviour
{ {
private Text lblHoldCount;
private Text lblWinLose;
public static int[] winLose = { -1, 1 };
public const string WIN_LOSE_TEXT = "<color=#10ff10>{0}</color> <color=red>{1}</color>";
private void OnDeath(bool _) private void OnDeath(bool _)
{ {
Debug.Log("I died!"); Debug.Log("I died!");
// TODO: bind stats to controller hand
} }
// TODO: lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted // TODO: win/lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted
private void OnHoldLose() 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)
winLose[0]++;
else
winLose[1]++;
} }
void Start() void Start()
{ {
//transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(-1f, 0, -.5f); transform.localPosition = new Vector3(-1f, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
lblHoldCount = transform.GetChild(1).GetComponent<Text>();
lblWinLose = transform.GetChild(2).GetComponent<Text>();
winLose[0] = 0;
winLose[1] = 0;
FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath; FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
} }
void Update() void Update()
{ {
// Total hold count
string display = ""; string display = "";
if (InPlay.tnhManager.ProgressionMode == TNHSetting_ProgressionType.Marathon) if (InPlay.tnhManager.ProgressionMode == TNHSetting_ProgressionType.Marathon)
display = InPlay.tnhManager.m_level.ToString() + " / ∞"; display = InPlay.tnhManager.m_level.ToString() + " / ∞";
else else
display = string.Format("{0} / {1}", InPlay.tnhManager.m_level, InPlay.tnhManager.m_maxLevels); display = string.Format("{0} / {1}", InPlay.tnhManager.m_level, InPlay.tnhManager.m_maxLevels);
lblHoldCount.text = display;
transform.GetChild(1).GetComponent<Text>().text = display; // Win/Lost holds
lblWinLose.text = string.Format(WIN_LOSE_TEXT, winLose[0], winLose[1]);
} }
} }
} }
+2 -5
View File
@@ -11,10 +11,8 @@ namespace TNHQoLImprovements
public class InPlay : MonoBehaviour public class InPlay : MonoBehaviour
{ {
private GameObject gObjHUD; private GameObject gObjHUD;
private GameObject gObjTokens;
public static TNH_Manager tnhManager; public static TNH_Manager tnhManager;
#region INITIALIZATION
void ImproveHPTextReadability() void ImproveHPTextReadability()
{ {
var canvas = gObjHUD.GetComponent<Canvas>(); var canvas = gObjHUD.GetComponent<Canvas>();
@@ -60,10 +58,9 @@ namespace TNHQoLImprovements
if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value) if(MeatKitPlugin.cfgShowHPBackground.Value || MeatKitPlugin.cfgSolidifyHPText.Value)
ImproveHPTextReadability(); ImproveHPTextReadability();
if (MeatKitPlugin.cfgShowTokens.Value) if (MeatKitPlugin.cfgShowTokens.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter")); Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("TokenCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
if (MeatKitPlugin.cfgShowHolds.Value) if (MeatKitPlugin.cfgShowHolds.Value)
Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter")); Instantiate(MeatKitPlugin.bundle.LoadAsset<GameObject>("HoldCounter"), FindObjectOfType<TAH_Reticle>().transform.GetChild(3));
} }
#endregion
} }
} }
+26 -26
View File
@@ -15,22 +15,13 @@ namespace TNHQoLImprovements
private bool tnhTweakerInstalled = false; private bool tnhTweakerInstalled = false;
private string curID; private string curID;
private string loadingStr;
private TNH_ScoreDisplay scoreDisplay; private TNH_ScoreDisplay scoreDisplay;
private Text lblGlobalScores; private Text lblGlobalScores;
private GameObject gObjLoading; private GameObject gObjLoading;
#region INITIALIZATION #region INITIALIZATION
// public void Start()
// {
// Debug.Log("--- Installed BepInEx Plugins ---");
// foreach (var plugin in Chainloader.PluginInfos)
// {
// Debug.Log(plugin.Key);
// }
// Debug.Log("--- End Plugins ---");
//}
public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel, GameObject gObjLoading) public void Init(TNH_ScoreDisplay tnhScore, Text scoreLabel, GameObject gObjLoading)
{ {
if (initialized) if (initialized)
@@ -41,12 +32,13 @@ namespace TNHQoLImprovements
this.lblGlobalScores.resizeTextForBestFit = true; this.lblGlobalScores.resizeTextForBestFit = true;
this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow; this.lblGlobalScores.horizontalOverflow = HorizontalWrapMode.Overflow;
this.gObjLoading = gObjLoading; this.gObjLoading = gObjLoading;
loadingStr = gObjLoading.GetComponentInChildren<Text>().text;
var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies(); var loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker")) if (Array.Exists<Assembly>(loadedAssemblies, x => x.GetName().Name == "TakeAndHoldTweaker"))
{ {
tnhTweakerInstalled = true; tnhTweakerInstalled = true;
this.gObjLoading.transform.GetChild(0).GetComponent<Text>().text = "<color=lightblue>Online leaderboards player count is incompatible with TNHTweaker.</color>"; this.gObjLoading.transform.GetChild(0).GetComponent<Text>().text = "<color=lightblue><size=30>Online player count is incompatible with TNHTweaker.</size></color>";
this.gObjLoading.SetActive(true); this.gObjLoading.SetActive(true);
} }
@@ -66,23 +58,31 @@ namespace TNHQoLImprovements
} }
private void UpdatePlayerCountDisplay(string id) private void UpdatePlayerCountDisplay(string id)
{ {
try try
{ {
string playerCountText = Steamworks.SteamUserStats string playerCountText = Steamworks.SteamUserStats
.GetLeaderboardEntryCount(HighScoreManager.Leaderboards[id]) .GetLeaderboardEntryCount(HighScoreManager.Leaderboards[id])
.ToString("N0"); .ToString("N0");
lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
curID = id; lblGlobalScores.text = "Global Scores: <color=lightblue>(" + playerCountText + " players)</color>";
curID = id;
gObjLoading.SetActive(false); gObjLoading.SetActive(false);
} }
catch (KeyNotFoundException e) catch (KeyNotFoundException e)
{ {
lblGlobalScores.text = "Global Scores:"; lblGlobalScores.text = "Global Scores:";
gObjLoading.GetComponentInChildren<Text>().text = loadingStr;
gObjLoading.SetActive(true); gObjLoading.SetActive(true);
curID = null; curID = null;
}
catch (Exception e)
{
gObjLoading.GetComponentInChildren<Text>().text = string.Format("<color=lightblue><size=30>Unknown error occured trying to retrieve online player count.</size></color>\n\n" +
"<color=red>{0}</color>", e);
gObjLoading.SetActive(true);
} }
} }
} }
#endregion #endregion
} }
@@ -1,25 +1,24 @@
using HarmonyLib; using System.Reflection;
using HarmonyLib;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using FistVR; using FistVR;
namespace TNHQoLImprovements namespace TNHQoLImprovements
{ {
[HarmonyPatch] public static class LeaderboardPlayerCountPatch
public class LeaderboardPlayerCountPatch
{ {
Harmony harmony;
private static GameObject gObjLoading; private static GameObject gObjLoading;
private static Text uiGlobalText; private static Text uiGlobalText;
public LeaderboardPlayerCountPatch() public static void Patch(Harmony harmony)
{ {
harmony = new Harmony("me.muskit.TNHQualityOfLifeImprovements.LeaderboardPlayerCount"); var original = typeof(TNH_ScoreDisplay).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance);
harmony.PatchAll(); var newfunc = typeof(LeaderboardPlayerCountPatch).GetMethod("Setup");
harmony.Patch(original, postfix: new HarmonyMethod(newfunc));
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(TNH_ScoreDisplay), "Start")]
public static void Setup(TNH_ScoreDisplay __instance) public static void Setup(TNH_ScoreDisplay __instance)
{ {
GameObject gObjLeaderboard = null; GameObject gObjLeaderboard = null;
+64
View File
@@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TNHQoLImprovements
{
/// <summary>
/// Flash attached MeshRenderer the timer runs out.
/// </summary>
public class MeshRendererFlicker : MonoBehaviour
{
private bool initialized = false;
private float beginTime;
private float onLength;
private float offLength;
private float stateChangeTime = 0;
private bool visible = true;
private MeshRenderer mesh;
void Start()
{
mesh = GetComponent<MeshRenderer>();
}
public void Init(float interval, float onToOffRatio = 0.5f, float beginAfter = 0)
{
beginTime = Time.time + beginAfter;
onLength = interval * onToOffRatio;
offLength = interval * (1 - onToOffRatio);
initialized = true;
}
void Update()
{
if (!initialized || Time.time < beginTime)
return;
if (Time.time >= stateChangeTime)
{
visible = !visible;
mesh.enabled = visible;
if (visible) // set time to stay on
{
stateChangeTime = Time.time + onLength;
}
else // set time to stay off
{
stateChangeTime = Time.time + offLength;
}
}
//if (Time.time >= stateChangeTime)
// {
// stateChangeTime = Time.time + interval;
// visible = !visible;
// mesh.enabled = visible;
// }
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 41ced368c613e2444bdbb07051989499
timeCreated: 1643160950
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,57 @@
using System.Reflection;
using HarmonyLib;
using UnityEngine;
using FistVR;
namespace TNHQoLImprovements
{
/// <summary>
/// If KillAfter is attached to a HealthCrystal, show visual representation of expiration.
/// </summary>
public static class TimedHealthCrystalPatch
{
private static GameObject timerAsset;
public const int VISUAL_APPROACH = 2;
public static void Patch(Harmony harmony)
{
timerAsset = MeatKitPlugin.bundle.LoadAsset<GameObject>("HealthCrystalTimer");
var original = typeof(KillAfter).GetMethod("Start", BindingFlags.NonPublic | BindingFlags.Instance);
var newfunc = typeof(TimedHealthCrystalPatch).GetMethod("Setup");
harmony.Patch(original, postfix: new HarmonyMethod(newfunc));
}
public static void Setup(KillAfter __instance)
{
// only work with Health Crystals
if (__instance.transform.GetComponentInChildren<HealthPickUp>() == null)
return;
Debug.Log("KillAfter will expire in " + __instance.DieTime + " seconds.");
GameObject timer;
Transform healthCrystal = __instance.transform.Find("HealthCrystal");
switch (VISUAL_APPROACH)
{
case 0: // ring above
timer = GameObject.Instantiate<GameObject>(timerAsset, healthCrystal);
timer.GetComponent<UIRingTimer>().Init(__instance.DieTime);
timer.transform.localScale = new Vector2(0.001f, 0.001f);
timer.transform.localPosition = new Vector3(0, .9f, 0);
break;
case 1: // ring around
timer = GameObject.Instantiate<GameObject>(timerAsset, healthCrystal);
timer.GetComponent<UIRingTimer>().Init(__instance.DieTime);
timer.transform.localScale = new Vector2(0.0035f, 0.0035f);
timer.transform.localPosition = Vector3.zero;
break;
case 2: // flashing crystal
var flicker = healthCrystal.gameObject.AddComponent<MeshRendererFlicker>();
flicker.Init(.4f, 0.6f, __instance.DieTime - 3f);
break;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e2d8d57a4a90c704da061837b5f7b16a
timeCreated: 1643082249
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-2
View File
@@ -9,8 +9,6 @@ namespace TNHQoLImprovements
{ {
void Start() void Start()
{ {
//transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(1, 0, -.5f); transform.localPosition = new Vector3(1, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0); transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f); transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
+33
View File
@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIRingTimer : MonoBehaviour {
private bool initialized = false;
private float endTime;
private float length;
private Image ringImg;
private void Start()
{
ringImg = GetComponentInChildren<Image>();
}
public void Init(float timeInSeconds)
{
length = timeInSeconds;
endTime = Time.time + length;
initialized = true;
}
void Update () {
if (!initialized)
return;
float amount = (endTime - Time.time) / length;
ringImg.fillAmount = Mathf.Clamp01(amount);
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c0cc182175a3417499d53e43378f028c
timeCreated: 1643099834
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 202273f3dee1d244dbfc63238c672310
folderAsset: yes
timeCreated: 1643099086
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

+76
View File
@@ -0,0 +1,76 @@
fileFormatVersion: 2
guid: 3677786155d617b4cb39bf42eddd24ad
timeCreated: 1643099089
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant: