Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BlindBox v1.0.3
REPO_BlindBox.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("REPO_MangHe")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("SOSRY7C6PMFEVJP")] [assembly: AssemblyProduct("REPO_MangHe")] [assembly: AssemblyCopyright("Copyright © SOSRY7C6PMFEVJP 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ebf26a1c-6184-467c-8d83-5eda2e350512")] [assembly: AssemblyFileVersion("1.0.2")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] namespace REPO_MangHe; [BepInPlugin("com.xiaohai.REPO_BlindBox", "REPO_MBlindBox", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.xiaohai.REPO_BlindBox"; public const string PLUGIN_NAME = "REPO_MBlindBox"; public const string PLUGIN_VERSION = "1.0.2"; public static Plugin instance; public static ManualLogSource logger; public GameObject asakiPrefab; public GameObject ManghePrefab; public GameObject landMindPrefeb; public AudioClip mineBeep; public AudioClip asakiMua; public static ConfigEntry<float> ChanceValuable; public static ConfigEntry<float> ChanceEnemy; public static ConfigEntry<float> ChanceAsaki; public static ConfigEntry<float> ChanceEvent; public static ConfigEntry<float> ChanceMoney; public static ConfigEntry<float> ChanceShopItem; private void Awake() { //IL_0197: Unknown result type (might be due to invalid IL or missing references) instance = this; logger = ((BaseUnityPlugin)this).Logger; logger.LogInfo((object)"插件 REPO_MBlindBox v1.0.2 已加载 / Plugin REPO_MBlindBox v1.0.2 loaded"); ChanceValuable = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现中小型贵重物品概率 ChanceValuable", 0.8f, "出现中小型贵重物品概率(会自动调整以确保总和=1) / Chance to spawn small/medium valuables (auto-adjusted so total=1)."); ChanceEnemy = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现敌人概率 ChanceEnemy", 0.05f, "出现敌人概率 / Chance to spawn an enemy."); ChanceAsaki = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现韩立雕像概率 ChanceHanli", 0.05f, "出现韩立雕像概率 / Chance to spawn Hanli statue."); ChanceEvent = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现特殊事件(如地雷 传送门)概率 ChanceEvent", 0.03f, "出现特殊事件(地雷/传送)概率 / Chance to trigger a special event (landmine/teleport)."); ChanceMoney = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现钱袋概率 ChanceMoney", 0.02f, "出现钱袋概率 / Chance to spawn a money bag."); ChanceShopItem = ((BaseUnityPlugin)this).Config.Bind<float>("BlindBox", "出现商店物品概率 ChanceShopItem", 0.05f, "出现商店物品概率 / Chance to spawn a shop item."); ChanceValuable.SettingChanged += OnChanceChanged; ChanceEnemy.SettingChanged += OnChanceChanged; ChanceAsaki.SettingChanged += OnChanceChanged; ChanceEvent.SettingChanged += OnChanceChanged; ChanceMoney.SettingChanged += OnChanceChanged; ChanceShopItem.SettingChanged += OnChanceChanged; NormalizeChances(); LoadAB(); new Harmony("com.xiaohai.REPO_BlindBox").PatchAll(); } private void Start() { LoadLandAB(); } private void OnChanceChanged(object sender, EventArgs e) { NormalizeChances(); } private void NormalizeChances() { float num = Mathf.Max(ChanceEnemy.Value, 0f) + Mathf.Max(ChanceAsaki.Value, 0f) + Mathf.Max(ChanceEvent.Value, 0f) + Mathf.Max(ChanceMoney.Value, 0f) + Mathf.Max(ChanceShopItem.Value, 0f); float num2 = 1f - num; if (num2 < 0f) { num2 = 0f; } if (Mathf.Abs(ChanceValuable.Value - num2) > 0.0001f) { ChanceValuable.Value = num2; } ((BaseUnityPlugin)this).Config.Bind<string>("A盲盒说明 / Info", "概率说明 / Probability Note", "", "概率总和必须等于 1,否则会自动调整贵重物品概率使总和为 1。 / The sum of probabilities must equal 1; otherwise the valuables chance is auto-adjusted to make the total 1."); } private static AssetBundle LoadOrReuseBundle(string path, string logicalName, params string[] probeAssets) { foreach (AssetBundle b in AssetBundle.GetAllLoadedAssetBundles()) { try { if (!string.IsNullOrEmpty(logicalName) && ((Object)b).name == logicalName) { return b; } if (probeAssets != null && probeAssets.Any((string a) => b.Contains(a))) { return b; } } catch { } } return AssetBundle.LoadFromFile(path); } private void LoadAB() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); string text = Path.Combine(directoryName, "blindbox"); AssetBundle val = AssetBundle.LoadFromFile(text); asakiPrefab = val.LoadAsset<GameObject>("Valuable Hanli.prefab"); ManghePrefab = val.LoadAsset<GameObject>("Valuable AsakiManghe.prefab"); if ((Object)(object)asakiPrefab == (Object)null || (Object)(object)ManghePrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"加载预制体失败 / Failed to load prefabs (Asaki / Blind Box)"); return; } ManghePrefab.gameObject.transform.localScale = Vector3.one * 0.6f; NetworkPrefabs.RegisterNetworkPrefab(asakiPrefab); NetworkPrefabs.RegisterNetworkPrefab(ManghePrefab); asakiPrefab.AddComponent<Asaki>(); ManghePrefab.AddComponent<Manghe>(); logger.LogInfo((object)"盲盒预制体加载成功 / Blind Box prefabs loaded successfully"); } private void LoadLandAB() { string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); string path = Path.Combine(directoryName, "landmine"); AssetBundle val = LoadOrReuseBundle(path, null, "LandMine.prefab", "MineBeep.ogg"); mineBeep = val.LoadAsset<AudioClip>("MineBeep.ogg"); if ((Object)(object)mineBeep == (Object)null) { Debug.LogError((object)"加载音频资源 MineBeep.ogg 失败 / Failed to load audio MineBeep.ogg"); } landMindPrefeb = val.LoadAsset<GameObject>("LandMine.prefab"); if ((Object)(object)landMindPrefeb == (Object)null) { Debug.LogError((object)"加载预制体 LandMine.prefab 失败 / Failed to load prefab LandMine.prefab"); } landMindPrefeb.AddComponent<LandMind>(); NetworkPrefabs.RegisterNetworkPrefab(landMindPrefeb); } } [HarmonyPatch] public static class Patch { [HarmonyPatch(typeof(ValuableObject))] public static class ValuableObjectPatch { [HarmonyPatch("DollarValueSetLogic")] [HarmonyPostfix] private static void DollarValueSetLogicPostFix(ValuableObject __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (((Object)__instance).name.Contains("AsakiManghe") && SemiFunc.IsMasterClientOrSingleplayer()) { float num = ((Component)__instance).gameObject.GetComponent<MangheData>()?.value ?? 233f; if (SemiFunc.IsMultiplayer()) { __instance.photonView.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num }); } else { __instance.DollarValueSetRPC(num, default(PhotonMessageInfo)); } } } } [HarmonyPatch(typeof(RoundDirector))] public static class RoundDirectorPatch { private static float timer; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch() { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) timer += Time.deltaTime; if (timer < 5f || (Object)(object)RoundDirector.instance == (Object)null) { return; } timer = 0f; if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || RoundDirector.instance.allExtractionPointsCompleted) { return; } Manghe[] array = Object.FindObjectsByType<Manghe>((FindObjectsSortMode)0); if (array.Length != 0) { return; } ValuableObject[] array2 = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); float num = 0f; ValuableObject[] array3 = array2; foreach (ValuableObject val in array3) { if (Object.op_Implicit((Object)(object)val) && !((Object)val).name.Contains("AsakiManghe")) { num += val.dollarValueCurrent; } } int num2 = Mathf.CeilToInt(((float)RoundDirector.instance.extractionHaulGoal - num) / 1000f); if (num2 > 0) { int num3 = Mathf.Min(num2, 10) + 1; for (int j = 0; j < num3; j++) { Vector3 randomValuablePoint = Manghe.GetRandomValuablePoint(); GameObject val2 = ((!GameManager.Multiplayer()) ? Object.Instantiate<GameObject>(Plugin.instance.ManghePrefab, randomValuablePoint, Plugin.instance.ManghePrefab.transform.rotation) : PhotonNetwork.InstantiateRoomObject(((Object)Plugin.instance.ManghePrefab).name, randomValuablePoint, Plugin.instance.ManghePrefab.transform.rotation, (byte)0, (object[])null)); MangheData mangheData = val2.AddComponent<MangheData>(); mangheData.SetValue(1000f); } } } } [HarmonyPatch(typeof(LevelGenerator))] public class LevelGeneratorPatch { [HarmonyPatch("GenerateDone")] [HarmonyPostfix] private static void AfterLevelGenerated(LevelGenerator __instance) { //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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (!ShouldRunCustomLogic()) { return; } Plugin.logger.LogInfo((object)"关卡生成完成,开始替换贵重物品为盲盒 / Level generated, replacing valuables with blind boxes"); ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); ValuableObject[] array2 = array; foreach (ValuableObject val in array2) { float dollarValueCurrent = val.dollarValueCurrent; Type volumeType = val.volumeType; Object.Destroy((Object)(object)((Component)val).gameObject); if (SemiFunc.IsMasterClientOrSingleplayer()) { GameObject val2 = ((!GameManager.Multiplayer()) ? Object.Instantiate<GameObject>(Plugin.instance.ManghePrefab, ((Component)val).transform.position, Plugin.instance.ManghePrefab.transform.rotation) : PhotonNetwork.InstantiateRoomObject(((Object)Plugin.instance.ManghePrefab).name, ((Component)val).transform.position, Plugin.instance.ManghePrefab.transform.rotation, (byte)0, (object[])null)); MangheData mangheData = val2.AddComponent<MangheData>(); mangheData.SetValue(233f); mangheData.volumeType = volumeType; } } } private static bool ShouldRunCustomLogic() { RunManager instance = RunManager.instance; return (Object)(object)instance != (Object)null && instance.levels.Contains(instance.levelCurrent) && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelTutorial && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelShop && (Object)(object)instance.levelCurrent != (Object)(object)instance.levelLobbyMenu; } } } public class MangheData : MonoBehaviour { public float value; public Type volumeType = (Type)2; public void SetValue(float val) { value = val; } } public class Manghe : MonoBehaviourPun { private enum BoxOutcome { Valuable, Enemy, Asaki, Event, Money, Item } [CompilerGenerated] private sealed class <EnemyTeleportWhenReady>d__25 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public EnemyParent ep; public Enemy enemy; public Vector3 pos; private float <window>5__1; private float <accumulated>5__2; private float <logTick>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnemyTeleportWhenReady>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; Plugin.logger.LogInfo((object)"准备传送 / Preparing teleport"); <window>5__1 = 10f; <accumulated>5__2 = 0f; <logTick>5__3 = 0f; break; case 1: <>1__state = -1; break; } if (<window>5__1 > 0f) { if (!Object.op_Implicit((Object)(object)ep)) { return false; } if (ep.DespawnedTimer <= 0f) { <accumulated>5__2 += Time.deltaTime; <logTick>5__3 += Time.deltaTime; if (<logTick>5__3 >= 0.5f) { Plugin.logger.LogInfo((object)$"等待敌人可传送 DespawnedTimer<=0 累计:{<accumulated>5__2:F2}s 当前:{ep.DespawnedTimer} / Waiting enemy ready Acc:{<accumulated>5__2:F2}s Cur:{ep.DespawnedTimer}"); <logTick>5__3 = 0f; } } if (<accumulated>5__2 >= 2f && (Object)(object)ep.Enemy != (Object)null) { Plugin.logger.LogInfo((object)"执行传送 / Teleporting now"); enemy.EnemyTeleported(pos); return false; } <window>5__1 -= Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <FreezeAndSpawnCoroutine>d__31 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 position; public PlayerAvatar target; public Manghe <>4__this; private int <i>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FreezeAndSpawnCoroutine>d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.FreezePlayer(target); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; <i>5__1 = 0; break; case 2: <>1__state = -1; <i>5__1++; break; } if (<i>5__1 < 10) { if (SemiFunc.IsMasterClient()) { target.photonView.RPC("SpawnRPC", (RpcTarget)0, new object[2] { position, ((Component)target).transform.rotation }); } else { target.SpawnRPC(position, ((Component)target).transform.rotation, default(PhotonMessageInfo)); } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } <>4__this.UnfreezePlayer(target); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OpenAndDestroy>d__14 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Manghe <>4__this; private Vector3 <pos>5__1; private Quaternion <rot>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OpenAndDestroy>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0076: 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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.8f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } <pos>5__1 = ((Component)<>4__this).transform.position; <rot>5__2 = ((Component)<>4__this).transform.rotation; <>4__this.ExecuteOutcome(<pos>5__1, <rot>5__2); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private BoxOutcome selectedOutcome; private bool outcomeSet; private Vector3 frozenVelocity; private float frozenAngularVelocity; public bool isMovementFrozen = false; private string openerSteamId; private PhysGrabObject phys; private PhysGrabObjectImpactDetector impact; private bool opened; private Coroutine pending; private PlayerAvatar grabber; private void Start() { phys = ((Component)this).GetComponent<PhysGrabObject>(); impact = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if (SemiFunc.IsMasterClientOrSingleplayer()) { selectedOutcome = ChooseOutcome(); outcomeSet = true; ApplySmokeColor(selectedOutcome); if (GameManager.Multiplayer()) { ((MonoBehaviourPun)this).photonView.RPC("SetOutcomeRPC", (RpcTarget)3, new object[1] { (int)selectedOutcome }); } } } private void Update() { if (opened || !((Object)(object)phys != (Object)null) || (!phys.grabbed && phys.playerGrabbing.Count <= 0)) { return; } grabber = phys.lastPlayerGrabbing; if (SemiFunc.IsMultiplayer()) { string text = (Object.op_Implicit((Object)(object)grabber) ? grabber.steamID : null); if (!string.IsNullOrEmpty(text)) { openerSteamId = text; if (!SemiFunc.IsMasterClient()) { ((MonoBehaviourPun)this).photonView.RPC("SetOpenerRPC", (RpcTarget)2, new object[1] { text }); } } } else { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); openerSteamId = (Object.op_Implicit((Object)(object)val) ? val.steamID : null); } opened = true; if (pending == null) { pending = ((MonoBehaviour)this).StartCoroutine(OpenAndDestroy()); } } [IteratorStateMachine(typeof(<OpenAndDestroy>d__14))] private IEnumerator OpenAndDestroy() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OpenAndDestroy>d__14(0) { <>4__this = this }; } private void ExecuteOutcome(Vector3 pos, Quaternion rot) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_007d: Unknown result type (might be due to invalid IL or missing references) Plugin.logger.LogInfo((object)"触发开箱效果 / Blind box opened"); switch (selectedOutcome) { case BoxOutcome.Valuable: SpawnRandomValuable(pos); break; case BoxOutcome.Enemy: { SpawnEnemy(pos, out var _); break; } case BoxOutcome.Asaki: SpawnAsaki(pos); break; case BoxOutcome.Event: SpawnEvent(pos); break; case BoxOutcome.Money: SpawnMoney(pos, 5f, 999f); break; case BoxOutcome.Item: SpawnItem(pos); break; } if (GameManager.Multiplayer()) { PhotonNetwork.Destroy(((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnDestroy() { if (!opened || !outcomeSet) { return; } Transform val = ((Component)this).transform.Find("Smoke"); if (Object.op_Implicit((Object)(object)val)) { val.SetParent((Transform)null); ParticleSystem component = ((Component)val).GetComponent<ParticleSystem>(); if (Object.op_Implicit((Object)(object)component)) { ApplySmokeColor(selectedOutcome); component.Play(); } } } private BoxOutcome ChooseOutcome() { float num = Mathf.Max(Plugin.ChanceValuable.Value, 0f); float num2 = Mathf.Max(Plugin.ChanceEnemy.Value, 0f); float num3 = Mathf.Max(Plugin.ChanceAsaki.Value, 0f); float num4 = Mathf.Max(Plugin.ChanceEvent.Value, 0f); float num5 = Mathf.Max(Plugin.ChanceMoney.Value, 0f); float num6 = Mathf.Max(Plugin.ChanceShopItem.Value, 0f); float num7 = num + num2 + num3 + num4 + num5 + num6; if (num7 <= 0f) { num7 = 1f; } float num8 = Random.value * num7; if (num8 < num) { return BoxOutcome.Valuable; } num8 -= num; if (num8 < num2) { return BoxOutcome.Enemy; } num8 -= num2; if (num8 < num3) { return BoxOutcome.Asaki; } num8 -= num3; if (num8 < num4) { return BoxOutcome.Event; } num8 -= num4; if (num8 < num5) { return BoxOutcome.Money; } return BoxOutcome.Item; } private void ApplySmokeColor(BoxOutcome outcome) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_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) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find("Smoke"); ParticleSystem val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<ParticleSystem>() : null); if (Object.op_Implicit((Object)(object)val2)) { MainModule main = val2.main; switch (outcome) { case BoxOutcome.Enemy: ((MainModule)(ref main)).startColor = new MinMaxGradient(Color.black); break; case BoxOutcome.Asaki: ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.5f, 0.8f)); break; case BoxOutcome.Event: ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.4f, 0f)); break; case BoxOutcome.Money: ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.84f, 0f)); break; case BoxOutcome.Item: ((MainModule)(ref main)).startColor = new MinMaxGradient(Color.green); break; case BoxOutcome.Valuable: break; } } } [PunRPC] private void SetOutcomeRPC(int outcomeValue) { selectedOutcome = (BoxOutcome)outcomeValue; outcomeSet = true; ApplySmokeColor(selectedOutcome); } private void SpawnRandomValuable(Vector3 pos) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) Level level = LevelGenerator.Instance.Level; List<PrefabRef> list = new List<PrefabRef>(); List<PrefabRef> list2 = new List<PrefabRef>(); foreach (LevelValuables valuablePreset in level.ValuablePresets) { list.AddRange(valuablePreset.small); list.AddRange(valuablePreset.medium); list.AddRange(valuablePreset.tiny); list.AddRange(valuablePreset.big); list.AddRange(valuablePreset.wide); list.AddRange(valuablePreset.veryTall); list.AddRange(valuablePreset.tall); } MangheData component = ((Component)this).GetComponent<MangheData>(); Type val = (Type)1; if ((Object)(object)component != (Object)null) { val = component.volumeType; } foreach (PrefabRef item in list) { ValuableObject component2 = item.Prefab.GetComponent<ValuableObject>(); if (component2.volumeType == val) { list2.Add(item); } } if (list2.Count != 0) { PrefabRef val2 = list2[Random.Range(0, list2.Count)]; GameObject val3 = ((!GameManager.Multiplayer()) ? Object.Instantiate<GameObject>(val2.Prefab, pos, val2.Prefab.transform.rotation) : PhotonNetwork.InstantiateRoomObject(val2.ResourcePath, pos, val2.Prefab.transform.rotation, (byte)0, (object[])null)); ValuableObject component3 = val3.GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component3)) { component3.DollarValueSetLogic(); } } } private void SpawnAsaki(Vector3 pos) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) if (!((Object)(object)Plugin.instance.asakiPrefab == (Object)null)) { GameObject val = ((!GameManager.Multiplayer()) ? Object.Instantiate<GameObject>(Plugin.instance.asakiPrefab, pos, Plugin.instance.asakiPrefab.transform.rotation) : PhotonNetwork.InstantiateRoomObject(((Object)Plugin.instance.asakiPrefab).name, pos, Plugin.instance.asakiPrefab.transform.rotation, (byte)0, (object[])null)); ValuableObject component = val.GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { component.DollarValueSetLogic(); } } } public static Vector3 GetRandomPoint() { //IL_002b: 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) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) LevelPoint[] array = Object.FindObjectsOfType<LevelPoint>(); if (array.Length == 0) { return Vector3.zero; } Transform transform = ((Component)array[Random.Range(0, array.Length)]).transform; return transform.position; } public static Vector3 GetRandomValuablePoint() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 ValuableVolume[] array = Object.FindObjectsOfType<ValuableVolume>(); List<ValuableVolume> list = new List<ValuableVolume>(); ValuableVolume[] array2 = array; foreach (ValuableVolume val in array2) { if (((Behaviour)val).isActiveAndEnabled && ((int)val.VolumeType == 2 || (int)val.VolumeType == 0 || (int)val.VolumeType == 1)) { list.Add(val); } } if (list.Count == 0) { return GetRandomPoint(); } ValuableVolume val2 = list[Random.Range(0, list.Count)]; return ((Component)val2).transform.position; } public static void SpawnEnemy(Vector3 pos, out List<string> enemyName, string enemyObjName = "random", int count = 1) { //IL_00ab: 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_0104: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) enemyName = new List<string>(); if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } LevelGenerator instance = LevelGenerator.Instance; EnemyDirector.instance.enemyFirstSpawnPoints.Clear(); if (!(enemyObjName == "random")) { return; } List<EnemySetup> list = EnemyDirector.instance.enemiesDifficulty3.Where((EnemySetup e) => e.spawnObjects.Count > 0 && ((Object)e.spawnObjects[0].Prefab).name != "Enemy - Gnome" && ((Object)e.spawnObjects[0].Prefab).name != "Enemy - Bang" && ((Object)e.spawnObjects[0].Prefab).name != "Enemy - Ceiling Eye").ToList(); for (int i = 0; i < count; i++) { if (list.Count == 0) { break; } int index = Random.Range(0, list.Count); EnemySetup val = list[index]; Vector3 randomPoint = GetRandomPoint(); foreach (PrefabRef spawnObject in val.spawnObjects) { GameObject val2 = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(spawnObject.ResourcePath, randomPoint, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(spawnObject.Prefab, randomPoint, Quaternion.identity)); EnemyParent component = val2.GetComponent<EnemyParent>(); if (Object.op_Implicit((Object)(object)component)) { component.SetupDone = true; Enemy componentInChildren = val2.GetComponentInChildren<Enemy>(); componentInChildren.EnemyTeleported(randomPoint); instance.EnemiesSpawnTarget++; EnemyDirector.instance.FirstSpawnPointAdd(component); enemyName.Add(component.enemyName); component.actionMultiplier = 0.01f; component.DespawnedTimer = 0f; ((MonoBehaviour)Plugin.instance).StartCoroutine(EnemyTeleportWhenReady(component, componentInChildren, pos)); break; } } } } [IteratorStateMachine(typeof(<EnemyTeleportWhenReady>d__25))] private static IEnumerator EnemyTeleportWhenReady(EnemyParent ep, Enemy enemy, 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnemyTeleportWhenReady>d__25(0) { ep = ep, enemy = enemy, pos = pos }; } public void SpawnEvent(Vector3 pos) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_0031: 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_0104: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(1, 100); if (num >= 50) { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject(((Object)Plugin.instance.landMindPrefeb).name, pos, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(Plugin.instance.landMindPrefeb, pos, Quaternion.identity); } return; } Vector3 randomPoint = GetRandomPoint(); string steamID = openerSteamId; if (string.IsNullOrEmpty(steamID) && Object.op_Implicit((Object)(object)grabber)) { steamID = grabber.steamID; } if (string.IsNullOrEmpty(steamID)) { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if (Object.op_Implicit((Object)(object)val)) { steamID = val.steamID; } } if (!string.IsNullOrEmpty(steamID)) { PlayerAvatar val2 = SemiFunc.PlayerAvatarGetFromSteamID(steamID); if ((Object)(object)val2 != (Object)null && !val2.deadSet) { val2.Spawn(randomPoint, ((Component)val2).transform.rotation); } } } [PunRPC] private void SetOpenerRPC(string steamId, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClient() && !string.IsNullOrEmpty(steamId)) { PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId); if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null && val.photonView.Owner == info.Sender) { openerSteamId = steamId; } } } public static void SpawnMoney(Vector3 position, float maxValue, float minValue) { //IL_006b: 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_004f: 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) ValuableObject component = AssetManager.instance.surplusValuableSmall.GetComponent<ValuableObject>(); Value val = ScriptableObject.CreateInstance<Value>(); val.valueMin = minValue; val.valueMax = maxValue; component.valuePreset = val; if (SemiFunc.IsMultiplayer()) { PhotonNetwork.Instantiate("Valuables/" + ((Object)AssetManager.instance.surplusValuableSmall).name, position, Quaternion.identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(AssetManager.instance.surplusValuableSmall, position, Quaternion.identity); } } public void SpawnItem(Vector3 pos) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (StatsManager.instance.itemDictionary != null && StatsManager.instance.itemDictionary.Count > 0) { List<Item> list = StatsManager.instance.itemDictionary.Values.ToList(); Item val = list[Random.Range(0, list.Count)]; if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)val.prefab.Prefab).name, pos, val.prefab.Prefab.transform.rotation, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(val.prefab.Prefab, pos, val.prefab.Prefab.transform.rotation); } } else { Plugin.logger.LogWarning((object)"itemDictionary 为空或未初始化 / itemDictionary is empty or not initialized"); } } [PunRPC] public void RPCTeleportPlayer(Vector3 pos, string target) { //IL_0078: 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_0063: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(target); if ((Object)(object)val != (Object)null && !val.deadSet) { if (SemiFunc.IsMasterClientOrSingleplayer() || val.isLocal) { Plugin.logger.LogInfo((object)$"传送玩家 {val.playerName} 到位置 {pos} / Teleporting {val.playerName} to {pos}"); } ((MonoBehaviour)this).StartCoroutine(FreezeAndSpawnCoroutine(pos, val)); } } [IteratorStateMachine(typeof(<FreezeAndSpawnCoroutine>d__31))] private IEnumerator FreezeAndSpawnCoroutine(Vector3 position, PlayerAvatar target) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FreezeAndSpawnCoroutine>d__31(0) { <>4__this = this, position = position, target = target }; } private void FreezePlayer(PlayerAvatar target) { //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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) if ((Object)(object)target.tumble == (Object)null) { Debug.LogError((object)"FreezePlayer: 缺少 Tumble 组件 / FreezePlayer: Tumble component is missing"); return; } if (target.tumble.isTumbling) { target.tumble.TumbleRequest(false, false); } if ((Object)(object)target.rb != (Object)null) { frozenVelocity = target.rb.velocity; Vector3 angularVelocity = target.rb.angularVelocity; frozenAngularVelocity = ((Vector3)(ref angularVelocity)).magnitude; target.rb.isKinematic = true; target.rb.velocity = Vector3.zero; target.rb.angularVelocity = Vector3.zero; } isMovementFrozen = true; } private void UnfreezePlayer(PlayerAvatar target) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)target.rb != (Object)null) { target.rb.isKinematic = false; target.rb.velocity = frozenVelocity; target.rb.AddTorque(target.rb.rotation * Vector3.up * frozenAngularVelocity, (ForceMode)2); } isMovementFrozen = false; } } internal class LandMind : MonoBehaviour { private ParticleScriptExplosion particle; private float beepTimer = 0f; private AudioSource audio; private Light beepLight; private void Start() { particle = ((Component)this).gameObject.GetComponent<ParticleScriptExplosion>(); if ((Object)(object)particle == (Object)null) { Debug.LogError((object)"ParticleScriptExplosion 组件缺失! / Missing ParticleScriptExplosion component", (Object)(object)this); return; } beepTimer = Time.time; audio = ((Component)this).gameObject.AddComponent<AudioSource>(); audio.clip = Plugin.instance.mineBeep; audio.spatialBlend = 2f; audio.volume = 1f; if ((Object)(object)audio == (Object)null) { Debug.LogError((object)"AudioSource 组件缺失! / Missing AudioSource component", (Object)(object)this); } else { beepLight = ((Component)this).gameObject.GetComponentInChildren<Light>(); } } private void OnTriggerExit(Collider other) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) particle.Spawn(((Component)this).transform.position, 1.5f, 88, 25, 1f, false, false, 1f); Object.Destroy((Object)(object)((Component)this).gameObject); } private void Update() { if (Time.time - beepTimer >= 3f) { audio.Play(); ((Component)beepLight).gameObject.SetActive(true); beepTimer = Time.time; } if (!audio.isPlaying) { ((Component)beepLight).gameObject.SetActive(false); } } private void OnDestroy() { if ((Object)(object)beepLight != (Object)null) { Object.Destroy((Object)(object)((Component)beepLight).gameObject); } if ((Object)(object)audio != (Object)null) { audio.Stop(); Object.Destroy((Object)(object)audio); } if ((Object)(object)particle != (Object)null) { Object.Destroy((Object)(object)particle); } } } internal class Asaki : MonoBehaviour { private float cdTimer; private PhysGrabObject phys; private float sfxTimer; private void Start() { phys = ((Component)this).GetComponent<PhysGrabObject>(); AudioClip asakiMua = Plugin.instance.asakiMua; } private void Update() { cdTimer += Time.deltaTime; if (!Object.op_Implicit((Object)(object)phys) || phys.playerGrabbing.Count <= 0 || !(cdTimer >= 4f)) { return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { foreach (PhysGrabber item in phys.playerGrabbing) { item.playerAvatar.playerHealth.HealOther(4, true); } } cdTimer = 0f; } }