Decompiled source of Campfire Safe Zone For Kins Chaotic Trials v1.0.1

BepInEx/plugins/Safe_Campfire.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 KinsChaoticTrials;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Safe_Campfire")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Safe_Campfire")]
[assembly: AssemblyTitle("Safe_Campfire")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
namespace SafeCampfire
{
	[BepInPlugin("safecampfire", "Safe_Campfire", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> targetPlayersAroundCampfire;

		internal static ConfigEntry<float> campfireSafetyDistance;

		internal static ConfigEntry<bool> targetPassedOutPlayers;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			targetPlayersAroundCampfire = ((BaseUnityPlugin)this).Config.Bind<bool>("Targeting Options", "Target Players Around Campfire", false, (ConfigDescription)null);
			campfireSafetyDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Targeting Options", "Campfire Safety Distance", 25f, (ConfigDescription)null);
			targetPassedOutPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Targeting Options", "Target Passed Out Players", false, (ConfigDescription)null);
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin Safe Campfire is loaded!");
			Harmony val = new Harmony("safecampfire");
			val.PatchAll();
		}
	}
	internal static class TheCampfires
	{
		public static List<Campfire> campfires = new List<Campfire>();

		public static bool IsSafe(Vector3 charCenter)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.targetPlayersAroundCampfire.Value)
			{
				return false;
			}
			if (campfires.Count == 0 || (Object)(object)campfires[0] == (Object)null)
			{
				campfires = Object.FindObjectsByType<Campfire>((FindObjectsInactive)1, (FindObjectsSortMode)0).ToList();
			}
			foreach (Campfire campfire in campfires)
			{
				if (Vector3.Distance(charCenter, ((Component)campfire).transform.position) < Plugin.campfireSafetyDistance.Value)
				{
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(KinsChaoticTrials), "GetRandomLocationNearPlayer")]
	internal static class TumbleSpawnPatch
	{
		[HarmonyPrefix]
		internal static bool Prefix(KinsChaoticTrials __instance, ref Vector3 __result, float min_distance, float max_distance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			Character val = new Character();
			val = Util.RandomSelection<Character>((IEnumerable<Character>)Character.AllCharacters, (Func<Character, int>)((Character character) => Convert.ToInt32(!character.data.dead)));
			if ((Object)(object)val == (Object)null)
			{
				__result = new Vector3(0f, 0f, 0f);
				return false;
			}
			if ((!Plugin.targetPassedOutPlayers.Value && val.data.passedOut) || TheCampfires.IsSafe(val.Center))
			{
				__result = new Vector3(0f, 0f, 0f);
				return false;
			}
			__result = KinsChaoticTrials.GetRandomLocationNearLocation(val.Center + new Vector3(0f, 300f, 0f), min_distance, max_distance);
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}