using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Entities.Player;
using Entities.Shared;
using HarmonyLib;
using KinematicCharacterController.Examples;
using Managers;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("hp_shake")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e6709e7870fdd311b7f0350a18cd0b2bd5d460f5")]
[assembly: AssemblyProduct("hp_shake")]
[assembly: AssemblyTitle("hp_shake")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace hp_shake;
internal class HP_Shake_Component : MonoBehaviour
{
private static ExampleCharacterCamera active_camera;
private static float progress = 420f;
private static float scale = 1f;
private static float lastWrittenScale = -1f;
private static bool GUIShow = false;
private static readonly string Path = Application.persistentDataPath + "/hp_shake.cfg";
private void Awake()
{
try
{
scale = float.Parse(File.ReadAllText(Path));
lastWrittenScale = scale;
}
catch
{
}
Harmony.CreateAndPatchAll(typeof(HP_Shake_Component), (string)null);
}
private void OnGUI()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (GUIShow)
{
GUI.Box(new Rect(10f, 10f, 100f, 80f), "HPShake Scale");
scale = GUI.HorizontalSlider(new Rect(20f, 40f, 80f, 20f), scale, 0f, 2f);
GUI.TextArea(new Rect(20f, 60f, 80f, 20f), scale.ToString());
}
}
private void Update()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
if (lastWrittenScale != scale)
{
try
{
lastWrittenScale = scale;
File.WriteAllText(Path, scale.ToString());
}
catch
{
}
}
if (Input.GetKeyDown((KeyCode)287))
{
GUIShow = !GUIShow;
}
if ((int)InputManager.LockState == 1 && Object.op_Implicit((Object)(object)active_camera) && Object.op_Implicit((Object)(object)PlayerManager.LocalPlayerObject))
{
PlayerHealth val = default(PlayerHealth);
PlayerManager.LocalPlayerObject.TryGetComponent<PlayerHealth>(ref val);
if (Object.op_Implicit((Object)(object)val))
{
float currentValue = ((NetValue)val).CurrentValue;
float maxValue = ((NetValue)val).MaxValue;
float num = Math.Abs(currentValue / maxValue - 1f) * 5f * scale;
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor((Mathf.PerlinNoise(progress, 0f) - 0.466666f + Mathf.PerlinNoise(progress / 10f, 0f) - 0.466666f) * num, (Mathf.PerlinNoise(0f, progress) - 0.466666f + Mathf.PerlinNoise(0f, progress / 10f) - 0.466666f) * num, 0f);
active_camera.UpdateWithInput(0f, 0f, val2);
progress += 0.01f;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ExampleCharacterCamera), "Awake")]
private static void OverrideAwake(ExampleCharacterCamera __instance)
{
if ((!Object.op_Implicit((Object)(object)active_camera) || !((Behaviour)active_camera).isActiveAndEnabled) && ((Behaviour)__instance).isActiveAndEnabled)
{
active_camera = __instance;
}
}
}
[BepInPlugin("hp_shake", "HP Shake", "0.0.2")]
public class HP_Shake : BasePlugin
{
internal static ManualLogSource Log;
public override void Load()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
((BasePlugin)this).AddComponent<HP_Shake_Component>();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin hp_shake loaded successfully.");
}
log.LogInfo(val);
}
}