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 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("AntiEarlyFlare")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d7d45e7fd59c872f29007b8fe87fbfbab8cf0f1d")] [assembly: AssemblyProduct("AntiEarlyFlare")] [assembly: AssemblyTitle("AntiEarlyFlare")] [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; } } } [BepInPlugin("AntiEarlyFlare", "Anti-Early Flare", "1.2.2")] public class AntiEarlyFlare : BaseUnityPlugin { [HarmonyPatch(typeof(Flare))] public class FlarePatcher { private static bool HasFlareBeenActivatedEarly(Flare flare) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) bool value = ((ItemComponent)flare).GetData((DataEntryKey)3).Value; if ((Object)(object)Singleton.Instance == (Object)null || (Object)(object)Singleton.Instance == (Object)null) { return false; } ConfigEntry checkFlareUseBeforeFinalBiome = CheckFlareUseBeforeFinalBiome; if (checkFlareUseBeforeFinalBiome != null && checkFlareUseBeforeFinalBiome.Value) { return value; } bool flag = Singleton.Instance.IsAtPeak(((Component)((ItemComponent)flare).item).transform.position); bool summonedHelicopter = Singleton.Instance.summonedHelicopter; return value && flag && !summonedHelicopter; } private static bool ShouldBlockFlare() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Character allCharacter in Character.AllCharacters) { if (!allCharacter.data.dead) { list.Add(allCharacter); } } List list2 = new List(); foreach (Character item in list) { if (Singleton.Instance.IsAtPeak(item.Center)) { list2.Add(item); } } return (float)list2.Count / (float)list.Count < ReachedPeakThreshold?.Value; } [HarmonyPrefix] [HarmonyPatch("Update")] public static bool BlockFlareActivation(Flare __instance) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient) { return true; } if (HasFlareBeenActivatedEarly(__instance) && ShouldBlockFlare()) { ManualLogSource log = Log; Character holderCharacter = ((ItemComponent)__instance).item.holderCharacter; log.LogInfo((object)(((holderCharacter != null) ? holderCharacter.characterName : null) + " tried to light the flare early!")); if (Object.op_Implicit((Object)(object)((ItemComponent)__instance).item.holderCharacter)) { ConfigEntry smiteEarlyFlareUser = SmiteEarlyFlareUser; if (smiteEarlyFlareUser != null && smiteEarlyFlareUser.Value) { Rigidbody component = ((Component)((ItemComponent)__instance).item).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { freezeNextDroppedFlarePosition = component.position; freezeNextDroppedFlareRotation = component.rotation; shouldFreezeNextDroppedFlare = true; } ManualLogSource log2 = Log; Character holderCharacter2 = ((ItemComponent)__instance).item.holderCharacter; log2.LogInfo((object)(((holderCharacter2 != null) ? holderCharacter2.characterName : null) + " is being slain...")); Character holderCharacter3 = ((ItemComponent)__instance).item.holderCharacter; if (holderCharacter3 != null) { holderCharacter3.view.RPC("RPCA_Die", (RpcTarget)0, new object[1] { ((ItemComponent)__instance).item.holderCharacter.Center + Vector3.up * 0.2f + Vector3.forward * 0.1f }); } } } ((ItemComponent)__instance).GetData((DataEntryKey)3).Value = false; ((ItemComponent)__instance).item.SetUseRemainingPercentage(1f); OptionableIntItemData data = ((ItemComponent)__instance).item.GetData((DataEntryKey)2); data.HasData = true; data.Value = 1; return false; } return true; } [HarmonyPrefix] [HarmonyPatch("SetFlareLitRPC")] public static bool BlockFlareRPC(Flare __instance) { if (!PhotonNetwork.IsMasterClient) { return true; } return !HasFlareBeenActivatedEarly(__instance) || !ShouldBlockFlare(); } [HarmonyPrefix] [HarmonyPatch("TriggerHelicopter")] public static bool BlockHelicopterRPC(Flare __instance) { if (!PhotonNetwork.IsMasterClient) { return true; } return !ShouldBlockFlare(); } } [HarmonyPatch(typeof(Item))] public class ItemPatcher { [HarmonyPostfix] [HarmonyPatch("SetItemInstanceDataRPC")] public static void FreezeFlare(Item __instance, ItemInstanceData instanceData) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) ItemComponent? obj = ((IEnumerable)__instance.itemComponents).FirstOrDefault((Func)((ItemComponent x) => x is Flare)); Flare val = (Flare)(object)((obj is Flare) ? obj : null); if ((Object)(object)val != (Object)null && shouldFreezeNextDroppedFlare) { Log.LogInfo((object)"Freezing flare in place..."); Rigidbody component = ((Component)val).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.isKinematic = false; component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.constraints = (RigidbodyConstraints)126; component.position = freezeNextDroppedFlarePosition; component.rotation = freezeNextDroppedFlareRotation; ((Component)((ItemComponent)val).item).transform.position = freezeNextDroppedFlarePosition; ((Component)((ItemComponent)val).item).transform.rotation = freezeNextDroppedFlareRotation; } Log.LogDebug((object)$"Flare position is {freezeNextDroppedFlarePosition}"); Log.LogDebug((object)$"Flare rotation is {freezeNextDroppedFlareRotation}"); ((ItemComponent)val).GetData((DataEntryKey)3).Value = false; ((ItemComponent)val).item.SetUseRemainingPercentage(1f); OptionableIntItemData data = ((ItemComponent)val).item.GetData((DataEntryKey)2); data.HasData = true; data.Value = 1; shouldFreezeNextDroppedFlare = false; } } } internal static ConfigEntry? ReachedPeakThreshold; internal static ConfigEntry? CheckFlareUseBeforeFinalBiome; internal static ConfigEntry? SmiteEarlyFlareUser; protected static bool shouldFreezeNextDroppedFlare; protected static Vector3 freezeNextDroppedFlarePosition; protected static Quaternion freezeNextDroppedFlareRotation; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ReachedPeakThreshold = ((BaseUnityPlugin)this).Config.Bind("General", "ReachedPeakThreshold", 0.5f, new ConfigDescription("Ratio of scouts that need to be at the Peak before the flare can be used properly.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); CheckFlareUseBeforeFinalBiome = ((BaseUnityPlugin)this).Config.Bind("General", "CheckFlareUseBeforeFinalBiome", false, "If enabled, checks will trigger when a flare is used in any biome."); SmiteEarlyFlareUser = ((BaseUnityPlugin)this).Config.Bind("General", "SmiteEarlyFlareUser", false, "If enabled, smites anyone trying to use the flare early."); Patch(); Log.LogInfo((object)"Plugin AntiEarlyFlare is loaded!"); } private void Patch() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("HarmonyPatcher"); val.PatchAll(); } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }