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 { public enum FavorType { NoFavor = 1, Favor, Disfavor } internal static ConfigEntry targetPlayersAroundCampfire; internal static ConfigEntry campfireSafetyDistance; internal static ConfigEntry targetPassedOutPlayers; internal static ConfigEntry highestPlayerFavor; internal static ConfigEntry highestPlayerFavorPower; internal static ConfigEntry lowestPlayerFavor; internal static ConfigEntry lowestPlayerFavorPower; internal static ConfigEntry gradientFavor; internal static ConfigEntry gradientExplanation1; internal static ConfigEntry gradientExplanation2; internal static ConfigEntry gradientFavorPower; internal static ConfigEntry raycastFrom; internal static ConfigEntry useCustomRaycastDirection; internal static ConfigEntry custRayX; internal static ConfigEntry custRayY; internal static ConfigEntry custRayZ; internal static ConfigEntry includePrevCampfire; internal static ConfigEntry useCustomRaycastInSegments; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown targetPlayersAroundCampfire = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Target Players Around Campfire", false, (ConfigDescription)null); includePrevCampfire = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Include Previous Campfire", true, (ConfigDescription)null); campfireSafetyDistance = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Campfire Safety Distance", 25f, (ConfigDescription)null); targetPassedOutPlayers = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Target Passed Out Players", false, (ConfigDescription)null); highestPlayerFavor = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Favor/Disfavor Highest Player (Favor Equals More Likely to be Targeted)", FavorType.NoFavor, (ConfigDescription)null); highestPlayerFavorPower = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Highest Player Favor Power", 1, (ConfigDescription)null); lowestPlayerFavor = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Favor/Disfavor Lowest Player", FavorType.NoFavor, (ConfigDescription)null); lowestPlayerFavorPower = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Lowest Player Favor Power", 1, (ConfigDescription)null); gradientFavor = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Gradient Favor", false, (ConfigDescription)null); gradientExplanation1 = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "^^^ If true, overall higher and lower players will be favored/disfavored instead of just a singular one,", true, (ConfigDescription)null); gradientExplanation2 = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "this does not use the previous favor power settings but it will use the previous favor/disfavor settings set", true, (ConfigDescription)null); gradientFavorPower = ((BaseUnityPlugin)this).Config.Bind("Targeting Options", "Gradient Power", 3, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange(2, 50), Array.Empty())); raycastFrom = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Raycast Distance", 50f, (ConfigDescription)null); useCustomRaycastInSegments = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Use Custom Raycast in Kiln", false, (ConfigDescription)null); useCustomRaycastDirection = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Use Custom Raycast Direction", false, (ConfigDescription)null); custRayX = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Custom Direction X", 0f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 1f), Array.Empty())); custRayY = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Custom Direction Y", -0.75f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 1f), Array.Empty())); custRayZ = ((BaseUnityPlugin)this).Config.Bind("Raycast Options", "Custom Direction Z", 1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 1f), Array.Empty())); Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Plugin Safe Campfire is loaded!"); Harmony val = new Harmony("safecampfire"); val.PatchAll(); } } [HarmonyPatch(typeof(MapHandler), "Awake")] public static class AddHighestandLowestPlayerHandler { public static void Prefix(MapHandler __instance) { ((Component)__instance).gameObject.AddComponent(); } } public class HighestandLowestPlayer : MonoBehaviour { public static HighestandLowestPlayer Instance; public Character HighestPlayer; public Character LowestPlayer; public List PlayersUnsafe = new List(); public float Timer; internal void Awake() { Instance = this; } internal void FixedUpdate() { //IL_0068: 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) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) Timer += Time.fixedDeltaTime; if (!(Timer > 3f)) { return; } Timer = 0f; PlayersUnsafe.Clear(); foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)HighestPlayer == (Object)null || allCharacter.Center.y > HighestPlayer.Center.y) { HighestPlayer = allCharacter; } if ((Object)(object)LowestPlayer == (Object)null || allCharacter.Center.y < LowestPlayer.Center.y) { LowestPlayer = allCharacter; } if (!TheCampfires.IsSafe(allCharacter.Center) && (Plugin.targetPassedOutPlayers.Value || !allCharacter.data.passedOut)) { PlayersUnsafe.Add(allCharacter); } } } } 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.Instance.currentSegment) < Plugin.campfireSafetyDistance.Value) { return true; } if (Plugin.includePrevCampfire.Value && DistanceToCampfire(charCenter, Singleton.Instance.currentSegment - 1) < Plugin.campfireSafetyDistance.Value) { return true; } return false; } public static float DistanceToCampfire(Vector3 position, int currentSeg) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (currentSeg == -1) { return Vector3.Distance(position, Singleton.Instance.segments[0].reconnectSpawnPos.position); } if ((int)Singleton.Instance.GetCurrentSegment() == 4 || (Object)(object)MapHandler.GetCampfireRoot(currentSeg).GetComponentInChildren() == (Object)null) { return float.MaxValue; } return Vector3.Distance(position, ((Component)MapHandler.GetCampfireRoot(currentSeg).GetComponentInChildren()).transform.position); } public static async void TryCleanup() { if (stopDontQueue) { return; } stopDontQueue = true; await Awaitable.NextFrameAsync(default(CancellationToken)); RemoveAfterSeconds[] allChaos = Object.FindObjectsByType((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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Invalid comparison between Unknown and I4 //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Expected O, but got Unknown //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Expected O, but got Unknown //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_072a: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_063e: Unknown result type (might be due to invalid IL or missing references) Character val = new Character(); if (!Plugin.gradientFavor.Value || (Plugin.highestPlayerFavor.Value == Plugin.FavorType.NoFavor && Plugin.lowestPlayerFavor.Value == Plugin.FavorType.NoFavor)) { int num = 10; int num2 = 0; int num3 = 0; switch (Plugin.highestPlayerFavor.Value) { case Plugin.FavorType.Favor: num += Plugin.highestPlayerFavorPower.Value; num2 += Plugin.highestPlayerFavorPower.Value; break; case Plugin.FavorType.Disfavor: num += Plugin.highestPlayerFavorPower.Value; num3 += Plugin.highestPlayerFavorPower.Value; break; } switch (Plugin.lowestPlayerFavor.Value) { case Plugin.FavorType.Favor: num += Plugin.lowestPlayerFavorPower.Value; num2 += Plugin.lowestPlayerFavorPower.Value; break; case Plugin.FavorType.Disfavor: num += Plugin.lowestPlayerFavorPower.Value; num3 += Plugin.lowestPlayerFavorPower.Value; break; } bool flag = false; while (num > 0 && !flag) { flag = true; val = Util.RandomSelection((IEnumerable)Character.AllCharacters, (Func)((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; } if (HighestandLowestPlayer.Instance.PlayersUnsafe.Count > 1) { if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Favor && (Object)(object)val != (Object)(object)HighestandLowestPlayer.Instance.HighestPlayer && num2 > 0) { num2--; flag = false; } else if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Disfavor && (Object)(object)val == (Object)(object)HighestandLowestPlayer.Instance.HighestPlayer && num3 > 0) { num3--; flag = false; } if (Plugin.lowestPlayerFavor.Value == Plugin.FavorType.Favor && (Object)(object)val != (Object)(object)HighestandLowestPlayer.Instance.LowestPlayer && num2 > 0) { num2--; flag = false; } else if (Plugin.lowestPlayerFavor.Value == Plugin.FavorType.Disfavor && (Object)(object)val == (Object)(object)HighestandLowestPlayer.Instance.LowestPlayer && num3 > 0) { num3--; flag = false; } } num--; } if (!flag) { __result = Vector3.zero; return false; } } else { List list = new List(); for (int i = 0; i < Plugin.gradientFavorPower.Value; i++) { list.Add(Util.RandomSelection((IEnumerable)HighestandLowestPlayer.Instance.PlayersUnsafe, (Func)((Character character) => Convert.ToInt32(!character.data.dead)))); } if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Favor || Plugin.lowestPlayerFavor.Value == Plugin.FavorType.Disfavor) { foreach (Character item in list) { if ((Object)(object)val == (Object)null || (item.Center.y > val.Center.y && HighestandLowestPlayer.Instance.PlayersUnsafe.Contains(item))) { val = item; } } } else if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Disfavor || Plugin.lowestPlayerFavor.Value == Plugin.FavorType.Favor) { foreach (Character item2 in list) { if ((Object)(object)val == (Object)null || (item2.Center.y < val.Center.y && HighestandLowestPlayer.Instance.PlayersUnsafe.Contains(item2))) { val = item2; } } } if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Favor && Plugin.highestPlayerFavor.Value == Plugin.lowestPlayerFavor.Value) { switch (Random.Range(0, 2)) { case 0: foreach (Character item3 in list) { if ((Object)(object)val == (Object)null || (item3.Center.y > val.Center.y && HighestandLowestPlayer.Instance.PlayersUnsafe.Contains(item3))) { val = item3; } } break; case 1: foreach (Character item4 in list) { if ((Object)(object)val == (Object)null || (item4.Center.y < val.Center.y && HighestandLowestPlayer.Instance.PlayersUnsafe.Contains(item4))) { val = item4; } } break; } } if (Plugin.highestPlayerFavor.Value == Plugin.FavorType.Disfavor && Plugin.highestPlayerFavor.Value == Plugin.lowestPlayerFavor.Value) { Character HighestPlayer = new Character(); Character LowestPlayer = new Character(); foreach (Character item5 in list) { if ((Object)(object)HighestPlayer == (Object)null || item5.Center.y > HighestPlayer.Center.y) { HighestPlayer = item5; } if ((Object)(object)LowestPlayer == (Object)null || item5.Center.y < LowestPlayer.Center.y) { LowestPlayer = item5; } } val = Util.RandomSelection((IEnumerable)HighestandLowestPlayer.Instance.PlayersUnsafe, (Func)((Character character) => Convert.ToInt32((Object)(object)character != (Object)(object)HighestPlayer && (Object)(object)character != (Object)(object)LowestPlayer))); if ((Object)(object)val == (Object)null) { switch (Random.Range(0, 2)) { case 0: val = LowestPlayer; break; case 1: val = HighestPlayer; break; } } } } if ((Object)(object)val == (Object)null) { __result = Vector3.zero; return false; } if (Plugin.useCustomRaycastInSegments.Value || (int)Singleton.Instance.GetCurrentSegment() != 4) { __result = KinsChaoticTrials.GetRandomLocationNearLocation(val.Center, min_distance, max_distance); } else { __result = KinsChaoticTrials.GetRandomLocationNearLocation(val.Center + new Vector3(0f, 300f, 0f), min_distance, max_distance); } return false; } } [HarmonyPatch(typeof(KinsChaoticTrials), "GetRandomLocationNearLocation")] internal static class RandomLocationPatch { internal static bool Prefix(KinsChaoticTrials __instance, Vector3 position, float min_distance, float max_distance, ref Vector3 __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) bool flag = (!Plugin.useCustomRaycastInSegments.Value && (int)Singleton.Instance.GetCurrentSegment() == 4) || !Plugin.useCustomRaycastDirection.Value; if (!flag) { float value = Plugin.raycastFrom.Value; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor((0f - Plugin.custRayX.Value) * value, (0f - Plugin.custRayY.Value) * value, (0f - Plugin.custRayZ.Value) * value); Vector3 val2 = position + val; Vector3 val3 = position - val * 50f; Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(Random.Range(min_distance, max_distance), Random.Range(min_distance, max_distance), Random.Range(min_distance, max_distance)); if (Random.Range(0f, 1f) < 0.5f) { val4.x *= -1f; } if (Random.Range(0f, 1f) < 0.5f) { val4.y *= -1f; } if (Random.Range(0f, 1f) < 0.5f) { val4.z *= -1f; } RaycastHit val5 = HelperFunctions.LineCheck(val2 + val4, val3 + val4, (LayerType)1, 0f, (QueryTriggerInteraction)1); __result = ((RaycastHit)(ref val5)).point - ((Vector3)(ref val)).normalized * 2f; return false; } return flag; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }