Decompiled source of Warming Lava v1.0.0

warmingLava.dll

Decompiled 2 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("spawnScoutmaster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("spawnScoutmaster")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("32b85ea7-95a5-4fec-b1c9-f3f3e9d550ab")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("tony4twentys.warmingLava", "Warming Lava", "1.0.0")]
public class LavaColdReducer : BaseUnityPlugin
{
	private Character player;

	private float checkInterval = 0.5f;

	private float checkTimer = 0f;

	private ConfigEntry<float> ColdReductionPerSecond;

	private ConfigEntry<float> WarmthRadius;

	private void Awake()
	{
		ColdReductionPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "ColdReductionPerSecond", 0.1f, "Amount of Cold reduced per second while near lava.");
		WarmthRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "WarmthRadius", 8f, "Radius around Lava or LavaRiver that applies warmth effect.");
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"LavaColdReducer loaded. ColdReduction/s: {ColdReductionPerSecond.Value}, Radius: {WarmthRadius.Value}");
	}

	private void Update()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null)
		{
			player = Character.localCharacter;
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
		}
		checkTimer -= Time.deltaTime;
		if (checkTimer <= 0f)
		{
			checkTimer = checkInterval;
			if (IsNearLava(player.Center))
			{
				float num = ColdReductionPerSecond.Value * checkInterval;
				player.refs.afflictions.AdjustStatus((STATUSTYPE)2, 0f - num, false);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Warming player near lava. Cold reduced by {num}.");
			}
		}
	}

	private bool IsNearLava(Vector3 position)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		Lava[] array = Object.FindObjectsOfType<Lava>();
		foreach (Lava val in array)
		{
			if (Vector3.Distance(position, ((Component)val).transform.position) < WarmthRadius.Value)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Player is near Lava.");
				return true;
			}
		}
		LavaRiver[] array2 = Object.FindObjectsOfType<LavaRiver>();
		foreach (LavaRiver val2 in array2)
		{
			foreach (LavaRiverFrame frame in val2.frames)
			{
				if (Vector3.Distance(position, frame.position) < WarmthRadius.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Player is near LavaRiver.");
					return true;
				}
			}
		}
		return false;
	}
}