using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using KinsChaoticTrials;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;
[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 ConfigEntry<float> raycastFrom;
internal static ConfigEntry<bool> includePrevCampfire;
internal static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
targetPlayersAroundCampfire = ((BaseUnityPlugin)this).Config.Bind<bool>("Targeting Options", "Target Players Around Campfire", false, (ConfigDescription)null);
includePrevCampfire = ((BaseUnityPlugin)this).Config.Bind<bool>("Targeting Options", "Include Previous Campfire", true, (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);
raycastFrom = ((BaseUnityPlugin)this).Config.Bind<float>("Targeting Options", "Raycast From Height", 300f, (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 bool stopDontQueue;
public static bool IsSafe(Vector3 charCenter)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.targetPlayersAroundCampfire.Value)
{
return false;
}
if (DistanceToCampfire(charCenter, Singleton<MapHandler>.Instance.currentSegment) < Plugin.campfireSafetyDistance.Value)
{
return true;
}
if (Plugin.includePrevCampfire.Value && DistanceToCampfire(charCenter, Singleton<MapHandler>.Instance.currentSegment - 1) < Plugin.campfireSafetyDistance.Value)
{
return true;
}
return false;
}
public static float DistanceToCampfire(Vector3 position, int currentSeg)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (currentSeg == -1)
{
return Vector3.Distance(position, Singleton<MapHandler>.Instance.segments[0].reconnectSpawnPos.position);
}
if ((Object)(object)Singleton<MapHandler>.Instance.segments[currentSeg].segmentCampfire == (Object)null)
{
return float.MaxValue;
}
return Vector3.Distance(position, Singleton<MapHandler>.Instance.segments[currentSeg].segmentCampfire.transform.position);
}
public static async void TryCleanup()
{
if (stopDontQueue)
{
return;
}
stopDontQueue = true;
await Awaitable.NextFrameAsync(default(CancellationToken));
RemoveAfterSeconds[] allChaos = Object.FindObjectsByType<RemoveAfterSeconds>((FindObjectsSortMode)0);
RemoveAfterSeconds[] array = allChaos;
foreach (RemoveAfterSeconds r in array)
{
if (((Component)r).transform.position.y <= 0f)
{
PhotonNetwork.Destroy(((Component)r).gameObject);
}
}
stopDontQueue = false;
}
}
[HarmonyPatch(typeof(KinsChaoticTrials), "GetRandomLocationNearPlayer")]
internal static class TargetingPatch
{
[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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
Character val = new Character();
int num = 10;
bool flag = false;
while (num > 0 && !flag)
{
flag = true;
val = Util.RandomSelection<Character>((IEnumerable<Character>)Character.AllCharacters, (Func<Character, int>)((Character character) => Convert.ToInt32(!character.data.dead)));
if ((!Plugin.targetPassedOutPlayers.Value && val.data.passedOut) || TheCampfires.IsSafe(val.Center) || (Object)(object)val == (Object)null)
{
flag = false;
}
num--;
}
if (!flag)
{
__result = Vector3.zero;
return false;
}
__result = KinsChaoticTrials.GetRandomLocationNearLocation(val.Center + new Vector3(0f, Plugin.raycastFrom.Value, 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)
{
}
}
}