mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
update MeatKit (9a1a68ab68cd0650227af944ffa30d1166b9e056)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
#if H3VR_IMPORTED
|
||||
using System.Collections;
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using BepInEx;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Logging;
|
||||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -16,29 +19,31 @@ using Sodalite;
|
||||
|
||||
/*
|
||||
* SUPER LARGE WARNING ABOUT THIS CLASS
|
||||
* This class can be used to add custom behaviour to your generated BepInEx plugin.
|
||||
* Please note, however, that all of the things in here already are REQUIRED and CANNOT BE CHANGED.
|
||||
* There are LARGE TEXT WARNINGS above such items so you don't forget.
|
||||
* You may add to this class so long as you do not modify anything with those notices (lest you want build errors)
|
||||
* This is the default and fallback class that MeatKit uses as a template to generate a BepInEx plugin
|
||||
* when building your mod. DO NOT MODIFY THIS FILE AT ALL, IN ANY WAY.
|
||||
*
|
||||
* The class name and BepInPlugin attribute are modified at build-time to reflect your build settings.
|
||||
* BepInDependency attributes will automatically be generated if they're required by a build item, otherwise
|
||||
* may add it yourself here.
|
||||
* If you want to add custom behavior to your mod, you should make a copy of this class, and put it inside
|
||||
* the main namespace of your mod (that namespace can be found by opening the 'Allowed Namespaces' list on your build
|
||||
* profile). MeatKit will then detect and use that class instead of this one, for that one specific profile.
|
||||
*
|
||||
* HOWEVER, YOU MUST KEEP ALL OF THE STUFF FROM THIS TEMPLATE, otherwise MeatKit may fail to correctly build
|
||||
* your plugin, or your mod may fail to correctly load.
|
||||
*/
|
||||
|
||||
// DO NOT REMOVE OR CHANGE ANY OF THESE ATTRIBUTES
|
||||
[BepInPlugin("MeatKit", "MeatKit Plugin", "1.0.0")]
|
||||
[BepInProcess("h3vr.exe")]
|
||||
|
||||
// DO NOT CHANGE THE NAME OF THIS CLASS.
|
||||
// DO NOT CHANGE THE NAME OF THIS CLASS OR THE BASE CLASS. If you're making a custom plugin, make sure it extends BaseUnityPlugin.
|
||||
public class MeatKitPlugin : BaseUnityPlugin
|
||||
{
|
||||
// DO NOT CHANGE OR REMOVE THIS FIELD.
|
||||
#pragma warning disable 414
|
||||
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
internal new static ManualLogSource Logger;
|
||||
#pragma warning restore 414
|
||||
|
||||
public static AssetBundle bundle;
|
||||
public static AssetBundle bundle;
|
||||
public static Font fontAgencyFB;
|
||||
public static Font fontBombardier;
|
||||
|
||||
@@ -99,13 +104,29 @@ public class MeatKitPlugin : BaseUnityPlugin
|
||||
WristMenuAPI.Buttons.Remove(wmbHPToggle);
|
||||
}
|
||||
|
||||
// TNH patches
|
||||
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
||||
StartCoroutine("TryTNH");
|
||||
}
|
||||
|
||||
private IEnumerator TryTNH()
|
||||
{
|
||||
for (int i = 0; i < 11; ++i)
|
||||
{
|
||||
Logger.LogInfo("We are in a TNH game!");
|
||||
instance = new GameObject().AddComponent<InPlay>();
|
||||
// TNH patches
|
||||
if (GameObject.Find("_GameManager") != null || FindObjectOfType<TNH_Manager>() != null)
|
||||
{
|
||||
Logger.LogInfo("We are in a TNH game!");
|
||||
instance = new GameObject().AddComponent<InPlay>();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInfo(String.Format("Couldn't find a TNH game. Trying again...({0}/10)", i));
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
// destroy self only if we are FOR SURE not in a TNH game
|
||||
if (GameObject.Find("_GameManager") == null || FindObjectOfType<TNH_Manager>() == null)
|
||||
{
|
||||
Logger.LogInfo("We are NOT in a TNH game!");
|
||||
Destroy(instance);
|
||||
@@ -140,13 +161,20 @@ public class MeatKitPlugin : BaseUnityPlugin
|
||||
public MeatKitPlugin(): base()
|
||||
{
|
||||
harmony = new Harmony("muskit.TNHQualityOfLifeImprovements");
|
||||
lpcSearchTime = 30f + 30f * Mathf.Sin(System.DateTime.Today.DayOfYear / 365f);
|
||||
lpcSearchTime = 30f + 30f * Mathf.Sin(System.DateTime.Today.DayOfYear / 365f); // lolz
|
||||
}
|
||||
|
||||
// You are free to edit this method, however please ensure LoadAssets is still called somewhere inside it.
|
||||
private void Awake()
|
||||
{
|
||||
// MeatKit requirement
|
||||
// ----- BEGIN MEATKIT REQ. CODE -----
|
||||
// This lets you use your BepInEx-provided logger from other scripts in your project
|
||||
Logger = base.Logger;
|
||||
|
||||
// You may place code before/after this, but do not remove this call to LoadAssets
|
||||
LoadAssets();
|
||||
// ----- END MEATKIT REQ. CODE -----
|
||||
|
||||
|
||||
// get Agency FB from system (BAD IDEA, NOT EVERYONE WILL HAVE IT; MAY SET TO DEFAULT FONT)
|
||||
//fontAgencyFB = Font.CreateDynamicFontFromOSFont("Agency FB", 16);
|
||||
@@ -224,9 +252,6 @@ public class MeatKitPlugin : BaseUnityPlugin
|
||||
RunPatches();
|
||||
}
|
||||
|
||||
// DO NOT EDIT.
|
||||
private void LoadAssets() {}
|
||||
|
||||
private void RunPatches()
|
||||
{
|
||||
if (harmony == null)
|
||||
@@ -292,5 +317,11 @@ public class MeatKitPlugin : BaseUnityPlugin
|
||||
lpcStopSearching = true;
|
||||
}
|
||||
}
|
||||
|
||||
// DO NOT CHANGE OR REMOVE THIS METHOD. It's contents will be overwritten when building your package.
|
||||
private void LoadAssets()
|
||||
{
|
||||
// Code to load your build items will be generated at build-time and inserted here
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user