using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HutongGames.PlayMaker;
using Microsoft.CodeAnalysis;
using StarterAssets;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("GoatlerSMTHealth")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cc6557c88a581717920f3adf6973eea65d385dfd")]
[assembly: AssemblyProduct("GoatlerSMTHealth")]
[assembly: AssemblyTitle("GoatlerSMTHealth")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class PlayerHealth : MonoBehaviour
{
public float maxHealth = 100f;
public float currentHealth;
private void Start()
{
currentHealth = maxHealth;
}
public void TakeDamage(float amount)
{
NamedVariable[] allNamedVariables = GameCanvas.Instance.jReference.GetComponent<PlayMakerFSM>().FsmVariables.GetAllNamedVariables();
if (((object)allNamedVariables[0]).ToString() == "0" || HealthMod.ReceiveDamageInJail.Value)
{
currentHealth = Mathf.Clamp(currentHealth - amount, 0f, maxHealth);
if (currentHealth <= 0f)
{
Die(0f - HealthMod.DeathCost.Value);
}
}
}
public void Heal(float amount)
{
currentHealth = Mathf.Clamp(currentHealth + amount, 0f, maxHealth);
}
public void Die(float cost)
{
GameData.Instance.UserCode_CmdAlterFunds__Single(cost);
if (HealthMod.SendToJail.Value)
{
((Component)FirstPersonController.Instance).GetComponent<PlayerPermissions>().UserCode_RpcJPlayer__Int32(HealthMod.NumJailClicks.Value);
}
currentHealth = maxHealth;
}
}
[BepInPlugin("GoatlerSMTHealth", "SMT Hardcore", "1.3.0")]
public class HealthMod : BaseUnityPlugin
{
public static ManualLogSource Logger;
private static Harmony harmonyThingySomethingUhh = new Harmony("harmonyThingySomethingUhh");
public static ConfigEntry<float> DeathCost;
public static ConfigEntry<bool> SendToJail;
public static ConfigEntry<int> NumJailClicks;
public static ConfigEntry<float> BroomDamage;
public static ConfigEntry<float> DeleteDamage;
public static ConfigEntry<float> NotFoundDamage;
public static ConfigEntry<float> ThiefDamage;
public static ConfigEntry<float> TooExpensiveDamage;
public static ConfigEntry<float> OverdueLoanDamage;
public static ConfigEntry<bool> ReceiveDamageInJail;
public static ConfigEntry<float> SetPricesDamage;
public static ConfigEntry<float> TimeAcceleratorDamage;
private void Awake()
{
DeathCost = ((BaseUnityPlugin)this).Config.Bind<float>("General.Death", "DeathCost", 500f, "This is the amount of money you will lose when you die, pick a negative value zero or higher.");
SendToJail = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Death", "SendToJail", true, "Should the player be sent to jail when they die?");
NumJailClicks = ((BaseUnityPlugin)this).Config.Bind<int>("General.Death", "NumJailClicks", 10, "When the player gets sent to jail on death, how many times should they have to click to escape?");
BroomDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "BroomDamage", 20f, "How much damage should it deal when hit with a broom?");
DeleteDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "DeleteDamage", 5f, "How much damage should it deal when deleting something from your store?");
NotFoundDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "NotFoundDamage", 10f, "How much damage should it deal when a customer can't find a product they're looking for?");
ThiefDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "ThiefDamage", 10f, "How much damage should it deal when a thief successfully robs your store?");
TooExpensiveDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "TooExpensiveDamage", 10f, "How much damage should it deal when a customer finds an item that's too expensive?");
OverdueLoanDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "OverdueLoanDamage", 5f, "How much damage should it deal per day a loan is overdue?");
ReceiveDamageInJail = ((BaseUnityPlugin)this).Config.Bind<bool>("General.Damage", "ReceiveDamageInJail", false, "Should damage be dealt to the player while in jail?");
SetPricesDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "SetPricesDamage", 10f, "How much damage should it deal when you use the pricing machine to set all prices?");
TimeAcceleratorDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General.Damage", "TimeAcceleratorDamage", 10f, "How much damage should it deal when you use the clock on the wall to speed up time?");
Logger = ((BaseUnityPlugin)this).Logger;
harmonyThingySomethingUhh.PatchAll();
}
}
public class UIManager : MonoBehaviour
{
private static Slider healthSlider;
public static PlayerHealth playerHealth;
public static void SpawnHealthUI()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Expected O, but got Unknown
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Expected O, but got Unknown
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)FirstPersonController.Instance == (Object)null)
{
HealthMod.Logger.LogInfo((object)"FirstPersonController instance returned null");
}
GameObject gameObject = ((Component)FirstPersonController.Instance).gameObject;
if ((Object)(object)gameObject == (Object)null)
{
HealthMod.Logger.LogInfo((object)"Player game object returned null");
}
if ((Object)(object)gameObject.GetComponent<PlayerHealth>() == (Object)null)
{
gameObject.AddComponent<PlayerHealth>();
}
playerHealth = gameObject.GetComponent<PlayerHealth>();
GameObject val = new GameObject("HealthCanvas");
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
CanvasScaler val3 = val.AddComponent<CanvasScaler>();
val3.uiScaleMode = (ScaleMode)1;
val3.referenceResolution = new Vector2(1920f, 1080f);
val3.screenMatchMode = (ScreenMatchMode)0;
val3.matchWidthOrHeight = 0.5f;
val.AddComponent<GraphicRaycaster>();
val.transform.SetParent(((Component)GameCanvas.Instance).transform, false);
GameObject val4 = new GameObject("HealthSlider", new Type[3]
{
typeof(RectTransform),
typeof(CanvasRenderer),
typeof(Slider)
});
val4.transform.SetParent(val.transform, false);
RectTransform component = val4.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(200f, 20f);
component.anchorMin = new Vector2(0.5f, 1f);
component.anchorMax = new Vector2(0.5f, 1f);
component.pivot = new Vector2(0.5f, 1f);
component.anchoredPosition = new Vector2(0f, -40f);
healthSlider = val4.GetComponent<Slider>();
healthSlider.minValue = 0f;
healthSlider.maxValue = 100f;
healthSlider.value = 100f;
GameObject val5 = new GameObject("Background", new Type[1] { typeof(Image) });
val5.transform.SetParent(val4.transform, false);
Image component2 = val5.GetComponent<Image>();
((Graphic)component2).color = Color.gray;
RectTransform component3 = val5.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.offsetMin = Vector2.zero;
component3.offsetMax = Vector2.zero;
GameObject val6 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) });
val6.transform.SetParent(val4.transform, false);
RectTransform component4 = val6.GetComponent<RectTransform>();
component4.anchorMin = new Vector2(0f, 0f);
component4.anchorMax = new Vector2(1f, 1f);
component4.offsetMin = new Vector2(5f, 5f);
component4.offsetMax = new Vector2(-5f, -5f);
GameObject val7 = new GameObject("Fill", new Type[1] { typeof(Image) });
val7.transform.SetParent(val6.transform, false);
Image component5 = val7.GetComponent<Image>();
((Graphic)component5).color = Color.red;
RectTransform component6 = val7.GetComponent<RectTransform>();
component6.anchorMin = Vector2.zero;
component6.anchorMax = Vector2.one;
component6.offsetMin = Vector2.zero;
component6.offsetMax = Vector2.zero;
healthSlider.fillRect = component6;
if ((Object)(object)val.GetComponent<UIManager>() == (Object)null)
{
val.AddComponent<UIManager>();
}
}
private void Update()
{
if ((Object)(object)healthSlider != (Object)null && (Object)(object)playerHealth != (Object)null)
{
healthSlider.value = playerHealth.currentHealth;
}
}
}
namespace GoatlerSMTHealth
{
[HarmonyPatch(typeof(DebtManager))]
internal class DebtManagerPatch
{
[HarmonyPatch("RetrieveTotalLoanLeftFromInvoices")]
[HarmonyPostfix]
public static void debtManagerPatch(DebtManager __instance)
{
int num = 0;
int num2 = default(int);
float num3 = default(float);
int num4 = default(int);
int num5 = default(int);
string text2 = default(string);
for (int i = 0; i < __instance.currentInvoicesData.Length; i++)
{
string text = __instance.currentInvoicesData[i];
if (text != "")
{
__instance.GetInvoiceDataValues(text, ref num2, ref num3, ref num4, ref num5, ref text2);
int gameDay = GameData.Instance.gameDay;
num += gameDay - num5;
}
}
UIManager.playerHealth.TakeDamage((float)num * HealthMod.OverdueLoanDamage.Value);
}
}
[HarmonyPatch(typeof(FirstPersonController))]
internal class FirstPersonControllerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void elizabeth(FirstPersonController __instance)
{
UIManager.SpawnHealthUI();
}
}
[HarmonyPatch(typeof(GameData))]
internal class GameDataPatch
{
[HarmonyPatch("CmdAlterFundsWithoutExperience")]
[HarmonyPostfix]
public static void deleteBehaviourPatch(GameData __instance)
{
UIManager.playerHealth.TakeDamage(HealthMod.DeleteDamage.Value);
}
[HarmonyPatch("AddExpensiveList")]
[HarmonyPostfix]
public static void tooExpensivePatch(GameData __instance)
{
UIManager.playerHealth.TakeDamage(HealthMod.TooExpensiveDamage.Value);
}
[HarmonyPatch("AddNotFoundList")]
[HarmonyPostfix]
public static void notFoundPatch(GameData __instance)
{
UIManager.playerHealth.TakeDamage(HealthMod.NotFoundDamage.Value);
}
}
[HarmonyPatch(typeof(NPC_Info))]
internal class NPC_InfoPatch
{
[HarmonyPatch("OnDestroy")]
[HarmonyPostfix]
public static void destroyNPCPatch(NPC_Info __instance)
{
if (__instance.isAThief)
{
UIManager.playerHealth.TakeDamage(HealthMod.ThiefDamage.Value);
}
}
}
[HarmonyPatch(typeof(PlayerNetwork))]
internal class PlayerNetworkPatch
{
[HarmonyPatch("InvokeUserCode_RpcPushPlayer__Vector3")]
[HarmonyPostfix]
public static void broomHitPatch(PlayerNetwork __instance)
{
UIManager.playerHealth.TakeDamage(HealthMod.BroomDamage.Value);
}
}
[HarmonyPatch(typeof(PricingMachine))]
internal class PricingMachinePatch
{
[HarmonyPatch("SetAllPercentages")]
[HarmonyPostfix]
public static void setPricesPatch(PricingMachine __instance)
{
HealthMod.Logger.LogInfo((object)"Test pricing damage");
UIManager.playerHealth.TakeDamage(HealthMod.SetPricesDamage.Value);
}
}
[HarmonyPatch(typeof(UpgradesManager))]
internal class UpgradesManagerPatch
{
[HarmonyPatch("SetAccelerationMethod")]
[HarmonyPostfix]
public static void timeAccelerationPatch(UpgradesManager __instance)
{
if (__instance.acceleratedTime)
{
UIManager.playerHealth.TakeDamage(HealthMod.TimeAcceleratorDamage.Value);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}