Decompiled source of PEAK GachaMod v2.4.2

PEAK_GachaMod.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Peak;
using Peak.Afflictions;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PEAK_GachaMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PEAK_GachaMod")]
[assembly: AssemblyTitle("PEAK_GachaMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PEAK_GachaMod;

public enum GachaEntryType
{
	GiveItem,
	InfiniteStamina,
	SpeedBuff,
	Invincibility,
	LowGravity,
	RestoreStatus,
	MoraleBoost,
	ExtraStamina,
	Bugle,
	RandomLoot,
	RandomItem,
	Mythic,
	Equipment,
	Luggage,
	Pandora,
	AllBomb,
	SpawnZombie,
	SpawnBees,
	SpawnDynamite,
	Tornado,
	Eruption,
	SpawnFrog,
	SpawnScorpion,
	TickParasite,
	IceBlind,
	MushroomBlind,
	StatusPoison,
	StatusSleep,
	StatusRandom,
	StatusAll,
	SteamExplode,
	SporeFog,
	GhostBoom,
	Revive,
	Legendary
}
public class GachaEntry
{
	public string id;

	public GachaEntryType type;

	public float p1;

	public float p2;

	public string s1;

	public int weight = 10;

	public int luckBias;
}
public static class GachaDraw
{
	private static float Luck01(int luck)
	{
		return Mathf.Clamp01(((float)luck + 100f) / 200f);
	}

	private static float LuckWeightMult(GachaEntry e, int luck)
	{
		float num = Luck01(luck);
		if (e.luckBias > 0)
		{
			return 1f + (float)e.luckBias * num;
		}
		if (e.luckBias < 0)
		{
			return 1f + (float)(-e.luckBias) * (1f - num);
		}
		return 1f;
	}

	private static int PickBigPool(int luck)
	{
		float num = Luck01(luck);
		float num2 = Plugin.cfgPool1Weight.Value * (0.3f + 0.7f * num);
		float num3 = Plugin.cfgPool2Weight.Value * (0.1f + 0.9f * num);
		float num4 = Plugin.cfgPool3Weight.Value * (1.9f - 0.9f * num);
		float num5 = num2 + num3 + num4;
		float num6 = Random.value * num5;
		if (num6 < num2)
		{
			return 1;
		}
		if (num6 < num2 + num3)
		{
			return 2;
		}
		return 3;
	}

	private static GachaEntry PickInPool(List<GachaEntry> pool, int luck)
	{
		float num = 0f;
		foreach (GachaEntry item in pool)
		{
			num += Mathf.Max(0.1f, (float)item.weight) * LuckWeightMult(item, luck);
		}
		float num2 = Random.value * num;
		foreach (GachaEntry item2 in pool)
		{
			num2 -= Mathf.Max(0.1f, (float)item2.weight) * LuckWeightMult(item2, luck);
			if (num2 <= 0f)
			{
				return item2;
			}
		}
		if (pool.Count <= 0)
		{
			return null;
		}
		return pool[pool.Count - 1];
	}

	public static GachaEntry Draw(int luck, Character c)
	{
		float value = Plugin.cfgLegendaryChance.Value;
		if (value > 0f && Random.value < value)
		{
			Plugin.Log.LogInfo((object)("[幸运罗盘] 命中传说级奖池!概率 " + value));
			return MakeEntryFromType(GachaEntryType.Legendary);
		}
		List<GachaEntry> list = Parse(Plugin.cfgPool1.Value, 1);
		List<GachaEntry> list2 = Parse(Plugin.cfgPool2.Value, 2);
		List<GachaEntry> list3 = Parse(Plugin.cfgPool3.Value, 3);
		int num = PickBigPool(luck);
		List<GachaEntry> list4 = num switch
		{
			2 => list2, 
			1 => list, 
			_ => list3, 
		};
		if (!Plugin.cfgStatueModeA.Value && num == 2)
		{
			list4 = list4.FindAll((GachaEntry e) => e.type != GachaEntryType.Revive || HasRevivablePlayers());
		}
		Plugin.Log.LogInfo((object)$"[幸运罗盘] 命中大奖池{num},条目数 {list4.Count}");
		return PickInPool(list4, luck);
	}

	public static GachaEntry MakeEntryFromType(GachaEntryType type)
	{
		return new GachaEntry
		{
			id = "Punish",
			type = type,
			p1 = 0f,
			p2 = 0f,
			s1 = "",
			weight = 10,
			luckBias = 0
		};
	}

	public static bool HasRevivablePlayers()
	{
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if ((Object)(object)allCharacter != (Object)null && (Object)(object)allCharacter.data != (Object)null && (allCharacter.data.dead || allCharacter.data.fullyPassedOut))
			{
				return true;
			}
		}
		return false;
	}

	public static List<GachaEntry> Parse(string cfg, int poolIndex)
	{
		List<GachaEntry> list = new List<GachaEntry>();
		if (string.IsNullOrEmpty(cfg))
		{
			return list;
		}
		string[] array = cfg.Split(new char[1] { ';' });
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (text.Length != 0)
			{
				string[] array2 = text.Split(new char[1] { '|' });
				if (array2.Length < 3)
				{
					WarnSkip(poolIndex, text, "字段数不足");
					continue;
				}
				if (!TryParseType(array2[1].Trim(), out var t))
				{
					WarnSkip(poolIndex, text, "未知类型 " + array2[1]);
					continue;
				}
				GachaEntry gachaEntry = new GachaEntry();
				gachaEntry.id = array2[0].Trim();
				gachaEntry.type = t;
				gachaEntry.s1 = array2[2].Trim();
				gachaEntry.p1 = ParseFloat(array2, 2);
				gachaEntry.p2 = ParseFloat(array2, 3);
				gachaEntry.weight = ((array2.Length > 4) ? ParseInt(array2[4]) : 10);
				gachaEntry.luckBias = ((array2.Length > 5) ? ParseInt(array2[5]) : 0);
				list.Add(gachaEntry);
			}
		}
		return list;
	}

	private static bool TryParseType(string s, out GachaEntryType t)
	{
		foreach (GachaEntryType value in Enum.GetValues(typeof(GachaEntryType)))
		{
			if (string.Equals(value.ToString(), s, StringComparison.OrdinalIgnoreCase))
			{
				t = value;
				return true;
			}
		}
		t = GachaEntryType.GiveItem;
		return false;
	}

	private static float ParseFloat(string[] f, int i)
	{
		if (f.Length <= i || !float.TryParse(f[i], out var result))
		{
			return 0f;
		}
		return result;
	}

	private static int ParseInt(string s)
	{
		if (!int.TryParse(s, out var result))
		{
			return 10;
		}
		return result;
	}

	private static void WarnSkip(int pool, string line, string why)
	{
		Plugin.Log.LogWarning((object)$"[幸运罗盘] 大奖池{pool} 条目解析失败已跳过({why}):{line}");
	}
}
public static class GachaExecutor
{
	private static bool _netInit = false;

	private static readonly string[] MythicPool = new string[11]
	{
		"0_Items/Anti-Rope Spool", "0_Items/BookOfBones", "0_Items/Bugle_Magic", "0_Items/Bugle_Scoutmaster Variant", "0_Items/Cure-All", "0_Items/Cursed Skull", "0_Items/Lantern_Faerie", "0_Items/PandorasBox", "0_Items/RopeShooterAnti", "0_Items/ScoutEffigy",
		"0_Items/Warp Compass"
	};

	private static readonly string[] EquipmentPool = new string[7] { "0_Items/ChainShooter", "0_Items/ClimbingSpike", "0_Items/Energy Drink", "0_Items/Lollipop", "0_Items/RescueHook", "0_Items/RopeShooter", "0_Items/RopeSpool" };

	private static readonly string[] LuggagePool = new string[4] { "0_Items/LuggageSmall", "0_Items/LuggageBig", "0_Items/LuggageEpic", "0_Items/LuggageAncient" };

	private static readonly STATUSTYPE[] RandomStatusPool;

	private static void EnsureNetworking()
	{
		if (_netInit)
		{
			return;
		}
		try
		{
			if (!((Object)(object)GameUtils.instance == (Object)null))
			{
				if ((Object)(object)((Component)GameUtils.instance).GetComponent<GachaNet>() == (Object)null)
				{
					((Component)GameUtils.instance).gameObject.AddComponent<GachaNet>();
				}
				if ((Object)(object)GachaNet.Instance == (Object)null)
				{
					GachaNet.Instance = ((Component)GameUtils.instance).GetComponent<GachaNet>();
				}
				_netInit = true;
				Plugin.Log.LogInfo((object)"[幸运罗盘] 网络组件就绪");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 网络初始化异常:" + ex.Message));
		}
	}

	public static void InitNetworking()
	{
		EnsureNetworking();
	}

	public static void TriggerSeverePunishment(Character c)
	{
		try
		{
			int num = Random.Range(0, 5);
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 触发最严重惩罚,类型roll={num}");
			switch (num)
			{
			case 0:
				Execute(GachaDraw.MakeEntryFromType(GachaEntryType.Tornado), c, LuckSystem.GetLuck());
				break;
			case 1:
				ApplyAllStatusForce(c);
				GachaNet.ShowAllWarning("【致命危机】 厄运降临:所有负面状态!", 4f);
				Notify("【厄运降临】 所有负面状态!");
				break;
			case 2:
				AddStatusSafe(c, (STATUSTYPE)13, 0.5f);
				GachaNet.ShowAllWarning("【致命危机】 石化条被填充一半!", 4f);
				Notify("【石化】 石化条被填充一半!");
				break;
			case 3:
				AddStatusSafe(c, (STATUSTYPE)6, 1f);
				GachaNet.ShowAllWarning("【致命危机】 强制倒地!", 4f);
				Notify("【强制倒地】 困意如山倒,你被迫倒地!");
				break;
			default:
				Execute(GachaDraw.MakeEntryFromType(GachaEntryType.AllBomb), c, LuckSystem.GetLuck());
				break;
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 严重惩罚异常:" + ex.Message));
		}
	}

	private static bool IsWorldSpawn(GachaEntryType t)
	{
		switch (t)
		{
		case GachaEntryType.GiveItem:
		case GachaEntryType.RandomLoot:
		case GachaEntryType.RandomItem:
		case GachaEntryType.Mythic:
		case GachaEntryType.Equipment:
		case GachaEntryType.Luggage:
		case GachaEntryType.Pandora:
		case GachaEntryType.AllBomb:
		case GachaEntryType.SpawnZombie:
		case GachaEntryType.SpawnBees:
		case GachaEntryType.SpawnDynamite:
		case GachaEntryType.SpawnFrog:
		case GachaEntryType.SpawnScorpion:
		case GachaEntryType.TickParasite:
		case GachaEntryType.SporeFog:
		case GachaEntryType.GhostBoom:
		case GachaEntryType.Legendary:
			return true;
		default:
			return false;
		}
	}

	private static bool IsSevereNegative(GachaEntryType t)
	{
		switch (t)
		{
		case GachaEntryType.Pandora:
		case GachaEntryType.AllBomb:
		case GachaEntryType.Tornado:
		case GachaEntryType.Eruption:
		case GachaEntryType.StatusAll:
		case GachaEntryType.GhostBoom:
			return true;
		default:
			return false;
		}
	}

	private static string SevereName(GachaEntryType t)
	{
		return t switch
		{
			GachaEntryType.Pandora => "魔盒瞬爆!", 
			GachaEntryType.AllBomb => "送你个礼物,我叫磁力棒!!", 
			GachaEntryType.Tornado => "高高的飞起来吧!", 
			GachaEntryType.Eruption => "火山喷发!", 
			GachaEntryType.StatusAll => "遇上彩虹,吃定彩虹!", 
			GachaEntryType.GhostBoom => "乐魂?", 
			_ => "", 
		};
	}

	public static void Execute(GachaEntry e, Character c, int luck)
	{
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Expected O, but got Unknown
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Expected O, but got Unknown
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Expected O, but got Unknown
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Expected O, but got Unknown
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Expected O, but got Unknown
		//IL_00b3: 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)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			EnsureNetworking();
			if (e.type == GachaEntryType.Legendary)
			{
				GachaNet.ShowAllWarning("【传说】 0.1%概率,传说神物降世!", 4f);
			}
			if (IsSevereNegative(e.type))
			{
				int value = Plugin.cfgSeverePump.Value;
				string text = SevereName(e.type);
				if (!string.IsNullOrEmpty(text))
				{
					GachaNet.ShowAllWarning("【致命危机】 " + text, 4f);
				}
				Plugin.Log.LogInfo((object)("[幸运罗盘] 触发最严重负面,全队共享幸运+" + value));
				GachaNet.RestoreAllLuck(value);
			}
			if (IsWorldSpawn(e.type))
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					RequestWorldSpawn(e.type, c, e.s1, luck);
					return;
				}
				Vector3 pos = WorldSpawnPos(c, e.type);
				ExecuteWorldSpawn(e.type, pos, e.s1, luck, c);
				return;
			}
			switch (e.type)
			{
			case GachaEntryType.InfiniteStamina:
				c.refs.afflictions.AddAffliction((Affliction)new Affliction_InfiniteStamina(e.p1), false);
				Notify("获得【无限体力】 " + e.p1 + "秒");
				break;
			case GachaEntryType.SpeedBuff:
				c.refs.afflictions.AddAffliction((Affliction)new Affliction_FasterBoi
				{
					moveSpeedMod = e.p1,
					climbSpeedMod = e.p2,
					totalTime = 12f,
					climbDelay = 1f
				}, false);
				Notify("获得【迅捷效果】 移速x" + e.p1 + " 攀爬x" + e.p2 + "(12秒)");
				break;
			case GachaEntryType.Invincibility:
				c.refs.afflictions.AddAffliction((Affliction)new Affliction_Invincibility
				{
					totalTime = e.p1
				}, false);
				Notify("获得【无敌】 " + e.p1 + "秒");
				break;
			case GachaEntryType.LowGravity:
				c.refs.afflictions.AddAffliction((Affliction)new Affliction_LowGravity((int)e.p1, e.p2), false);
				Notify("获得【低重力】 档位" + (int)e.p1 + " " + e.p2 + "秒");
				break;
			case GachaEntryType.RestoreStatus:
				RestoreStatus(c, e.p1);
				Notify("【状态恢复】 恢复" + e.p1 + "点负面状态");
				break;
			case GachaEntryType.MoraleBoost:
				c.MoraleBoost(e.p1, 1);
				Notify("【士气高涨】 体力回复");
				break;
			case GachaEntryType.ExtraStamina:
				c.AddExtraStamina(e.p1);
				Notify("【额外体力】 +" + e.p1);
				break;
			case GachaEntryType.Bugle:
				c.MoraleBoost(0.25f, 1);
				RestoreStatus(c, 0.5f);
				Notify("【友谊喇叭】 士气高涨 + 清除负面状态");
				break;
			case GachaEntryType.Tornado:
				SpawnTornado(c);
				break;
			case GachaEntryType.Eruption:
				SpawnEruption(c);
				break;
			case GachaEntryType.IceBlind:
				AddStatusSafe(c, (STATUSTYPE)2, 0.7f);
				GachaHold.ShowIceBlind(6f);
				Notify("【冰雪覆盖视野】 寒气刺骨,视野被冰雪遮蔽!");
				break;
			case GachaEntryType.MushroomBlind:
				c.refs.afflictions.AddAffliction((Affliction)new Affliction_Blind
				{
					totalTime = Plugin.cfgMushroomBlindTime.Value
				}, false);
				Notify("【蘑菇遮蔽】 眼前一黑,视野被蘑菇遮蔽!(" + Plugin.cfgMushroomBlindTime.Value + "秒)");
				break;
			case GachaEntryType.StatusPoison:
				AddStatusSafe(c, (STATUSTYPE)3, 0.6f);
				Notify("【中毒】 你中毒了!");
				break;
			case GachaEntryType.StatusSleep:
				AddStatusSafe(c, (STATUSTYPE)6, 0.8f);
				Notify("【瞌睡】 困意袭来!");
				break;
			case GachaEntryType.StatusRandom:
				ApplyRandomStatus(c);
				break;
			case GachaEntryType.StatusAll:
				ApplyAllStatusGate(c);
				break;
			case GachaEntryType.SteamExplode:
				SteamExplode(c);
				break;
			case GachaEntryType.Revive:
				Revive(c);
				break;
			case GachaEntryType.RandomLoot:
			case GachaEntryType.RandomItem:
			case GachaEntryType.Mythic:
			case GachaEntryType.Equipment:
			case GachaEntryType.Luggage:
			case GachaEntryType.Pandora:
			case GachaEntryType.AllBomb:
			case GachaEntryType.SpawnZombie:
			case GachaEntryType.SpawnBees:
			case GachaEntryType.SpawnDynamite:
			case GachaEntryType.SpawnFrog:
			case GachaEntryType.SpawnScorpion:
			case GachaEntryType.TickParasite:
			case GachaEntryType.SporeFog:
			case GachaEntryType.GhostBoom:
				break;
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 效果执行异常(已拦截,不影响运行):" + ex.Message));
		}
	}

	public static int CountByLuck(int luck)
	{
		if (luck >= 0)
		{
			return 1;
		}
		if (luck >= -50)
		{
			return 2;
		}
		return 3;
	}

	private static void RequestWorldSpawn(GachaEntryType type, Character c, string s1, int luck)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)GameUtils.instance == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] GameUtils不可用");
				return;
			}
			PhotonView component = ((Component)GameUtils.instance).GetComponent<PhotonView>();
			if ((Object)(object)component == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] GameUtils无PhotonView");
				return;
			}
			Vector3 val = WorldSpawnPos(c, type);
			string text = "";
			switch (type)
			{
			case GachaEntryType.SpawnFrog:
			case GachaEntryType.SpawnScorpion:
				text = CountByLuck(luck).ToString();
				break;
			case GachaEntryType.TickParasite:
				text = "TICK:" + ((MonoBehaviourPun)c).photonView.ViewID;
				break;
			}
			component.RPC("RPCA_GachaSpawn", (RpcTarget)2, new object[6]
			{
				(int)type,
				val.x,
				val.y,
				val.z,
				s1 ?? "",
				text
			});
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 已请求房主生成 {type}");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 请求房主生成失败:" + ex.Message));
		}
	}

	private static Vector3 WorldSpawnPos(Character c, GachaEntryType type)
	{
		//IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		float num = 2f;
		if (type == GachaEntryType.SpawnZombie || type == GachaEntryType.SpawnFrog || type == GachaEntryType.SpawnScorpion)
		{
			num = 3f;
		}
		if (type == GachaEntryType.GhostBoom)
		{
			num = 15f;
		}
		if (type == GachaEntryType.SporeFog)
		{
			return c.Center + Vector3.up * 0.1f;
		}
		return c.Center + c.data.lookDirection * num + Vector3.up * 0.3f;
	}

	public static void ExecuteWorldSpawn(GachaEntryType type, Vector3 pos, string s1, int luck = 0, Character requester = null)
	{
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_00a7: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: 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_0080: 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)
		switch (type)
		{
		case GachaEntryType.GhostBoom:
			SpawnGhostBallAt(pos, requester);
			break;
		case GachaEntryType.Legendary:
			SpawnLegendaryAt(pos, requester);
			break;
		case GachaEntryType.SpawnZombie:
			SpawnZombieAt(pos);
			break;
		case GachaEntryType.SpawnBees:
			SpawnBeesAt(pos);
			break;
		case GachaEntryType.SpawnDynamite:
			SpawnDynamiteAt(pos);
			break;
		case GachaEntryType.Pandora:
			SpawnPandoraAt(pos);
			break;
		case GachaEntryType.AllBomb:
			SpawnAllBombsAt(pos);
			break;
		case GachaEntryType.SporeFog:
			SporeFogAt(pos, requester);
			break;
		case GachaEntryType.Mythic:
			SpawnFromPoolAt(pos, MythicPool, "神话");
			break;
		case GachaEntryType.Equipment:
			SpawnFromPoolAt(pos, EquipmentPool, "装备");
			break;
		case GachaEntryType.Luggage:
			SpawnLuggageAt(pos);
			break;
		case GachaEntryType.GiveItem:
			GiveItemAt(pos, s1);
			break;
		case GachaEntryType.RandomLoot:
			SpawnRandomItemAt(pos, allItems: false);
			break;
		case GachaEntryType.RandomItem:
			SpawnRandomItemAt(pos, allItems: true);
			break;
		case GachaEntryType.SpawnFrog:
			SpawnFrogsAt(pos, ParseCount(s1, luck), requester);
			break;
		case GachaEntryType.SpawnScorpion:
			SpawnScorpionsAt(pos, ParseCount(s1, luck), requester);
			break;
		case GachaEntryType.TickParasite:
			AttachTick(s1, requester);
			break;
		}
	}

	private static int ParseCount(string s1, int luck)
	{
		if (!string.IsNullOrEmpty(s1) && int.TryParse(s1, out var result) && result > 0)
		{
			return result;
		}
		return CountByLuck(luck);
	}

	private static void Notify(string msg)
	{
		Plugin.Log.LogInfo((object)("[幸运罗盘] " + msg));
	}

	private static void GiveItemAt(Vector3 pos, string name)
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(name))
		{
			return;
		}
		try
		{
			string text = (name.StartsWith("0_Items/") ? name : ("0_Items/" + name));
			GameObject val = Resources.Load<GameObject>(text);
			if ((Object)(object)val != (Object)null && IsBanned(val))
			{
				Plugin.Log.LogInfo((object)("[幸运罗盘] 该物品已被列入禁止库,跳过生成: " + name));
				return;
			}
			PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
			Notify("房主生成物品:" + name);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成物品失败:" + ex.Message));
		}
	}

	private static void SpawnRandomItemAt(Vector3 pos, bool allItems)
	{
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject[] array = Resources.LoadAll<GameObject>("0_Items");
			List<Item> list = new List<Item>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Item component = val.GetComponent<Item>();
					if (!((Object)(object)component == (Object)null) && (allItems || !((Object)(object)val.GetComponent<LootData>() == (Object)null)) && !IsBanned(val))
					{
						list.Add(component);
					}
				}
			}
			if (list.Count == 0)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:无可用物品");
				return;
			}
			Item val2 = list[Random.Range(0, list.Count)];
			PhotonNetwork.Instantiate("0_Items/" + ((Object)((Component)val2).gameObject).name, pos, Quaternion.identity, (byte)0, (object[])null);
			Notify(string.Format("房主生成随机物品({0}池 {1}种):", allItems ? "全部" : "掉落", list.Count) + ((Object)((Component)val2).gameObject).name);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主随机物品失败:" + ex.Message));
		}
	}

	private static void SpawnFromPoolAt(Vector3 pos, string[] pool, string display)
	{
		//IL_0051: 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)
		try
		{
			string text = null;
			for (int i = 0; i < pool.Length && i < 5; i++)
			{
				string text2 = pool[Random.Range(0, pool.Length)];
				GameObject val = Resources.Load<GameObject>(text2);
				if (!((Object)(object)val != (Object)null) || !IsBanned(val))
				{
					text = text2;
					break;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				text = pool[Random.Range(0, pool.Length)];
			}
			PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
			Notify("房主生成" + display + "物品:" + text);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成" + display + "失败:" + ex.Message));
		}
	}

	private static void SpawnLegendaryAt(Vector3 pos, Character requester)
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		string value = Plugin.cfgLegendaryPool.Value;
		object obj = ((!string.IsNullOrEmpty(value)) ? ((object)value.Split(new char[1] { ';' })) : ((object)new string[2] { "AncientIdol", "RescueHook_Infinite" }));
		List<string> list = new List<string>();
		string[] array = (string[])obj;
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (text.Length != 0)
			{
				list.Add(text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
			}
		}
		if (list.Count == 0)
		{
			list.Add("0_Items/AncientIdol");
		}
		try
		{
			GameObject val = PhotonNetwork.Instantiate(list[Random.Range(0, list.Count)], pos, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] 房主传说物品生成失败(null)");
				return;
			}
			Item component = val.GetComponent<Item>();
			if ((Object)(object)component != (Object)null && (Object)(object)requester != (Object)null && (Object)(object)((MonoBehaviourPun)requester).photonView != (Object)null)
			{
				component.RequestPickup(((MonoBehaviourPun)requester).photonView);
			}
			Notify("【传说】 天降传说神物:" + ((Object)val.gameObject).name);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主传说物品失败:" + ex.Message));
		}
	}

	private static bool IsBanned(GameObject go)
	{
		if ((Object)(object)go == (Object)null)
		{
			return false;
		}
		string value = Plugin.cfgBannedItems.Value;
		if (string.IsNullOrEmpty(value))
		{
			return false;
		}
		string name = ((Object)go).name;
		string[] array = value.Split(new char[1] { ';' });
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (text.Length != 0 && name.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
		}
		return false;
	}

	private static void SpawnLuggageAt(Vector3 pos)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string text = LuggagePool[Random.Range(0, LuggagePool.Length)];
			PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
			Notify("房主生成【行李箱】:" + text);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主行李箱失败:" + ex.Message));
		}
	}

	private static void SpawnPandoraAt(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)
		try
		{
			GameObject val = PhotonNetwork.Instantiate("0_Items/PandorasBox", pos, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val != (Object)null)
			{
				ItemCooking component = val.GetComponent<ItemCooking>();
				if ((Object)(object)component != (Object)null)
				{
					component.FinishCooking();
				}
				Notify("【潘多拉魔盒】已触发!");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主魔盒失败:" + ex.Message));
		}
	}

	private static void SpawnAllBombsAt(Vector3 pos)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string text = Plugin.cfgDynamiteName.Value;
			if (string.IsNullOrEmpty(text))
			{
				text = "0_Items/Dynamite";
			}
			string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
			int num = 0;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)null)
				{
					continue;
				}
				GameObject val = PhotonNetwork.Instantiate(text2, allCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
				if (!((Object)(object)val == (Object)null))
				{
					Item component = val.GetComponent<Item>();
					if ((Object)(object)component != (Object)null && (Object)(object)((MonoBehaviourPun)allCharacter).photonView != (Object)null)
					{
						component.RequestPickup(((MonoBehaviourPun)allCharacter).photonView);
						num++;
					}
				}
			}
			Notify($"【全玩家炸弹】 强制 {num} 名玩家手持炸药!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 全玩家炸弹失败:" + ex.Message));
		}
	}

	private static void SpawnZombieAt(Vector3 pos)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		string text = Plugin.cfgZombieName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = FindZombieName();
		}
		if (string.IsNullOrEmpty(text))
		{
			text = "MushroomZombie";
		}
		try
		{
			GameObject val = PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
			if (!((Object)(object)val == (Object)null))
			{
				MushroomZombie component = val.GetComponent<MushroomZombie>();
				if ((Object)(object)component != (Object)null)
				{
					component.zombieSprintDistance = 15f;
					component.zombieLungeDistance = 3f;
					component.lungeRecoveryTime = 1f;
					component.lifetime = 45f;
					component.currentState = (State)0;
				}
				Notify("生成【僵尸】!");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主僵尸失败:" + ex.Message));
		}
	}

	private static void SpawnBeesAt(Vector3 pos)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_00b0: 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)
		string text = Plugin.cfgBeeName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = FindBeeName();
		}
		if (string.IsNullOrEmpty(text))
		{
			text = "BeeSwarm";
		}
		try
		{
			GameObject val = PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:蜜蜂生成失败(null)");
				return;
			}
			BeeSwarm component = val.GetComponent<BeeSwarm>();
			if ((Object)(object)component != (Object)null)
			{
				float num = float.MaxValue;
				Character val2 = null;
				foreach (Character allCharacter in Character.AllCharacters)
				{
					if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && allCharacter.data.fullyConscious)
					{
						float num2 = Vector3.Distance(allCharacter.Center, pos);
						if (num2 < num)
						{
							num = num2;
							val2 = allCharacter;
						}
					}
				}
				if ((Object)(object)val2 != (Object)null)
				{
					component.currentAggroCharacter = val2;
					component.HiveDestroyed(pos);
				}
				if (Beehive.ALL_BEEHIVES != null)
				{
					foreach (Beehive aLL_BEEHIVE in Beehive.ALL_BEEHIVES)
					{
						if ((Object)(object)aLL_BEEHIVE != (Object)null)
						{
							component.SetBeehive(aLL_BEEHIVE);
							break;
						}
					}
				}
			}
			Notify("生成【蜜蜂群】!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主蜜蜂失败:" + ex.Message));
		}
	}

	private static void SpawnDynamiteAt(Vector3 pos)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		string text = Plugin.cfgDynamiteName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = "0_Items/Dynamite";
		}
		string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
		try
		{
			PhotonNetwork.Instantiate(text2, pos, Quaternion.identity, (byte)0, (object[])null);
			Notify("面前生成【炸药】!小心:靠近会被点燃爆炸");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主炸药失败:" + ex.Message));
		}
	}

	private static void SpawnFrogsAt(Vector3 pos, int count, Character requester)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		string text = Plugin.cfgFrogName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = "Frog";
		}
		string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
		try
		{
			for (int i = 0; i < count; i++)
			{
				Vector3 val = pos + new Vector3(Random.Range(-1f, 1f), 0.5f, Random.Range(-1f, 1f));
				PhotonNetwork.Instantiate(text2, val, Quaternion.identity, (byte)0, (object[])null);
			}
			Notify($"生成【青蛙】x{count}!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主青蛙失败:" + ex.Message));
			FallbackNegative(requester, "青蛙");
		}
	}

	private static void SpawnGhostBallAt(Vector3 pos, Character requester)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		string name = Plugin.cfgGhostName.Value;
		if (string.IsNullOrEmpty(name))
		{
			name = FindGhostBallName();
		}
		if (string.IsNullOrEmpty(name))
		{
			name = "GhostBall";
		}
		GachaNet.ShowAllWarning("【致命危机】 雾沼大幽灵即将来袭!快跑!", 3f);
		Plugin.Log.LogInfo((object)"[幸运罗盘] 抽中大幽灵!3秒后在玩家前方远处生成");
		Vector3 spawnPos = pos;
		Plugin.RunDelayed(3f, delegate
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Vector3 val = spawnPos;
				val.y += 0.8f;
				GameObject val2 = PhotonNetwork.Instantiate(name, val, Quaternion.identity, (byte)0, (object[])null);
				if ((Object)(object)val2 == (Object)null)
				{
					FallbackNegative(requester, "大幽灵");
				}
				else
				{
					GhostBall component = val2.GetComponent<GhostBall>();
					if ((Object)(object)component != (Object)null)
					{
						component.maxHeight = val.y + 3f;
						component.chaseHeight = val.y + 1.2f;
						if (component.lifetime <= 0f)
						{
							component.lifetime = 30f;
						}
					}
					Notify("【大幽灵】 雾沼大幽灵追着你来了!");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[幸运罗盘] 房主大幽灵生成失败:" + ex.Message));
				FallbackNegative(requester, "大幽灵");
			}
		});
	}

	private static string FindGhostBallName()
	{
		try
		{
			if ((Object)(object)GhostBallSpawner.Instance != (Object)null && (Object)(object)GhostBallSpawner.Instance.ghostBallPrefab != (Object)null)
			{
				return ((Object)((Component)GhostBallSpawner.Instance.ghostBallPrefab).gameObject).name;
			}
			GameObject[] array = Resources.LoadAll<GameObject>("0_Items");
			foreach (GameObject val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name.IndexOf("Ghost", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return ((Object)val).name;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 探测大幽灵名异常:" + ex.Message));
		}
		return null;
	}

	private static void SpawnScorpionsAt(Vector3 pos, int count, Character requester)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		string text = Plugin.cfgScorpionName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = "0_Items/Scorpion";
		}
		string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
		try
		{
			for (int i = 0; i < count; i++)
			{
				Vector3 val = pos + new Vector3(Random.Range(-1f, 1f), 0.5f, Random.Range(-1f, 1f));
				PhotonNetwork.Instantiate(text2, val, Quaternion.identity, (byte)0, (object[])null);
			}
			Notify($"生成【蝎子】x{count}!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主蝎子失败:" + ex.Message));
			FallbackNegative(requester, "蝎子");
		}
	}

	private static void AttachTick(string s1, Character requester)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string text = Plugin.cfgTickName.Value;
			if (string.IsNullOrEmpty(text))
			{
				text = "BugfixOnYou";
			}
			int result = -1;
			if (!string.IsNullOrEmpty(s1) && s1.StartsWith("TICK:"))
			{
				int.TryParse(s1.Substring(5), out result);
			}
			if (result <= 0 && (Object)(object)requester != (Object)null)
			{
				result = ((MonoBehaviourPun)requester).photonView.ViewID;
			}
			GameObject val = PhotonNetwork.Instantiate(text, Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:蜱虫生成失败");
				return;
			}
			Bugfix component = val.GetComponent<Bugfix>();
			if ((Object)(object)component != (Object)null && result > 0)
			{
				component.AttachBug(result);
				Notify("【蜱虫寄生】 一只蜱虫寄生在抽取者身上!");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 蜱虫失败:" + ex.Message));
		}
	}

	private static void SporeFogAt(Vector3 pos, Character requester)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		string text = Plugin.cfgSporeFogName.Value;
		if (string.IsNullOrEmpty(text))
		{
			text = "CloudFungus";
		}
		string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
		try
		{
			GameObject val = PhotonNetwork.Instantiate(text2, pos, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				FallbackNegative(requester, "孢子云");
				return;
			}
			CloudFungus component = val.GetComponent<CloudFungus>();
			if ((Object)(object)component != (Object)null)
			{
				component.Break();
			}
			else
			{
				PhotonNetwork.Destroy(val);
			}
			if ((Object)(object)requester != (Object)null)
			{
				AddStatusSafe(requester, (STATUSTYPE)10, 0.25f);
				AddStatusSafe(requester, (STATUSTYPE)3, 0.15f);
			}
			Notify("【孢子云】 云蕈爆开,原生孢子云弥漫!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主孢子云失败:" + ex.Message));
			FallbackNegative(requester, "孢子云");
		}
	}

	private static void TrySpawnPrefabAt(string name, Vector3 pos, string display, Character requester)
	{
		//IL_001b: 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)
		try
		{
			if ((Object)(object)PhotonNetwork.Instantiate(name.StartsWith("0_Items/") ? name : ("0_Items/" + name), pos, Quaternion.identity, (byte)0, (object[])null) == (Object)null)
			{
				FallbackNegative(requester, display);
			}
			else
			{
				Notify("生成【" + display + "】!");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成" + display + "失败:" + ex.Message));
			FallbackNegative(requester, display);
		}
	}

	private static void FallbackNegative(Character target, string effectName)
	{
		if ((Object)(object)target != (Object)null)
		{
			AddStatusSafe(target, (STATUSTYPE)3, 0.6f);
			AddStatusSafe(target, (STATUSTYPE)6, 0.8f);
			Notify("【" + effectName + "生成失败】 转为中毒+瞌睡惩罚!");
		}
		else
		{
			Notify("【" + effectName + "生成失败】 无法定位目标玩家");
		}
	}

	private static void SpawnTornado(Character c)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			float value = Plugin.cfgTornadoDelay.Value;
			Vector3 fixedPos = c.Center;
			GachaHold.ShowWarning("警告:龙卷风即将来袭!", value + 1f);
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中龙卷风!{value}秒后生成于固定位置 {fixedPos}");
			if (PhotonNetwork.IsMasterClient)
			{
				GachaNet.ShowAllWarning("警告:龙卷风即将来袭!", value + 1f);
				Plugin.RunDelayed(value, delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					SpawnTornadoAt(fixedPos);
				});
			}
			else
			{
				GachaNet.RequestTornado(fixedPos);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 龙卷风异常:" + ex.Message));
		}
	}

	public static void SpawnTornadoAt(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)
		try
		{
			GameObject val = PhotonNetwork.Instantiate("Tornado", pos, Quaternion.identity, (byte)0, (object[])null);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:龙卷风生成失败");
				return;
			}
			Tornado component = val.GetComponent<Tornado>();
			if ((Object)(object)component != (Object)null)
			{
				component.tornadoLifetimeMax = 20f;
				component.tornadoLifetimeMin = 15f;
				component.force = 20f;
			}
			Notify("【龙卷风】生成!");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主龙卷风失败:" + ex.Message));
		}
	}

	private static void SpawnEruption(Character c)
	{
		try
		{
			float value = Plugin.cfgEruptionDelay.Value;
			GachaHold.ShowWarning("警告:火山喷发即将爆发!", value + 1f);
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中火山喷发!{value}秒后爆发,快逃!");
			Plugin.RunDelayed(value, delegate
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				EruptionSpawner val = Object.FindObjectOfType<EruptionSpawner>();
				if ((Object)(object)val == (Object)null)
				{
					AddStatusSafe(c, (STATUSTYPE)8, 0.5f);
					Notify("【火山喷发】 当前区域无火山生成器,施加过热状态");
				}
				else
				{
					PhotonView component = ((Component)val).GetComponent<PhotonView>();
					if ((Object)(object)component != (Object)null)
					{
						component.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { c.Center });
						Notify("【火山喷发】岩浆涌出!");
					}
				}
			});
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 火山喷发异常:" + ex.Message));
		}
	}

	private unsafe static void AddStatusSafe(Character target, STATUSTYPE type, float amount)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Object)(object)target == (Object)null) && target.refs != null && !((Object)(object)target.refs.afflictions == (Object)null))
			{
				target.refs.afflictions.AddStatus(type, amount, false, true, true);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 加状态失败(" + ((object)(*(STATUSTYPE*)(&type))/*cast due to .constrained prefix*/).ToString() + "):" + ex.Message));
		}
	}

	private static void ApplyAllStatusForce(Character c)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		STATUSTYPE[] randomStatusPool = RandomStatusPool;
		foreach (STATUSTYPE type in randomStatusPool)
		{
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter != (Object)null)
				{
					AddStatusSafe(allCharacter, type, 0.6f);
				}
			}
		}
	}

	private unsafe static void ApplyRandomStatus(Character c)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		STATUSTYPE type = RandomStatusPool[Random.Range(0, RandomStatusPool.Length)];
		AddStatusSafe(c, type, 0.5f);
		Notify("【随机负面状态】 " + ((object)(*(STATUSTYPE*)(&type))/*cast due to .constrained prefix*/).ToString());
	}

	private static void ApplyAllStatusGate(Character c)
	{
		if (Random.value < Plugin.cfgStatusAllChance.Value)
		{
			Plugin.Log.LogInfo((object)"[幸运罗盘] 触发【全部负面状态】!!");
			ApplyAllStatusForce(c);
			Notify("【厄运降临】 所有负面状态!");
		}
		else
		{
			ApplyRandomStatus(c);
		}
	}

	private static void SteamExplode(Character c)
	{
		//IL_003b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Rigidbody val = (((Object)(object)c.refs.hip != (Object)null) ? c.refs.hip.Rig : null);
			if ((Object)(object)val != (Object)null)
			{
				Vector3 val2 = ((Vector3)(ref c.data.lookDirection)).normalized * 10f + Vector3.up * 7f;
				c.AddForceToBodyPart(val, val2, val2);
				Notify("【蒸气爆炸】 你被炸飞了!");
			}
			else
			{
				Notify("【蒸气爆炸】 爆炸冲击!");
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 蒸气爆炸弹飞失败:" + ex.Message));
		}
	}

	private static void RestoreStatus(Character c, float amount)
	{
		CharacterAfflictions afflictions = c.refs.afflictions;
		afflictions.SubtractStatus((STATUSTYPE)1, amount, false, false);
		afflictions.SubtractStatus((STATUSTYPE)0, amount, false, false);
		afflictions.SubtractStatus((STATUSTYPE)3, amount, false, false);
		afflictions.SubtractStatus((STATUSTYPE)2, amount, false, false);
		afflictions.SubtractStatus((STATUSTYPE)6, amount, false, false);
		afflictions.SubtractStatus((STATUSTYPE)10, amount, false, false);
	}

	private static string FindKeywordPrefab(string[] keywords)
	{
		try
		{
			GameObject[] array = Resources.LoadAll<GameObject>("0_Items");
			foreach (GameObject val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string name = ((Object)val).name;
				foreach (string value in keywords)
				{
					if (name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return name;
					}
				}
			}
		}
		catch
		{
		}
		return null;
	}

	private static string FindZombieName()
	{
		try
		{
			MushroomZombieSpawner[] array = Object.FindObjectsOfType<MushroomZombieSpawner>();
			foreach (MushroomZombieSpawner val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.mushroomZombiePrefab != (Object)null)
				{
					return ((Object)((Component)val.mushroomZombiePrefab).gameObject).name;
				}
			}
			if ((Object)(object)ZombieManager.Instance != (Object)null && ZombieManager.Instance.spawners != null)
			{
				foreach (MushroomZombieSpawner spawner in ZombieManager.Instance.spawners)
				{
					if ((Object)(object)spawner != (Object)null && (Object)(object)spawner.mushroomZombiePrefab != (Object)null)
					{
						return ((Object)((Component)spawner.mushroomZombiePrefab).gameObject).name;
					}
				}
			}
			MushroomZombie[] array2 = Object.FindObjectsOfType<MushroomZombie>();
			foreach (MushroomZombie val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					return ((Object)((Component)val2).gameObject).name;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 探测僵尸名异常:" + ex.Message));
		}
		return null;
	}

	private static string FindBeeName()
	{
		try
		{
			foreach (Beehive aLL_BEEHIVE in Beehive.ALL_BEEHIVES)
			{
				if ((Object)(object)aLL_BEEHIVE != (Object)null && (Object)(object)aLL_BEEHIVE.beeSwarmPrefab != (Object)null)
				{
					return ((Object)((Component)aLL_BEEHIVE.beeSwarmPrefab).gameObject).name;
				}
			}
			Beehive[] array = Object.FindObjectsOfType<Beehive>();
			foreach (Beehive val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.beeSwarmPrefab != (Object)null)
				{
					return ((Object)((Component)val.beeSwarmPrefab).gameObject).name;
				}
			}
			BeeSwarm[] array2 = Object.FindObjectsOfType<BeeSwarm>();
			foreach (BeeSwarm val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					return ((Object)((Component)val2).gameObject).name;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 探测蜜蜂名异常:" + ex.Message));
		}
		return null;
	}

	private static void Revive(Character c)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		if (Plugin.cfgStatueModeA.Value)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				try
				{
					Vector3 val = c.Center + c.data.lookDirection * 2f + Vector3.up * 0.3f;
					PhotonNetwork.Instantiate("0_Items/ScoutEffigy", val, Quaternion.identity, (byte)0, (object[])null);
					Notify("面前生成【童军雕像】(ScoutEffigy)");
					return;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("[幸运罗盘] 生成童军雕像失败:" + ex.Message));
					return;
				}
			}
			RequestWorldSpawn(GachaEntryType.Mythic, c, "", LuckSystem.GetLuck());
			return;
		}
		int num = 0;
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && (allCharacter.data.dead || allCharacter.data.fullyPassedOut))
			{
				Vector3 val2 = c.Center + c.data.lookDirection * 2f + Vector3.up * 0.3f;
				((MonoBehaviourPun)allCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val2, true, -1 });
				num++;
			}
		}
		Notify((num > 0) ? ("【复活】 共复活 " + num + " 名玩家(抽取者身边重生)") : "【复活】 当前无待复活玩家");
	}

	internal static void GiveCompassTo(Character p)
	{
		try
		{
			if ((Object)(object)p == (Object)null || (Object)(object)((MonoBehaviourPun)p).photonView == (Object)null || PlayerHoldsCompass(p))
			{
				return;
			}
			Plugin.RunDelayed(1.5f, delegate
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (!((Object)(object)p == (Object)null) && !((Object)(object)((MonoBehaviourPun)p).photonView == (Object)null))
					{
						GameObject val = PhotonNetwork.Instantiate("0_Items/Compass", p.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
						Item val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Item>() : null);
						if ((Object)(object)val2 != (Object)null)
						{
							val2.RequestPickup(((MonoBehaviourPun)p).photonView);
						}
						Plugin.Log.LogInfo((object)("[幸运罗盘] 已给复活玩家补发轮盘: " + ((Object)((Component)p).gameObject).name));
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogWarning((object)("[幸运罗盘] 复活补发轮盘失败:" + ex2.Message));
				}
			});
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 发轮盘异常:" + ex.Message));
		}
	}

	internal static bool PlayerHoldsCompass(Character p)
	{
		try
		{
			if ((Object)(object)p == (Object)null || (Object)(object)p.data == (Object)null || (Object)(object)p.data.currentItem == (Object)null)
			{
				return false;
			}
			Item currentItem = p.data.currentItem;
			string text = ((Object)((Component)currentItem).gameObject).name;
			if (text.EndsWith("(Clone)"))
			{
				text = text.Substring(0, text.Length - 7);
			}
			return text.StartsWith("Compass") || currentItem.itemID == 23;
		}
		catch
		{
			return false;
		}
	}

	static GachaExecutor()
	{
		STATUSTYPE[] array = new STATUSTYPE[8];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		RandomStatusPool = (STATUSTYPE[])(object)array;
	}
}
public class GachaNet : MonoBehaviourPunCallbacks
{
	public static GachaNet Instance;

	private static bool _compassGivenThisRun;

	private static int _compassRetryCount;

	private void Awake()
	{
		Instance = this;
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	[PunRPC]
	public void RPCA_GachaSpawn(int type, float x, float y, float z, string s1, string extra)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(x, y, z);
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主执行生成:{(GachaEntryType)type} @ {val} extra={extra}");
			Character requester = null;
			if (!string.IsNullOrEmpty(extra) && extra.StartsWith("TICK:"))
			{
				if (int.TryParse(extra.Substring(5), out var result))
				{
					PhotonView photonView = PhotonNetwork.GetPhotonView(result);
					if ((Object)(object)photonView != (Object)null)
					{
						requester = ((Component)photonView).GetComponent<Character>();
					}
				}
				extra = "";
			}
			GachaExecutor.ExecuteWorldSpawn((GachaEntryType)type, val, s1, 0, requester);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主RPC生成异常:" + ex.ToString()));
		}
	}

	[PunRPC]
	public void RPCA_GachaTornado(float x, float y, float z)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Vector3 pos = new Vector3(x, y, z);
				float value = Plugin.cfgTornadoDelay.Value;
				Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主收到龙卷风请求,固定位置 {pos},广播警告");
				ShowAllWarning("警告:龙卷风即将来袭!", value + 1f);
				Plugin.RunDelayed(value, delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					GachaExecutor.SpawnTornadoAt(pos);
				});
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 房主龙卷风请求异常:" + ex.Message));
		}
	}

	[PunRPC]
	public void RPCA_GiveCompass()
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!PhotonNetwork.IsMasterClient || _compassGivenThisRun)
			{
				return;
			}
			_compassGivenThisRun = true;
			HashSet<int> hashSet = new HashSet<int>();
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null || ((MonoBehaviourPun)allCharacter).photonView.Owner == null)
				{
					continue;
				}
				int actorNumber = ((MonoBehaviourPun)allCharacter).photonView.Owner.ActorNumber;
				if (hashSet.Add(actorNumber))
				{
					GameObject val = PhotonNetwork.Instantiate("0_Items/Compass", allCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
					Item val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Item>() : null);
					if ((Object)(object)val2 != (Object)null)
					{
						val2.RequestPickup(((MonoBehaviourPun)allCharacter).photonView);
					}
				}
			}
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主已给 {hashSet.Count} 名玩家发放罗盘");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 发放罗盘失败:" + ex.Message));
		}
	}

	public static void ResetCompassFlag()
	{
		_compassGivenThisRun = false;
	}

	public static void GiveCompassToAll()
	{
		//IL_00b6: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)Instance == (Object)null)
			{
				GachaExecutor.InitNetworking();
				int num = ++_compassRetryCount;
				Plugin.Log.LogInfo((object)$"[幸运罗盘] 网络组件未就绪,将重试({num}/3)");
				if (num < 3)
				{
					Plugin.RunDelayed(2f, GiveCompassToAll);
				}
				else
				{
					_compassRetryCount = 0;
				}
				return;
			}
			_compassRetryCount = 0;
			if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
			{
				((MonoBehaviourPun)Instance).photonView.RPC("RPCA_GiveCompass", (RpcTarget)2, Array.Empty<object>());
			}
			else if ((Object)(object)Character.localCharacter != (Object)null)
			{
				GameObject val = PhotonNetwork.Instantiate("0_Items/Compass", Character.localCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
				Item val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Item>() : null);
				if ((Object)(object)val2 != (Object)null && (Object)(object)((MonoBehaviourPun)Character.localCharacter).photonView != (Object)null)
				{
					val2.RequestPickup(((MonoBehaviourPun)Character.localCharacter).photonView);
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 发放罗盘异常:" + ex.Message));
		}
	}

	[PunRPC]
	public void RPCA_SyncLuck(int luck)
	{
		LuckSystem.SetLuckFromHost(luck);
	}

	[PunRPC]
	public void RPCA_RequestPenalty(int type, string drawerName)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			GachaEntryType t = (GachaEntryType)type;
			int num = LuckSystem.PenaltyForType(t);
			LuckSystem.AddLuck(-num);
			if (num > 1)
			{
				string text = ((num >= 10) ? (drawerName + "抽中了大奖!幸运值-" + num) : ((num < 5) ? (drawerName + " 使用了罗盘,幸运值-" + num) : (drawerName + "中奖了,幸运值-" + num)));
				GachaHold.ShowInfo(text, 3f);
				((MonoBehaviourPun)Instance).photonView.RPC("RPCA_ShowLuckToast", (RpcTarget)1, new object[1] { text });
			}
			Plugin.Log.LogInfo((object)("[幸运罗盘] 房主结算扣减: " + t.ToString() + " -" + num + " (抽的人=" + drawerName + ")"));
		}
	}

	[PunRPC]
	public void RPCA_RestoreLuck(int amount, string reason)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			LuckSystem.AddLuck(amount);
			string text = reason + " 全队幸运+" + amount + "!";
			GachaHold.ShowInfo(text, 3f);
			((MonoBehaviourPun)Instance).photonView.RPC("RPCA_ShowLuckToast", (RpcTarget)1, new object[1] { text });
		}
	}

	[PunRPC]
	public void RPCA_ShowLuckToast(string text)
	{
		GachaHold.ShowInfo(text, 3f);
	}

	public static void RequestPenalty(GachaEntryType type)
	{
		if ((Object)(object)Instance == (Object)null)
		{
			LuckSystem.AddLuck(-LuckSystem.PenaltyForType(type));
			return;
		}
		string text = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.NickName : "玩家");
		if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Instance.RPCA_RequestPenalty((int)type, text);
				return;
			}
			((MonoBehaviourPun)Instance).photonView.RPC("RPCA_RequestPenalty", (RpcTarget)2, new object[2]
			{
				(int)type,
				text
			});
		}
		else
		{
			LuckSystem.AddLuck(-LuckSystem.PenaltyForType(type));
		}
	}

	public static void BroadcastLuck()
	{
		if (!((Object)(object)Instance == (Object)null))
		{
			int luck = LuckSystem.GetLuck();
			if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
			{
				((MonoBehaviourPun)Instance).photonView.RPC("RPCA_SyncLuck", (RpcTarget)0, new object[1] { luck });
			}
			else
			{
				LuckSystem.SetLuckFromHost(luck);
			}
		}
	}

	public static void RestoreAllLuck(int amount)
	{
		if ((Object)(object)Instance == (Object)null)
		{
			LuckSystem.AddLuck(amount);
			return;
		}
		string text = "【危机救赎】";
		if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Instance.RPCA_RestoreLuck(amount, text);
				return;
			}
			((MonoBehaviourPun)Instance).photonView.RPC("RPCA_RestoreLuck", (RpcTarget)2, new object[2] { amount, text });
		}
		else
		{
			LuckSystem.AddLuck(amount);
		}
	}

	public static void ShowAllWarning(string text, float seconds)
	{
		if ((Object)(object)Instance == (Object)null)
		{
			GachaHold.ShowWarning(text, seconds);
		}
		else if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
		{
			((MonoBehaviourPun)Instance).photonView.RPC("RPCA_ShowWarning", (RpcTarget)0, new object[2] { text, seconds });
		}
		else
		{
			GachaHold.ShowWarning(text, seconds);
		}
	}

	public static void RequestTornado(Vector3 pos)
	{
		//IL_006d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Instance == (Object)null))
		{
			if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
			{
				((MonoBehaviourPun)Instance).photonView.RPC("RPCA_GachaTornado", (RpcTarget)2, new object[3] { pos.x, pos.y, pos.z });
			}
			else
			{
				GachaExecutor.SpawnTornadoAt(pos);
			}
		}
	}
}
public class GachaHold : MonoBehaviour
{
	internal static bool Charging;

	internal static string warningText = "";

	internal static float warningUntil = 0f;

	internal static string infoText = "";

	internal static float infoUntil = 0f;

	internal static float iceBlindUntil = 0f;

	internal static float iceBlindTimeLeft = 0f;

	private int _lastWindow = -1;

	private int _minuteDrawCount;

	private bool _rejected;

	private bool _inLevel;

	private int _missedWindows;

	private float _sleepPressure;

	private float _graceTimer;

	private Dictionary<int, bool> _downedState = new Dictionary<int, bool>();

	private Dictionary<int, float> _lastCompassTime = new Dictionary<int, float>();

	private float _hold;

	private bool _started;

	private static GUIStyle _warningStyle;

	private static GUIStyle _luckStyle;

	private static GUIStyle _infoStyle;

	private static GUIStyle _barStyle;

	private static GUIStyle _textStyle;

	private void Start()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		try
		{
			if (((Scene)(ref scene)).name.StartsWith("Level"))
			{
				_inLevel = true;
				_graceTimer = Plugin.cfgSleepGrace.Value;
				_missedWindows = 0;
				_sleepPressure = 0f;
				_downedState.Clear();
				Plugin.Log.LogInfo((object)("[幸运罗盘] 进入游戏地图 " + ((Scene)(ref scene)).name + ",本局幸运值重置为 100/100"));
				LuckSystem.ResetForNewRun();
				ResetMinuteCounter();
				GachaNet.ResetCompassFlag();
			}
			else
			{
				_inLevel = false;
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] 场景切换处理异常(已拦截):" + ex.Message));
		}
	}

	private void ResetMinuteCounter()
	{
		_lastWindow = -1;
		_minuteDrawCount = 0;
		_rejected = false;
	}

	private int CurrentWindow()
	{
		return Mathf.FloorToInt(Time.time / 60f);
	}

	private void CheckMinuteRefresh()
	{
		int num = CurrentWindow();
		if (num != _lastWindow)
		{
			if (_inLevel && _minuteDrawCount <= 0)
			{
				_missedWindows++;
			}
			else if (_minuteDrawCount > 0)
			{
				_missedWindows = 0;
			}
			_lastWindow = num;
			_minuteDrawCount = 0;
			_rejected = false;
			Plugin.Log.LogInfo((object)("[幸运罗盘] 进入新的60秒窗口(#" + num + "),抽奖计数已刷新(连续空窗 " + _missedWindows + ")"));
		}
	}

	private void TickSleepPressure(Character c)
	{
		if (_graceTimer > 0f)
		{
			_graceTimer -= Time.deltaTime;
			return;
		}
		int num = Mathf.Max(1, (int)Plugin.cfgSleepEmptyWindows.Value);
		if (_missedWindows >= num && LuckSystem.GetLuck() >= -50)
		{
			_sleepPressure += Plugin.cfgSleepDrowsyPerSec.Value * Time.deltaTime;
			if (_sleepPressure >= 0.5f && _sleepPressure - Plugin.cfgSleepDrowsyPerSec.Value * Time.deltaTime < 0.5f)
			{
				ShowWarning("罗盘饥渴难耐:再不抽,你会困到睡着!", 2.5f);
			}
			if ((Object)(object)c != (Object)null && c.refs != null && (Object)(object)c.refs.afflictions != (Object)null)
			{
				c.refs.afflictions.AddStatus((STATUSTYPE)6, Plugin.cfgSleepDrowsyPerSec.Value * Time.deltaTime, false, true, true);
			}
		}
	}

	private void CheckReviveAndGiveCompass()
	{
		if (!_inLevel || Character.AllCharacters == null)
		{
			return;
		}
		HashSet<int> hashSet = new HashSet<int>();
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if ((Object)(object)allCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null || (Object)(object)allCharacter.data == (Object)null)
			{
				continue;
			}
			int viewID = ((MonoBehaviourPun)allCharacter).photonView.ViewID;
			if (!hashSet.Add(viewID) || GachaExecutor.PlayerHoldsCompass(allCharacter))
			{
				continue;
			}
			bool flag = allCharacter.data.dead || allCharacter.data.fullyPassedOut;
			bool value;
			bool flag2 = _downedState.TryGetValue(viewID, out value);
			_downedState[viewID] = flag;
			bool flag3 = false;
			if (flag)
			{
				flag3 = false;
			}
			else if (flag2 && value && !flag)
			{
				flag3 = true;
			}
			else if (!flag2)
			{
				flag3 = true;
			}
			if (flag3)
			{
				float unscaledTime = Time.unscaledTime;
				if (!_lastCompassTime.TryGetValue(viewID, out var value2) || !(unscaledTime - value2 < 10f))
				{
					_lastCompassTime[viewID] = unscaledTime;
					Plugin.Log.LogInfo((object)("[幸运罗盘] 补发轮盘(复活/新加入): " + ((Object)((Component)allCharacter).gameObject).name));
					GachaExecutor.GiveCompassTo(allCharacter);
				}
			}
		}
	}

	private void Update()
	{
		try
		{
			if (Input.GetKeyDown((KeyCode)290))
			{
				DebugDumpHeldItem();
			}
			if (Input.GetKeyDown((KeyCode)291))
			{
				LuckSystem.ResetForNewRun();
				ResetMinuteCounter();
				_missedWindows = 0;
				_sleepPressure = 0f;
				Plugin.Log.LogInfo((object)"[幸运罗盘][F10] Debug:刷新抽取次数 + 重置幸运值 + 清除睡眠压力");
			}
			if (Input.GetKeyDown((KeyCode)292))
			{
				DebugListCreaturePrefabs();
			}
			if (Input.GetKeyDown((KeyCode)293))
			{
				DebugProbeSpore();
			}
			if (Input.GetKeyDown((KeyCode)289))
			{
				DebugDumpStatusFields();
			}
			LuckSystem.TickRegen();
			CheckMinuteRefresh();
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || localCharacter.refs == null)
			{
				ResetHold();
				return;
			}
			if (LoadingScreenHandler.loading || GUIManager.InPauseMenu)
			{
				ResetHold();
				return;
			}
			if (!localCharacter.data.dead && !localCharacter.data.fullyPassedOut)
			{
				TickSleepPressure(localCharacter);
			}
			CheckReviveAndGiveCompass();
			Item currentItem = localCharacter.data.currentItem;
			if (!((Object)(object)currentItem != (Object)null) || !IsGachaItem(currentItem))
			{
				ResetHold();
			}
			else if (localCharacter.data.dead || localCharacter.data.fullyPassedOut)
			{
				ResetHold();
			}
			else if (localCharacter.input.interactIsPressed)
			{
				_hold += Time.deltaTime;
				_started = true;
				Charging = true;
				if (_hold >= Plugin.cfgHoldTime.Value)
				{
					_hold = 0f;
					_started = false;
					Charging = false;
					TriggerDraw(localCharacter, currentItem);
				}
			}
			else
			{
				ResetHold();
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] Update异常(已拦截):" + ex.Message));
			ResetHold();
		}
	}

	private void ResetHold()
	{
		_hold = 0f;
		_started = false;
		Charging = false;
	}

	private static bool IsGachaItem(Item it)
	{
		try
		{
			if ((Object)(object)it == (Object)null)
			{
				return false;
			}
			string text = ((Object)((Component)it).gameObject).name;
			if (text.EndsWith("(Clone)"))
			{
				text = text.Substring(0, text.Length - 7);
			}
			if (text.StartsWith("Compass"))
			{
				return true;
			}
			if (it.itemID == 23)
			{
				return true;
			}
			return false;
		}
		catch
		{
			return false;
		}
	}

	internal static void ShowWarning(string text, float seconds)
	{
		warningText = text;
		warningUntil = Mathf.Max(warningUntil, Time.unscaledTime + seconds);
	}

	internal static void ShowInfo(string text, float seconds)
	{
		infoText = text;
		infoUntil = Mathf.Max(infoUntil, Time.unscaledTime + seconds);
	}

	internal static void ShowIceBlind(float seconds)
	{
		iceBlindUntil = Mathf.Max(iceBlindUntil, Time.unscaledTime + seconds);
	}

	private void TriggerDraw(Character c, Item held)
	{
		CheckMinuteRefresh();
		_missedWindows = 0;
		_sleepPressure = 0f;
		if (_rejected)
		{
			ShowWarning("罗盘拒绝了你!", 2f);
			Plugin.Log.LogWarning((object)"[幸运罗盘] 本60秒窗口抽奖次数已用尽,罗盘拒绝(等待窗口刷新)");
			return;
		}
		_minuteDrawCount++;
		if (_minuteDrawCount == 5)
		{
			Plugin.Log.LogWarning((object)"[幸运罗盘] 本分钟已抽5次,触发最严重惩罚!");
			ShowWarning("罗盘警告:滥用抽奖,触发最严重惩罚!", 3f);
			GachaExecutor.TriggerSeverePunishment(c);
			return;
		}
		if (_minuteDrawCount >= 10)
		{
			Plugin.Log.LogWarning((object)"[幸运罗盘] 本60秒窗口已抽10次,达到上限!");
			ShowWarning("罗盘拒绝了你!", 3f);
			_rejected = true;
			return;
		}
		int luck = LuckSystem.GetLuck();
		Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽取触发!当前幸运值 {luck}/100(本分钟第{_minuteDrawCount}次)");
		GachaEntry gachaEntry = GachaDraw.Draw(luck, c);
		if (gachaEntry != null)
		{
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中 [{gachaEntry.id}] 类型 {gachaEntry.type}");
			GachaExecutor.Execute(gachaEntry, c, luck);
			LuckSystem.ApplyDrawPenalty(gachaEntry.type);
			Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中[{gachaEntry.id}]({gachaEntry.type}) 扣幸运后当前值 {LuckSystem.GetLuck()}/100");
		}
		else
		{
			Plugin.Log.LogWarning((object)"[幸运罗盘] 本次未抽中任何条目(奖池可能为空)");
		}
	}

	private void DebugListCreaturePrefabs()
	{
		try
		{
			string[] array = new string[16]
			{
				"Ghost", "Wraith", "Phantom", "Spirit", "Banshee", "Boom", "Spore", "Fungus", "Cloud", "Mushroom",
				"Frog", "Scorpion", "Bugfix", "Tick", "Eruption", "Tornado"
			};
			Plugin.Log.LogInfo((object)"[幸运罗盘][F11] 开始列出含关键字的prefab名...");
			GameObject[] array2 = Resources.LoadAll<GameObject>("0_Items");
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				string[] array3 = array;
				foreach (string value in array3)
				{
					if (((Object)val).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						Plugin.Log.LogInfo((object)("[幸运罗盘][F11] 找到: " + ((Object)val).name));
						break;
					}
				}
			}
			Plugin.Log.LogInfo((object)"[幸运罗盘][F11] 列出完毕。");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] F11异常:" + ex.Message));
		}
	}

	private void DebugDumpHeldItem()
	{
		try
		{
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || (Object)(object)localCharacter.data.currentItem == (Object)null)
			{
				Plugin.Log.LogInfo((object)"[幸运罗盘][F9] 当前没有手持物品");
				return;
			}
			Item currentItem = localCharacter.data.currentItem;
			string text = "";
			Component[] components = ((Component)currentItem).GetComponents<Component>();
			foreach (Component val in components)
			{
				text = text + ((object)val).GetType().Name + ", ";
			}
			Plugin.Log.LogInfo((object)("[幸运罗盘][F9] 物品名=" + ((Object)((Component)currentItem).gameObject).name + "  itemID=" + currentItem.itemID + "  组件=[" + text + "]"));
			Plugin.Log.LogInfo((object)("[幸运罗盘][F9] 是否指南针(CompassPointer)=" + ((Object)(object)((Component)currentItem).GetComponent<CompassPointer>() != (Object)null)));
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] F9调试异常:" + ex.Message));
		}
	}

	private void DebugProbeSpore()
	{
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Plugin.Log.LogInfo((object)"[幸运罗盘][F12] === 孢子云探测开始 ===");
			int num = 0;
			CloudFungus[] array = Object.FindObjectsOfType<CloudFungus>();
			foreach (CloudFungus val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string text = (((Object)(object)val.instantiateOnBreak != (Object)null) ? ((Object)val.instantiateOnBreak).name : "NULL");
					Plugin.Log.LogInfo((object)("[幸运罗盘][F12] 场景CloudFungus=" + ((Object)((Component)val).gameObject).name + " -> instantiateOnBreak=" + text));
					num++;
				}
			}
			if (num == 0)
			{
				Plugin.Log.LogInfo((object)"[幸运罗盘][F12] 本场景无CloudFungus实例");
			}
			string[] array2 = new string[5] { "Spore", "Cloud", "Gas", "Burst", "Fungus" };
			GameObject[] array3 = Resources.LoadAll<GameObject>("0_Items");
			foreach (GameObject val2 in array3)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				string[] array4 = array2;
				foreach (string value in array4)
				{
					if (((Object)val2).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						Plugin.Log.LogInfo((object)("[幸运罗盘][F12] 0_Items中: " + ((Object)val2).name));
						break;
					}
				}
			}
			if (!PhotonNetwork.IsMasterClient)
			{
				Plugin.Log.LogInfo((object)"[幸运罗盘][F12] 非房主,跳过池探测(请房主按F12)");
			}
			else
			{
				Character localCharacter = Character.localCharacter;
				if ((Object)(object)localCharacter == (Object)null)
				{
					Plugin.Log.LogInfo((object)"[幸运罗盘][F12] 玩家不在场,跳过池探测");
				}
				else
				{
					string[] array4 = new string[5] { "CloudFungus", "CloudFungusPlaced", "Mushroom Cluster", "Mushroom Cluster Poison", "WarpFungus" };
					foreach (string text2 in array4)
					{
						string text3 = "0_Items/" + text2;
						try
						{
							GameObject go = PhotonNetwork.Instantiate(text3, localCharacter.Center + Vector3.up * 1f, Quaternion.identity, (byte)0, (object[])null);
							if (!((Object)(object)go != (Object)null))
							{
								continue;
							}
							string text4 = "";
							Component[] components = go.GetComponents<Component>();
							foreach (Component val3 in components)
							{
								text4 = text4 + ((object)val3).GetType().Name + ", ";
							}
							Plugin.Log.LogInfo((object)("[幸运罗盘][F12] 生成成功: " + text3 + "  组件=[" + text4 + "]"));
							if (text2 == "CloudFungusPlaced" || text2.IndexOf("Mushroom") >= 0 || text2 == "WarpFungus")
							{
								Plugin.RunDelayed(10f, delegate
								{
									if ((Object)(object)go != (Object)null)
									{
										PhotonNetwork.Destroy(go);
									}
								});
								Plugin.Log.LogInfo((object)("[幸运罗盘][F12] " + text2 + " 保留10秒,请靠近触发后按F13扫描雾球"));
							}
							else
							{
								PhotonNetwork.Destroy(go);
							}
						}
						catch (Exception ex)
						{
							Plugin.Log.LogInfo((object)("[幸运罗盘][F12] 生成失败(不在池): " + text3 + "  原因=" + ex.Message));
						}
					}
				}
			}
			Plugin.Log.LogInfo((object)"[幸运罗盘][F12] === 孢子云探测结束 ===");
		}
		catch (Exception ex2)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] F12异常:" + ex2.Message));
		}
	}

	private void DebugDumpStatusFields()
	{
		try
		{
			Plugin.Log.LogInfo((object)"[幸运罗盘][F13] === StatusField球体扫描开始 ===");
			int num = 0;
			StatusField[] array = Object.FindObjectsOfType<StatusField>();
			foreach (StatusField val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					num++;
					Transform transform = ((Component)val).transform;
					string text = ((Object)((Component)transform).gameObject).name;
					Transform parent = transform.parent;
					while ((Object)(object)parent != (Object)null)
					{
						text = ((Object)((Component)parent).gameObject).name + "/" + text;
						parent = parent.parent;
					}
					PhotonView component = ((Component)val).GetComponent<PhotonView>();
					string text2 = (((Object)(object)component != (Object)null) ? ("PhotonView=" + component.ViewID) : "无PhotonView(场景静态)");
					string text3 = (((Object)(object)((Component)val).transform.parent != (Object)null && (Object)(object)((Component)((Component)val).transform.parent).GetComponent<PhotonView>() != (Object)null) ? "父级有PhotonView" : "");
					Plugin.Log.LogInfo((object)("[幸运罗盘][F13] StatusField #" + num + ": " + text + "  " + text2 + "  " + text3));
				}
			}
			if (num == 0)
			{
				Plugin.Log.LogInfo((object)"[幸运罗盘][F13] 本场景无StatusField(请走到孢子团旁边再按)");
			}
			Plugin.Log.LogInfo((object)"[幸运罗盘][F13] === StatusField球体扫描结束 ===");
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("[幸运罗盘] F13异常:" + ex.Message));
		}
	}

	private void OnGUI()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (Time.unscaledTime < warningUntil && !string.IsNullOrEmpty(warningText))
			{
				float num = 700f;
				float num2 = ((float)Screen.width - num) * 0.5f;
				float num3 = (float)Screen.height * 0.35f;
				GUI.Label(new Rect(num2, num3, num, 60f), warningText, WarningStyle());
			}
		}
		catch
		{
		}
		try
		{
			if (Time.unscaledTime < infoUntil && !string.IsNullOrEmpty(infoText))
			{
				GUI.Label(new Rect((float)(Screen.width - 520), (float)Screen.height * 0.5f - 12f, 500f, 24f), infoText, InfoStyle());
			}
		}
		catch
		{
		}
		try
		{
			if (Time.unscaledTime < iceBlindUntil)
			{
				GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01((iceBlindUntil - Time.unscaledTime) / 2f) * 0.6f);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)MakeTex(Color.white));
				GUI.color = Color.white;
			}
		}
		catch
		{
		}
		try
		{
			if (Plugin.cfgShowLuckUI.Value)
			{
				float num4 = (float)Screen.height * 0.8f;
				int minuteDrawCount = _minuteDrawCount;
				bool flag = minuteDrawCount == 5 || minuteDrawCount >= 10;
				float num5 = 60f - Time.time % 60f;
				bool rejected = _rejected;
				GUI.color = (Color)((flag || rejected) ? new Color(1f, 0.2f, 0.2f) : Color.white);
				GUI.Label(new Rect(10f, num4 - 22f, 420f, 20f), "本窗口抽取: " + minuteDrawCount + " / 10   刷新: " + Mathf.CeilToInt(num5) + "秒  " + (rejected ? "罗盘拒绝中" : (flag ? "警告" : "正常")), LuckStyle());
				GUI.color = Color.white;
				GUI.Label(new Rect(10f, num4, 300f, 20f), "全体幸运值: " + LuckSystem.GetLuck(), LuckStyle());
			}
		}
		catch
		{
		}
		if (!_started || !Charging)
		{
			return;
		}
		try
		{
			float num6 = Mathf.Clamp01(_hold / Mathf.Max(0.01f, Plugin.cfgHoldTime.Value));
			float num7 = 300f;
			float num8 = 14f;
			float num9 = ((float)Screen.width - num7) * 0.5f;
			float num10 = (float)Screen.height * 0.72f;
			GUI.Box(new Rect(num9 - 2f, num10 - 2f, num7 + 4f, num8 + 4f), "");
			GUI.Box(new Rect(num9, num10, num7 * num6, num8), "", BarStyle());
			GUI.Label(new Rect(num9, num10 - 22f, num7, 20f), "幸运罗盘抽取中...", TextStyle());
		}
		catch
		{
		}
	}

	private static GUIStyle WarningStyle()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (_warningStyle == null)
		{
			_warningStyle = new GUIStyle();
			_warningStyle.fontSize = 42;
			_warningStyle.normal.textColor = new Color(1f, 0.25f, 0.1f);
		}
		return _warningStyle;
	}

	private static GUIStyle LuckStyle()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		if (_luckStyle == null)
		{
			_luckStyle = new GUIStyle();
			_luckStyle.fontSize = 16;
			_luckStyle.normal.textColor = Color.white;
		}
		return _luckStyle;
	}

	private static GUIStyle InfoStyle()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if (_infoStyle == null)
		{
			_infoStyle = new GUIStyle(GUI.skin.label);
			_infoStyle.fontSize = 18;
			_infoStyle.normal.textColor = new Color(1f, 0.85f, 0.3f);
			_infoStyle.alignment = (TextAnchor)5;
		}
		return _infoStyle;
	}

	private static GUIStyle BarStyle()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		if (_barStyle == null)
		{
			_barStyle = new GUIStyle();
			_barStyle.normal.background = MakeTex(new Color(0.2f, 0.9f, 0.3f, 0.9f));
		}
		return _barStyle;
	}

	private static GUIStyle TextStyle()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if (_textStyle == null)
		{
			_textStyle = new GUIStyle(GUI.skin.label);
			_textStyle.fontSize = 18;
			_textStyle.normal.textColor = Color.white;
		}
		return _textStyle;
	}

	private static Texture2D MakeTex(Color c)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(2, 2);
		for (int i = 0; i < ((Texture)val).width; i++)
		{
			for (int j = 0; j < ((Texture)val).height; j++)
			{
				val.SetPixel(i, j, c);
			}
		}
		val.Apply();
		return val;
	}
}
[HarmonyPatch(typeof(Interaction))]
public static class InteractionPatch
{
	[HarmonyPatch("LateUpdate")]
	[HarmonyPrefix]
	private static bool Prefix()
	{
		return !GachaHold.Charging;
	}
}
public static class LuckSystem
{
	public const int LUCK_MAX = 100;

	public const int LUCK_MIN = -100;

	private static int _luck = 100;

	private static float _regenTimer = 0f;

	private static float _negTimer = 0f;

	public static int GetLuck()
	{
		return _luck;
	}

	private static bool IsHost()
	{
		if (PhotonNetwork.InRoom)
		{
			return PhotonNetwork.IsMasterClient;
		}
		return true;
	}

	public static void ResetForNewRun()
	{
		_luck = 100;
		_regenTimer = 0f;
		_negTimer = 0f;
		if (IsHost())
		{
			GachaNet.BroadcastLuck();
		}
	}

	public static void AddLuck(int delta)
	{
		_luck = Mathf.Clamp(_luck + delta, -100, 100);
		GachaNet.BroadcastLuck();
	}

	public static void SetLuckFromHost(int value)
	{
		_luck = Mathf.Clamp(value, -100, 100);
	}

	public static int PenaltyForType(GachaEntryType t)
	{
		switch (t)
		{
		case GachaEntryType.Legendary:
			return Plugin.cfgLegendaryPenalty.Value;
		case GachaEntryType.Mythic:
			return Plugin.cfgMythicPenalty.Value;
		case GachaEntryType.Equipment:
		case GachaEntryType.Luggage:
			return Plugin.cfgEpicPenalty.Value;
		default:
			return 1;
		}
	}

	public static void ApplyDrawPenalty(GachaEntryType t)
	{
		GachaNet.RequestPenalty(t);
	}

	public static void TickRegen()
	{
		if (!IsHost() || !(Plugin.cfgLuckRegenSeconds.Value > 0f))
		{
			return;
		}
		_regenTimer += Time.deltaTime;
		if (_regenTimer >= Plugin.cfgLuckRegenSeconds.Value)
		{
			_regenTimer = 0f;
			if (_luck < 100)
			{
				AddLuck(1);
			}
		}
	}
}
[BepInPlugin("com.scout.gachamod", "PEAK幸运罗盘抽奖模组", "2.1.0")]
public class Plugin : BaseUnityPlugin
{
	internal static Plugin Instance;

	internal static ManualLogSource Log;

	internal static ConfigEntry<float> cfgHoldTime;

	internal static ConfigEntry<bool> cfgSuppressInteract;

	internal static ConfigEntry<float> cfgLuckRegenSeconds;

	internal static ConfigEntry<int> cfgMythicPenalty;

	internal static ConfigEntry<int> cfgEpicPenalty;

	internal static ConfigEntry<bool> cfgShowLuckUI;

	internal static ConfigEntry<string> cfgPool1;

	internal static ConfigEntry<float> cfgPool1Weight;

	internal static ConfigEntry<string> cfgPool2;

	internal static ConfigEntry<float> cfgPool2Weight;

	internal static ConfigEntry<string> cfgPool3;

	internal static ConfigEntry<float> cfgPool3Weight;

	internal static ConfigEntry<bool> cfgStatueModeA;

	internal static ConfigEntry<string> cfgZombieName;

	internal static ConfigEntry<string> cfgBeeName;

	internal static ConfigEntry<string> cfgDynamiteName;

	internal static ConfigEntry<string> cfgSporeFogName;

	internal static ConfigEntry<float> cfgSporeRadius;

	internal static ConfigEntry<float> cfgSporeDuration;

	internal static ConfigEntry<float> cfgSporePerSec;

	internal static ConfigEntry<string> cfgGhostName;

	internal static ConfigEntry<string> cfgFrogName;

	internal static ConfigEntry<string> cfgScorpionName;

	internal static ConfigEntry<string> cfgTickName;

	internal static ConfigEntry<float> cfgTornadoDelay;

	internal static ConfigEntry<int> cfgSeverePump;

	internal static ConfigEntry<float> cfgSleepEmptyWindows;

	internal static ConfigEntry<float> cfgSleepDrowsyPerSec;

	internal static ConfigEntry<float> cfgSleepGrace;

	internal static ConfigEntry<float> cfgEruptionDelay;

	internal static ConfigEntry<float> cfgStatusAllChance;

	internal static ConfigEntry<float> cfgMushroomBlindTime;

	internal static ConfigEntry<float> cfgLegendaryChance;

	internal static ConfigEntry<int> cfgLegendaryPenalty;

	internal static ConfigEntry<string> cfgLegendaryPool;

	internal static ConfigEntry<string> cfgBannedItems;

	internal static ConfigEntry<float> cfgFatigueWindow;

	internal static ConfigEntry<int> cfgFatigueLimit;

	internal static ConfigEntry<string> cfgFatiguePunishment;

	private void Awake()
	{
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		LoadConfig();
		Harmony.CreateAndPatchAll(typeof(InteractionPatch), (string)null);
		((Component)this).gameObject.AddComponent<GachaHold>();
		GachaExecutor.InitNetworking();
		Log.LogInfo((object)"[幸运罗盘] 模组 v2.1 已加载。开局幸运值固定100。F9=物品信息 F10=重置幸运值 F11=列出prefab名。");
	}

	internal static void RunDelayed(float seconds, Action action)
	{
		if (!((Object)(object)Instance == (Object)null))
		{
			((MonoBehaviour)Instance).StartCoroutine(DelayedRoutine(seconds, action));
		}
	}

	private static IEnumerator DelayedRoutine(float seconds, Action action)
	{
		yield return (object)new WaitForSeconds(seconds);
		try
		{
			action();
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("[幸运罗盘] 延迟动作异常(已拦截):" + ex.Message));
		}
	}

	private void LoadConfig()
	{
		cfgHoldTime = ((BaseUnityPlugin)this).Config.Bind<float>("触发", "长按互动键时长(秒)", 1f, "手持幸运罗盘时,按住游戏【互动键】达到该时长后触发抽取。支持玩家改键。");
		cfgSuppressInteract = ((BaseUnityPlugin)this).Config.Bind<bool>("触发", "蓄力时屏蔽普通互动", true, "为true时:长按互动键蓄力期间,不触发对世界物体/队友的普通互动。");
		cfgLuckRegenSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("幸运值", "幸运值回复间隔(秒)", 60f, "每抽一次幸运值-1(神话-10/史诗-5/普通-1)。经过该秒数回复+1(上限100)。设为0关闭回复。\n幸运值范围:-100 ~ 100,每局开局固定100。\n抽到最严重负面效果时,全队共享幸运+8。");
		cfgMythicPenalty = ((BaseUnityPlugin)this).Config.Bind<int>("幸运值", "神话级惩罚", 10, "抽到神话级物品时幸运值扣除数。");
		cfgEpicPenalty = ((BaseUnityPlugin)this).Config.Bind<int>("幸运值", "史诗级惩罚", 5, "抽到史诗级物品(装备/行李箱)时幸运值扣除数。");
		cfgShowLuckUI = ((BaseUnityPlugin)this).Config.Bind<bool>("幸运值", "显示幸运值UI", true, "为true时:在屏幕左下角状态条上方实时显示【自己】的幸运值。");
		cfgPool1 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池1-正面增益", "奖池内容", "Buff1|InfiniteStamina|20|0|14|1;Buff2|SpeedBuff|0.5|1.5|10|1;Buff3|Invincibility|8|0|9|2;Buff4|LowGravity|3|15|8|1;Buff5|RestoreStatus|0.4|0|12|1;Buff6|MoraleBoost|0.25|0|10|1;Buff7|ExtraStamina|0.6|0|8|1", "大奖池1(正面增益)条目。格式:条目ID|类型|参数1|参数2|权重|幸运偏向\n类型:InfiniteStamina|秒数;SpeedBuff|移速,攀爬(12秒);Invincibility|秒数;\nLowGravity|档位(1~3),秒数;RestoreStatus|恢复量;MoraleBoost|体力回复;ExtraStamina|额外体力\n幸运偏向:>0幸运越高越易抽中;<0越低越易;0不受影响。");
		cfgPool1Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池1-正面增益", "奖池权重", 40f, "第一次抽取时,该大奖池基础权重。仅受幸运值降低影响。");
		cfgPool2 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池2-稀有奖励", "奖池内容", "Rare1|Revive|0|0|3|5;Rare2|Bugle|0|0|5|3;Rare3|RandomLoot|0|0|6|2;Rare4|RandomItem|0|0|5|2;Rare5|Mythic|0|0|5|5;Rare6|Equipment|0|0|5|2;Rare7|Luggage|0|0|3|2;Rare8|GiveItem|Guidebook|0|2|1;Rare9|GiveItem|Frisbee|0|2|1", "大奖池2(稀有奖励)条目。类型:RandomLoot/RandomItem/Mythic/Equipment/Luggage/GiveItem/Bugle/Revive。\n幸运降低时该池权重被大幅压低。");
		cfgPool2Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池2-稀有奖励", "奖池权重", 20f, "第一次抽取时,该大奖池基础权重。仅受幸运值降低影响。");
		cfgPool3 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池3-负面危机", "奖池内容", "Bad1|SpawnZombie|0|0|9|-1;Bad2|SpawnBees|0|0|8|-1;Bad3|SpawnDynamite|0|0|7|-1;Bad4|Pandora|0|0|6|-2;Bad5|AllBomb|0|0|6|-3;Bad6|Tornado|0|0|5|-2;Bad7|Eruption|0|0|5|-2;Bad8|SpawnFrog|0|0|6|-2;Bad9|SpawnScorpion|0|0|6|-2;Bad10|TickParasite|0|0|4|-2;Bad11|IceBlind|0|0|5|-1;Bad12|StatusPoison|0|0|6|-1;Bad13|StatusSleep|0|0|6|-1;Bad14|StatusRandom|0|0|5|-1;Bad15|StatusAll|0|0|2|-3;Bad16|SteamExplode|0|0|5|-2;Bad17|SporeFog|0|0|5|-1;Bad18|GhostBoom|0|0|4|-2;Bad19|MushroomBlind|0|0|4|-2", "大奖池3(负面危机)条目。类型:\nSpawnZombie|生成僵尸;SpawnBees|生成蜜蜂;SpawnDynamite|面前生成炸药(靠近自动点燃);\nPandora|潘多拉魔盒瞬爆;AllBomb|所有玩家获得炸弹;Tornado|固定位置龙卷风;\nEruption|延迟火山喷发;SpawnFrog|按幸运值生成青蛙(高1只/0~-50两只/<-50三只);\nSpawnScorpion|按幸运值生成蝎子(同青蛙数量规则);TickParasite|一只蜱虫寄生在抽取者身上;\nIceBlind|雪山寒冰果式冰雪覆盖视野;StatusPoison|中毒;StatusSleep|瞌睡;\nStatusRandom|随机单一负面;StatusAll|极小概率(1%)所有负面;SteamExplode|蒸气爆炸弹飞;\nSporeFog|脚下生成爆炸/毒气孢子;GhostBoom|自爆大幽灵。\n生成类失败自动改为负面状态惩罚。最严重负面(AllBomb/Pandora/Tornado/Eruption/StatusAll/GhostBoom)触发时所有玩家幸运+5。");
		cfgPool3Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池3-负面危机", "奖池权重", 30f, "第一次抽取时,该大奖池基础权重。幸运降低时权重大幅提高。");
		cfgStatueModeA = ((BaseUnityPlugin)this).Config.Bind<bool>("童军雕像", "生成道具模式(方案A)", false, "false=方案B(默认):抽奖时先扫描场上有无待复活玩家,有则把【复活】条目纳入,没有则屏蔽;\ntrue=方案A:改为在你面前生成一个复活道具(ScoutEffigy)。");
		cfgZombieName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "僵尸prefab名", "MushroomZombie", "僵尸prefab名。默认 MushroomZombie。留空则自动探测场景。");
		cfgBeeName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "蜜蜂prefab名", "", "蜜蜂prefab名(裸名,不加0_Items/前缀)。留空自动从场景蜂巢引用探测,找不到再兜底 BeeSwarm。");
		cfgDynamiteName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "炸药prefab名", "0_Items/Dynamite", "炸药prefab名。默认 0_Items/Dynamite。生成后玩家靠近会自动点燃。");
		cfgSporeFogName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "孢子生成物prefab名", "CloudFungus", "孢子云生成物prefab名(Photon池名)。默认 CloudFungus:还原原生生成链 云蕈→爆开→CloudFungusPlaced孢子云。");
		cfgSporeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("负面生成物", "孢子云球半径", 4f, "孢子云球生效半径(米)。球内玩家持续叠毒。");
		cfgSporeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("负面生成物", "孢子云持续秒数", 8f, "孢子云球持续生效秒数。");
		cfgSporePerSec = ((BaseUnityPlugin)this).Config.Bind<float>("负面生成物", "孢子云每秒叠毒量", 0.1f, "球内玩家每秒增加的孢子条量(0~1满条)。毒条为一半。参考游戏StatusField节奏。");
		cfgGhostName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "大幽灵prefab名", "", "自爆大幽灵的prefab名。默认 GhostBall,留空自动探测含Ghost/Wraith/Phantom/Spirit/Banshee关键字。");
		cfgFrogName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生