using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 TMPro;
using UnityEngine;
using UnityEngine.TextCore;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("legocool.TrickOrTreat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("legocool.TrickOrTreat")]
[assembly: AssemblyTitle("TrickOrTreat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 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 TrickOrTreat
{
[BepInPlugin("legocool.TrickOrTreat", "TrickOrTreat", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Luggage), "Interact_CastFinished")]
public static class LuggagePatch
{
private static bool Prefix(Luggage __instance, Character interactor)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
if (__instance is RespawnChest)
{
return true;
}
if (__instance is LuggageCursed)
{
return true;
}
if ((int)__instance.state == 0)
{
float value = TrickChance.Value;
float value2 = TreatChance.Value;
float value3 = Random.value;
if (value3 <= value && luggageOpenCount > 2)
{
TrickOrTreatUI.ShowText("TRICK", Color.red);
__instance.photonView.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { false });
Trick.TriggerTrick(__instance.GetTransform().position, interactor);
}
else
{
if (!(value3 <= value + value2))
{
luggageOpenCount++;
return true;
}
TrickOrTreatUI.ShowText("Treat", Color.green);
__instance.photonView.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { true });
Trick.TriggerTreat(__instance.GetTransform().position, interactor);
luggageOpenCount++;
}
}
GlobalEvents.TriggerLuggageOpened(__instance, interactor);
return false;
}
}
private Harmony _harmony;
public static int luggageOpenCount;
public static ConfigEntry<float> TrickChance;
public static ConfigEntry<float> TreatChance;
public const string Id = "legocool.TrickOrTreat";
internal static ManualLogSource Log { get; private set; }
public static string Name => "TrickOrTreat";
public static string Version => "0.1.0";
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("legocool.TrickOrTreat");
_harmony.PatchAll();
TrickChance = ((BaseUnityPlugin)this).Config.Bind<float>("Chances", "TrickChance", 0.25f, "Chance for a trick to happen (0 to 1)");
TreatChance = ((BaseUnityPlugin)this).Config.Bind<float>("Chances", "TreatChance", 0.25f, "Chance for a treat to happen (0 to 1)");
LoadLuggageTexture("LuggageSmall");
LoadLuggageTexture("LuggageBig");
LoadLuggageTexture("LuggageEpic");
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
}
public void LoadLuggageTexture(string luggage)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
GameObject val = Resources.Load<GameObject>("0_items/" + luggage);
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load LuggageSmall prefab!");
return;
}
MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>();
string path = Path.Combine(Paths.PluginPath, "HalloweenTextures/" + luggage + ".png");
byte[] array = File.ReadAllBytes(path);
Texture2D val2 = new Texture2D(2, 2);
ImageConversion.LoadImage(val2, array);
((Renderer)componentInChildren).sharedMaterial.mainTexture = (Texture)(object)val2;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Halloween " + luggage + " texture applied successfully!"));
}
}
public class TrickOrTreatUI : MonoBehaviour
{
private class CoroutineRunner : MonoBehaviour
{
}
[CompilerGenerated]
private sealed class <FadeOutAndDestroy>d__9 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float delay;
public TextMeshProUGUI tmp;
public float fadeTime;
private Color <startColor>5__2;
private float <elapsed>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeOutAndDestroy>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<startColor>5__2 = ((Graphic)tmp).color;
<elapsed>5__3 = 0f;
break;
case 2:
<>1__state = -1;
break;
}
if (<elapsed>5__3 < fadeTime)
{
<elapsed>5__3 += Time.deltaTime;
float num = Mathf.Lerp(1f, 0f, <elapsed>5__3 / fadeTime);
((Graphic)tmp).color = new Color(<startColor>5__2.r, <startColor>5__2.g, <startColor>5__2.b, num);
<>2__current = null;
<>1__state = 2;
return true;
}
Object.Destroy((Object)(object)((Component)tmp).gameObject);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static GameObject canvasObject;
private static GameObject currentTextObj;
private static TMP_FontAsset _gameFontAsset;
private static bool _fontSearchAttempted;
public static TMP_FontAsset GameFont
{
get
{
if ((Object)(object)_gameFontAsset == (Object)null && !_fontSearchAttempted)
{
_gameFontAsset = FindGameFont();
_fontSearchAttempted = true;
}
return _gameFontAsset;
}
}
private static TMP_FontAsset FindGameFont()
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
try
{
TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)$"Found {array.Length} TMP fonts in resources");
}
TMP_FontAsset val = ((IEnumerable<TMP_FontAsset>)array).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset fontAsset)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
FaceInfo faceInfo2 = ((TMP_Asset)fontAsset).faceInfo;
if (!(((FaceInfo)(ref faceInfo2)).familyName == "Darumadrop One"))
{
faceInfo2 = ((TMP_Asset)fontAsset).faceInfo;
return ((FaceInfo)(ref faceInfo2)).familyName == "Daruma Drop One";
}
return true;
});
FaceInfo faceInfo;
if ((Object)(object)val != (Object)null)
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
string[] obj = new string[5]
{
"Found game font: ",
((Object)val).name,
" (Family: ",
null,
null
};
faceInfo = ((TMP_Asset)val).faceInfo;
obj[3] = ((FaceInfo)(ref faceInfo)).familyName;
obj[4] = ")";
log2.LogInfo((object)string.Concat(obj));
}
return val;
}
ManualLogSource log3 = Plugin.Log;
if (log3 != null)
{
log3.LogWarning((object)"Available TMP fonts:");
}
TMP_FontAsset[] array2 = array;
foreach (TMP_FontAsset val2 in array2)
{
ManualLogSource log4 = Plugin.Log;
if (log4 != null)
{
string[] obj2 = new string[5]
{
" - ",
((Object)val2).name,
" (Family: ",
null,
null
};
faceInfo = ((TMP_Asset)val2).faceInfo;
obj2[3] = ((FaceInfo)(ref faceInfo)).familyName;
obj2[4] = ")";
log4.LogWarning((object)string.Concat(obj2));
}
}
return null;
}
catch (Exception ex)
{
ManualLogSource log5 = Plugin.Log;
if (log5 != null)
{
log5.LogWarning((object)("Error finding game font: " + ex.Message));
}
return null;
}
}
public static void SetupCanvas()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (!((Object)(object)canvasObject != (Object)null))
{
canvasObject = new GameObject("TrickOrTreatCanvas");
Canvas val = canvasObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 999;
canvasObject.AddComponent<CanvasScaler>();
canvasObject.AddComponent<GraphicRaycaster>();
Object.DontDestroyOnLoad((Object)(object)canvasObject);
}
}
public static void ShowText(string text, Color color)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)canvasObject == (Object)null)
{
SetupCanvas();
}
if ((Object)(object)currentTextObj != (Object)null)
{
Object.Destroy((Object)(object)currentTextObj);
}
currentTextObj = new GameObject("TrickOrTreatText");
currentTextObj.transform.SetParent(canvasObject.transform);
TextMeshProUGUI val = currentTextObj.AddComponent<TextMeshProUGUI>();
((TMP_Text)val).fontSize = 120f;
((TMP_Text)val).alignment = (TextAlignmentOptions)514;
TMP_FontAsset gameFont = GameFont;
if ((Object)(object)gameFont != (Object)null)
{
((TMP_Text)val).font = gameFont;
}
else
{
Plugin.Log.LogWarning((object)"Using fallback TMP font (Darumadrop One not found).");
}
RectTransform component = ((Component)val).GetComponent<RectTransform>();
component.sizeDelta = new Vector2(800f, 200f);
component.anchoredPosition = Vector2.zero;
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
((TMP_Text)val).text = text;
((Graphic)val).color = color;
CoroutineRunner coroutineRunner = currentTextObj.AddComponent<CoroutineRunner>();
((MonoBehaviour)coroutineRunner).StartCoroutine(FadeOutAndDestroy(val, 1f, 1f));
}
[IteratorStateMachine(typeof(<FadeOutAndDestroy>d__9))]
private static IEnumerator FadeOutAndDestroy(TextMeshProUGUI tmp, float fadeTime, float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeOutAndDestroy>d__9(0)
{
tmp = tmp,
fadeTime = fadeTime,
delay = delay
};
}
}
public static class Trick
{
public static void TriggerTrick(Vector3 pos, Character interactor)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
switch (Random.Range(0, 6))
{
case 0:
SpawnTornado(pos);
break;
case 1:
SpawnEruption(pos);
break;
case 2:
PeelRain(pos);
break;
case 3:
Explode(pos);
break;
case 4:
ScorpoRain(pos);
break;
case 5:
SummonScoutmaster(pos, interactor);
break;
}
}
public static void TriggerTreat(Vector3 pos, Character interactor)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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)
switch (Random.Range(0, 5))
{
case 0:
{
GameObject val4 = PhotonNetwork.Instantiate("0_Items/Lollipop", pos, Quaternion.identity, (byte)0, (object[])null);
break;
}
case 1:
{
GameObject val3 = PhotonNetwork.Instantiate("0_Items/Energy Drink", pos, Quaternion.identity, (byte)0, (object[])null);
break;
}
case 2:
{
GameObject val2 = PhotonNetwork.Instantiate("0_Items/PandorasBox", pos, Quaternion.identity, (byte)0, (object[])null);
break;
}
case 3:
{
GameObject val = PhotonNetwork.Instantiate("0_Items/FirstAidKit", pos, Quaternion.identity, (byte)0, (object[])null);
break;
}
case 4:
MoraleBoost.SpawnMoraleBoost(pos, 10f, 30f, 5f, true, 1);
break;
}
}
public static void SpawnTornado(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
GameObject val = PhotonNetwork.Instantiate("Tornado", pos, Quaternion.identity, (byte)0, (object[])null);
Tornado component = val.GetComponent<Tornado>();
component.tornadoLifetimeMax = 5f;
component.tornadoLifetimeMin = 5f;
component.force = 75f;
}
public static void SpawnEruption(Vector3 pos)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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)
EruptionSpawner val = Object.FindAnyObjectByType<EruptionSpawner>();
val.photonView.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { pos });
}
public static void PeelRain(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
int num = 25;
for (int i = 0; i < num; i++)
{
Vector3 val = pos + new Vector3(Random.Range(-5f, 5f), Random.Range(8f, 10f), Random.Range(-5f, 5f));
GameObject val2 = PhotonNetwork.Instantiate("0_Items/Berrynana Peel Yellow", val, Quaternion.identity, (byte)0, (object[])null);
RemoveAfterSeconds val3 = val2.AddComponent<RemoveAfterSeconds>();
val3.photonRemove = true;
val3.seconds = 120f;
}
}
public static void Explode(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
GameObject val = PhotonNetwork.Instantiate("0_Items/Dynamite", pos, Quaternion.identity, (byte)0, (object[])null);
Dynamite component = val.GetComponent<Dynamite>();
component.LightFlare();
component.startingFuseTime = 0f;
}
public static void ScorpoRain(Vector3 pos)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
int num = 7;
for (int i = 0; i < num; i++)
{
Vector3 val = pos + new Vector3(Random.Range(-3f, 3f), Random.Range(5f, 8f), Random.Range(-3f, 3f));
GameObject val2 = PhotonNetwork.Instantiate("0_Items/Scorpion", val, Quaternion.identity, (byte)0, (object[])null);
RemoveAfterSeconds val3 = val2.AddComponent<RemoveAfterSeconds>();
val3.photonRemove = true;
val3.seconds = 60f;
}
}
public static void SummonScoutmaster(Vector3 pos, Character interactor)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Scoutmaster val = default(Scoutmaster);
if (Scoutmaster.GetPrimaryScoutmaster(ref val))
{
float num = 30f;
if ((Object)(object)interactor != (Object)null)
{
val.SetCurrentTarget(interactor, num);
}
val.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { pos, false });
val.view.RPC("StopClimbingRpc", (RpcTarget)0, new object[1] { 0f });
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}