Skip to content

Commit

Permalink
fix in-play stuff not working in other maps
Browse files Browse the repository at this point in the history
  • Loading branch information
muskit committed Jan 24, 2022
1 parent b259424 commit 6f938e9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
16 changes: 13 additions & 3 deletions Assets/MeatKit/MeatKitPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class MeatKitPlugin : BaseUnityPlugin
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
#pragma warning restore 414
public static AssetBundle bundle;
public static ConfigEntry<bool> cfgShowLPC;
public static ConfigEntry<bool> cfgSolidifyHPText;
public static ConfigEntry<bool> cfgShowHPBackground;
public static ConfigEntry<float> cfgHPBackgroundOpacity;
Expand All @@ -48,12 +49,16 @@ public class MeatKitPlugin : BaseUnityPlugin
private void SceneChanged(Scene from, Scene to)
{
//Logger.LogInfo(string.Format("scene chg: {0} --> {1}", from.name, to.name));
if(GameObject.Find("_NewTAHReticle") != null)
Logger.LogInfo("_GameManager present: " + (GameObject.Find("_GameManager") != null));
Logger.LogInfo("TNH_Manager object present: " + (FindObjectOfType<FistVR.TNH_Manager>() != null));
if(GameObject.Find("_GameManager") != null || FindObjectOfType<FistVR.TNH_Manager>() != null)
{
Logger.LogInfo("We are in a TNH game!");
instance = new GameObject().AddComponent<InPlay>();
}
else
{
Logger.LogInfo("We are NOT in a TNH game!");
Destroy(instance);
}
}
Expand All @@ -78,6 +83,10 @@ private void Awake()
"Solidify HP text",
true,
"Set opacity of HP text to full and give it a shadow.");
cfgShowLPC = Config.Bind("Game Info",
"Show player count in online leaderboards",
true,
"Shows the number of players in the currently selected TNH leaderboard.");
cfgShowTokens = Config.Bind("Game Info",
"Show Tokens",
true,
Expand All @@ -88,7 +97,8 @@ private void Awake()
"Shows how many holds the player has completed by their radar hand.");

// patch leaderboard code
lpc = new LeaderboardPlayerCountPatch();
if (cfgShowLPC.Value)
lpc = new LeaderboardPlayerCountPatch();

// give 120 seconds to search for old mod
lpcModSearchTimeEnd = Time.realtimeSinceStartup + 120;
Expand Down Expand Up @@ -116,7 +126,7 @@ private void Update()

if (Time.realtimeSinceStartup >= lpcModSearchTimeEnd)
{
Logger.LogWarning("Stopping search for TNH Leaderboard Player Count mod after 120 seconds.");
Logger.LogInfo("Stopping search for TNH Leaderboard Player Count mod after 120 seconds.");
lpcModGone = true;
}
}
Expand Down
16 changes: 14 additions & 2 deletions Assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@
This mod adds quality of life improvements to the *Take and Hold* experience.

## Features
* More visible HP counter
* Better Health counter visibility
* Token and hold counter on wrist
* Player count for online leaderboards; see how you stack up!
* Incompatible with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/); feature will be disabled!
* Won't work with [*TakeAndHoldTweaker*](https://h3vr.thunderstore.io/package/devyndamonster/TakeAndHoldTweaker/) installed

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).

## Changelog
1.0.1
* Fixed the in-play improvements only applying in Classic Hallways map (whoops!!)
* Added option to enable/disable showing player count of online leaderboards
* Added option to enable/disable HP text opacity/shadow change
* (Surprisingly, the HP text normally doesn't have full opacity)
* Searching for TNH Leaderboards Player Count now stops after 120s


1.0.0
* Initial release!

**NOTE: [*TNH Leaderboard Player Count*](https://h3vr.thunderstore.io/package/muskit/TNH_Leaderboard_Player_Count/) has been merged with this mod. If installed, please remove that mod as it lacks features and is no longer supported.**
11 changes: 9 additions & 2 deletions Assets/_Scripts/HoldCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ public class HoldCounter : MonoBehaviour
private void OnDeath(bool _)
{
Debug.Log("I died!");
}

// TODO: lose counter. patch postfix FistVR.TNH_Manager.HoldPointCompleted
private void OnHoldLose()
{

}

void Start()
{
transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
//transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(-1f, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);

GameObject.Find("[SceneSettings]").GetComponent<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
FindObjectOfType<FVRSceneSettings>().PlayerDeathEvent += OnDeath;
}

void Update()
Expand Down
7 changes: 4 additions & 3 deletions Assets/_Scripts/TokenCounter.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using FistVR;

namespace TNHQoLImprovements
{
public class TokenCounter : MonoBehaviour
{
void Start()
{
transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
//transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
transform.parent = FindObjectOfType<TAH_Reticle>().transform.GetChild(3);
transform.localPosition = new Vector3(1, 0, -.5f);
transform.localRotation = Quaternion.Euler(90, 0, 0);
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
Expand All @@ -31,7 +32,7 @@ private IEnumerator SetTokenImage()
else
{
debug_iterations++;
yield return new WaitForSeconds(0.25f);
yield return new WaitForEndOfFrame();
}
}
Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations.");
Expand Down

0 comments on commit 6f938e9

Please sign in to comment.