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 ArenaRaceCosmeticBoxTrap v4.0.0
ArenaRaceCosmeticBoxTrap.dll
Decompiled 11 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("REPOJP")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("zabuMod")] [assembly: AssemblyTitle("zabuMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace REPOJP.ArenaRaceCosmeticBoxTrap { [BepInPlugin("REPOJP.ArenaRaceCosmeticBoxTrap", "ArenaRaceCosmeticBoxTrap", "4.0.0")] public class ArenaRaceCosmeticBoxTrapPlugin : BaseUnityPlugin { public const string PluginGuid = "REPOJP.ArenaRaceCosmeticBoxTrap"; public const string PluginName = "ArenaRaceCosmeticBoxTrap"; public const string PluginVersion = "4.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> OverallSpawnChance; internal static ConfigEntry<float> SmallVolumeSpawnChance; internal static ConfigEntry<float> LargeVolumeSpawnChance; internal static ConfigEntry<int> CommonWeight; internal static ConfigEntry<int> UncommonWeight; internal static ConfigEntry<int> RareWeight; internal static ConfigEntry<int> UltraRareWeight; internal static ConfigEntry<SizeRangeMode> SizeMode; internal static ConfigEntry<float> CommonMinScale; internal static ConfigEntry<float> CommonMaxScale; internal static ConfigEntry<float> UncommonMinScale; internal static ConfigEntry<float> UncommonMaxScale; internal static ConfigEntry<float> RareMinScale; internal static ConfigEntry<float> RareMaxScale; internal static ConfigEntry<float> UltraRareMinScale; internal static ConfigEntry<float> UltraRareMaxScale; internal static ConfigEntry<float> CommonMinScaleCompact; internal static ConfigEntry<float> CommonMaxScaleCompact; internal static ConfigEntry<float> UncommonMinScaleCompact; internal static ConfigEntry<float> UncommonMaxScaleCompact; internal static ConfigEntry<float> RareMinScaleCompact; internal static ConfigEntry<float> RareMaxScaleCompact; internal static ConfigEntry<float> UltraRareMinScaleCompact; internal static ConfigEntry<float> UltraRareMaxScaleCompact; internal static ConfigEntry<float> PositionJitter; internal static ConfigEntry<bool> RandomYaw; internal static ConfigEntry<bool> RandomTilt; internal static ConfigEntry<float> RandomTiltDegrees; internal static ConfigEntry<bool> TriggerPlayers; internal static ConfigEntry<bool> TriggerVehicles; internal static ConfigEntry<float> TouchRadius; internal static ConfigEntry<float> SpawnGraceSeconds; internal static ConfigEntry<bool> RegisterToTrackPieceCleanup; internal static ConfigEntry<bool> DebugLog; private Harmony harmony; private void Awake() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown try { ((Component)this).transform.parent = null; ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Log = ((BaseUnityPlugin)this).Logger; BindConfig(); harmony = new Harmony("REPOJP.ArenaRaceCosmeticBoxTrap"); harmony.PatchAll(); Log.LogInfo((object)"ArenaRaceCosmeticBoxTrap v4.0.0 loaded."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failure: Awake\n" + ex)); } } private void OnDestroy() { try { if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failure: OnDestroy\n" + ex)); } } private void BindConfig() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Expected O, but got Unknown //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Expected O, but got Unknown //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Expected O, but got Unknown //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Expected O, but got Unknown //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Expected O, but got Unknown //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Expected O, but got Unknown //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Expected O, but got Unknown //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Expected O, but got Unknown //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Expected O, but got Unknown //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Expected O, but got Unknown //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod.このMODを有効にする"); OverallSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "OverallSpawnChance", 100f, new ConfigDescription("Overall spawn chance before volume-specific checks.全体の生成確率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); SmallVolumeSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "SmallVolumeSpawnChance", 35f, new ConfigDescription("Spawn chance for Tiny, Small, and Medium volume spawners.Tiny、Small、Mediumの生成確率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); LargeVolumeSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "LargeVolumeSpawnChance", 100f, new ConfigDescription("Spawn chance for Big, Wide, Tall, and VeryTall volume spawners.Big、Wide、Tall、VeryTallの生成確率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); CommonWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Rarity Weight", "CommonWeight", 50, new ConfigDescription("Weighted spawn chance for Common cosmetic boxes.Commonコスメボックスの生成重み", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); UncommonWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Rarity Weight", "UncommonWeight", 30, new ConfigDescription("Weighted spawn chance for Uncommon cosmetic boxes.Uncommonコスメボックスの生成重み", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); RareWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Rarity Weight", "RareWeight", 15, new ConfigDescription("Weighted spawn chance for Rare cosmetic boxes.Rareコスメボックスの生成重み", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); UltraRareWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Rarity Weight", "UltraRareWeight", 5, new ConfigDescription("Weighted spawn chance for Ultra Rare cosmetic boxes.Ultra Rareコスメボックスの生成重み", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); SizeMode = ((BaseUnityPlugin)this).Config.Bind<SizeRangeMode>("Size", "SizeRangeMode", SizeRangeMode.CompactRarity, "Size range mode.サイズ範囲モード"); CommonMinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "CommonMinScale", 1f, new ConfigDescription("Minimum Common scale in Wide mode.WideモードのCommon最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); CommonMaxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "CommonMaxScale", 2f, new ConfigDescription("Maximum Common scale in Wide mode.WideモードのCommon最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UncommonMinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "UncommonMinScale", 1.2f, new ConfigDescription("Minimum Uncommon scale in Wide mode.WideモードのUncommon最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UncommonMaxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "UncommonMaxScale", 2.3f, new ConfigDescription("Maximum Uncommon scale in Wide mode.WideモードのUncommon最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); RareMinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "RareMinScale", 1.5f, new ConfigDescription("Minimum Rare scale in Wide mode.WideモードのRare最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); RareMaxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "RareMaxScale", 2.6f, new ConfigDescription("Maximum Rare scale in Wide mode.WideモードのRare最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UltraRareMinScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "UltraRareMinScale", 2f, new ConfigDescription("Minimum Ultra Rare scale in Wide mode.WideモードのUltra Rare最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UltraRareMaxScale = ((BaseUnityPlugin)this).Config.Bind<float>("Size Wide", "UltraRareMaxScale", 3f, new ConfigDescription("Maximum Ultra Rare scale in Wide mode.WideモードのUltra Rare最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); CommonMinScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "CommonMinScaleCompact", 1f, new ConfigDescription("Minimum Common scale in CompactRarity mode.CompactRarityモードのCommon最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); CommonMaxScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "CommonMaxScaleCompact", 1.5f, new ConfigDescription("Maximum Common scale in CompactRarity mode.CompactRarityモードのCommon最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UncommonMinScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "UncommonMinScaleCompact", 1.3f, new ConfigDescription("Minimum Uncommon scale in CompactRarity mode.CompactRarityモードのUncommon最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UncommonMaxScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "UncommonMaxScaleCompact", 2f, new ConfigDescription("Maximum Uncommon scale in CompactRarity mode.CompactRarityモードのUncommon最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); RareMinScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "RareMinScaleCompact", 1.7f, new ConfigDescription("Minimum Rare scale in CompactRarity mode.CompactRarityモードのRare最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); RareMaxScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "RareMaxScaleCompact", 2.5f, new ConfigDescription("Maximum Rare scale in CompactRarity mode.CompactRarityモードのRare最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UltraRareMinScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "UltraRareMinScaleCompact", 2.2f, new ConfigDescription("Minimum Ultra Rare scale in CompactRarity mode.CompactRarityモードのUltra Rare最小サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); UltraRareMaxScaleCompact = ((BaseUnityPlugin)this).Config.Bind<float>("Size CompactRarity", "UltraRareMaxScaleCompact", 3f, new ConfigDescription("Maximum Ultra Rare scale in CompactRarity mode.CompactRarityモードのUltra Rare最大サイズ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); PositionJitter = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Transform", "PositionJitter", 0.5f, new ConfigDescription("Horizontal random spawn offset.X/Z方向のランダム補正", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); RandomYaw = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn Transform", "RandomYaw", true, "Randomize Y-axis rotation.Y軸回転をランダム化する"); RandomTilt = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn Transform", "RandomTilt", false, "Randomize X/Z-axis tilt.X/Z軸の傾きをランダム化する"); RandomTiltDegrees = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Transform", "RandomTiltDegrees", 10f, new ConfigDescription("Maximum tilt degrees when RandomTilt is enabled.RandomTilt有効時の最大傾き", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 45f), Array.Empty<object>())); TriggerPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosion", "TriggerPlayers", true, "Explode when touched by players.プレイヤー接触で爆発する"); TriggerVehicles = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosion", "TriggerVehicles", true, "Explode when touched by vehicles.車両接触で爆発する"); TouchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "TouchRadius", 0.75f, new ConfigDescription("Host-side overlap detection radius.ホスト側の補助接触判定半径", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); SpawnGraceSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "SpawnGraceSeconds", 0.25f, new ConfigDescription("Delay before the trap can explode after spawning.生成直後の爆発無効時間", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); RegisterToTrackPieceCleanup = ((BaseUnityPlugin)this).Config.Bind<bool>("Advanced", "RegisterToTrackPieceCleanup", true, "Register spawned boxes to the track piece cleanup list.生成した箱をコース部品の破壊対象に登録する"); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Advanced", "DebugLog", false, "Enable debug logs.デバッグログを有効にする"); } internal static void WriteDebug(string message) { if (DebugLog != null && DebugLog.Value && Log != null) { Log.LogInfo((object)message); } } internal static void WriteWarning(string message) { if (Log != null) { Log.LogWarning((object)message); } } internal static void WriteError(string message) { if (Log != null) { Log.LogError((object)message); } } } public enum SizeRangeMode { Wide, CompactRarity } [HarmonyPatch(typeof(ArenaRacePhysGrabObjectSpawner), "Start")] internal static class ArenaRacePhysGrabObjectSpawnerStartPatch { private static readonly FieldInfo SpawnedObjectsField = AccessTools.Field(typeof(ArenaRaceTrackPiece), "spawnedObjects"); private static bool Prefix(ArenaRacePhysGrabObjectSpawner __instance) { //IL_007d: 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_009e: 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) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00fa: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) try { if (ArenaRaceCosmeticBoxTrapPlugin.Enabled == null || !ArenaRaceCosmeticBoxTrapPlugin.Enabled.Value) { return true; } if (!SafeIsMasterClientOrSingleplayer()) { return false; } if (!SafeRunIsArena()) { return true; } if ((Object)(object)__instance == (Object)null || (Object)(object)ArenaRace.instance == (Object)null) { return true; } if (!ShouldSpawn(__instance.volumeType)) { return false; } Rarity val = PickRarity(); PrefabRef cosmeticWorldObjectPrefab = GetCosmeticWorldObjectPrefab(val); if (cosmeticWorldObjectPrefab == null || string.IsNullOrEmpty(cosmeticWorldObjectPrefab.ResourcePath)) { ArenaRaceCosmeticBoxTrapPlugin.WriteWarning("Failure: Cosmetic box prefab not found - " + ((object)(Rarity)(ref val)).ToString()); return true; } Vector3 spawnPosition = GetSpawnPosition(((Component)__instance).transform); Quaternion spawnRotation = GetSpawnRotation(((Component)__instance).transform.rotation); float scale = GetScale(val); GameObject val2 = SpawnCosmeticBox(cosmeticWorldObjectPrefab, spawnPosition, spawnRotation, scale); if (!Object.op_Implicit((Object)(object)val2)) { ArenaRaceCosmeticBoxTrapPlugin.WriteWarning("Failure: Cosmetic box spawn failed - " + ((object)(Rarity)(ref val)).ToString()); return true; } val2.transform.localScale = new Vector3(scale, scale, scale); ArenaRaceCosmeticBoxTrapTrigger arenaRaceCosmeticBoxTrapTrigger = val2.GetComponent<ArenaRaceCosmeticBoxTrapTrigger>(); if (!Object.op_Implicit((Object)(object)arenaRaceCosmeticBoxTrapTrigger)) { arenaRaceCosmeticBoxTrapTrigger = val2.AddComponent<ArenaRaceCosmeticBoxTrapTrigger>(); } arenaRaceCosmeticBoxTrapTrigger.Setup(val, scale); RegisterSpawnedObject(__instance, val2); ArenaRaceCosmeticBoxTrapPlugin.WriteDebug("Spawned cosmetic box trap: " + ((object)(Rarity)(ref val)).ToString() + " scale=" + scale.ToString("0.00") + " volume=" + ((object)(Type)(ref __instance.volumeType)).ToString()); return false; } catch (Exception ex) { ArenaRaceCosmeticBoxTrapPlugin.WriteError("Failure: ArenaRacePhysGrabObjectSpawner.Start Prefix\n" + ex); return true; } } private static bool SafeIsMasterClientOrSingleplayer() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private static bool SafeRunIsArena() { try { if ((Object)(object)RunManager.instance == (Object)null) { return false; } return SemiFunc.RunIsArena(); } catch { return false; } } private static bool ShouldSpawn(Type volumeType) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) float num = ClampPercent(ArenaRaceCosmeticBoxTrapPlugin.OverallSpawnChance.Value); if (Random.value * 100f >= num) { return false; } float num2 = (IsSmallVolume(volumeType) ? ClampPercent(ArenaRaceCosmeticBoxTrapPlugin.SmallVolumeSpawnChance.Value) : ClampPercent(ArenaRaceCosmeticBoxTrapPlugin.LargeVolumeSpawnChance.Value)); return Random.value * 100f < num2; } private static bool IsSmallVolume(Type volumeType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 return (int)volumeType == 0 || (int)volumeType == 1 || (int)volumeType == 2; } private static float ClampPercent(float value) { return Mathf.Clamp(value, 0f, 100f); } private static Rarity PickRarity() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) int num = Mathf.Max(0, ArenaRaceCosmeticBoxTrapPlugin.CommonWeight.Value); int num2 = Mathf.Max(0, ArenaRaceCosmeticBoxTrapPlugin.UncommonWeight.Value); int num3 = Mathf.Max(0, ArenaRaceCosmeticBoxTrapPlugin.RareWeight.Value); int num4 = Mathf.Max(0, ArenaRaceCosmeticBoxTrapPlugin.UltraRareWeight.Value); int num5 = num + num2 + num3 + num4; if (num5 <= 0) { return (Rarity)0; } int num6 = Random.Range(0, num5); if (num6 < num) { return (Rarity)0; } num6 -= num; if (num6 < num2) { return (Rarity)1; } num6 -= num2; if (num6 < num3) { return (Rarity)2; } return (Rarity)3; } private static PrefabRef GetCosmeticWorldObjectPrefab(Rarity rarity) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected I4, but got Unknown //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) if ((Object)(object)ValuableDirector.instance == (Object)null || ValuableDirector.instance.cosmeticWorldObjectSetups == null) { return null; } List<CosmeticWorldObjectSetup> cosmeticWorldObjectSetups = ValuableDirector.instance.cosmeticWorldObjectSetups; for (int i = 0; i < cosmeticWorldObjectSetups.Count; i++) { CosmeticWorldObjectSetup val = cosmeticWorldObjectSetups[i]; if (val != null && val.rarity == rarity && val.prefab != null) { return val.prefab; } } int num = (int)rarity; if (num >= 0 && num < cosmeticWorldObjectSetups.Count && cosmeticWorldObjectSetups[num] != null) { return cosmeticWorldObjectSetups[num].prefab; } return null; } private static Vector3 GetSpawnPosition(Transform spawnerTransform) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0043: 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_0055: 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_005b: 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_0068: 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) //IL_0072: 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) //IL_0074: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Vector3 position = spawnerTransform.position; float num = Mathf.Clamp(ArenaRaceCosmeticBoxTrapPlugin.PositionJitter.Value, 0f, 10f); if (num <= 0f) { return position; } Vector2 val = Random.insideUnitCircle * num; position += spawnerTransform.right * val.x; return position + spawnerTransform.forward * val.y; } private static Quaternion GetSpawnRotation(Quaternion baseRotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Quaternion val = baseRotation; if (ArenaRaceCosmeticBoxTrapPlugin.RandomYaw.Value) { val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * val; } if (ArenaRaceCosmeticBoxTrapPlugin.RandomTilt.Value) { float num = Mathf.Clamp(ArenaRaceCosmeticBoxTrapPlugin.RandomTiltDegrees.Value, 0f, 45f); float num2 = Random.Range(0f - num, num); float num3 = Random.Range(0f - num, num); val = Quaternion.Euler(num2, 0f, num3) * val; } return val; } private static float GetScale(Rarity rarity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) GetScaleRange(rarity, out var minScale, out var maxScale); minScale = Mathf.Clamp(minScale, 0.1f, 10f); maxScale = Mathf.Clamp(maxScale, 0.1f, 10f); if (minScale > maxScale) { float num = minScale; minScale = maxScale; maxScale = num; } return Random.Range(minScale, maxScale); } private static void GetScaleRange(Rarity rarity, out float minScale, out float maxScale) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 if (ArenaRaceCosmeticBoxTrapPlugin.SizeMode.Value == SizeRangeMode.CompactRarity) { if ((int)rarity == 0) { minScale = ArenaRaceCosmeticBoxTrapPlugin.CommonMinScaleCompact.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.CommonMaxScaleCompact.Value; } else if ((int)rarity == 1) { minScale = ArenaRaceCosmeticBoxTrapPlugin.UncommonMinScaleCompact.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.UncommonMaxScaleCompact.Value; } else if ((int)rarity == 2) { minScale = ArenaRaceCosmeticBoxTrapPlugin.RareMinScaleCompact.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.RareMaxScaleCompact.Value; } else { minScale = ArenaRaceCosmeticBoxTrapPlugin.UltraRareMinScaleCompact.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.UltraRareMaxScaleCompact.Value; } } else if ((int)rarity == 0) { minScale = ArenaRaceCosmeticBoxTrapPlugin.CommonMinScale.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.CommonMaxScale.Value; } else if ((int)rarity == 1) { minScale = ArenaRaceCosmeticBoxTrapPlugin.UncommonMinScale.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.UncommonMaxScale.Value; } else if ((int)rarity == 2) { minScale = ArenaRaceCosmeticBoxTrapPlugin.RareMinScale.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.RareMaxScale.Value; } else { minScale = ArenaRaceCosmeticBoxTrapPlugin.UltraRareMinScale.Value; maxScale = ArenaRaceCosmeticBoxTrapPlugin.UltraRareMaxScale.Value; } } private static GameObject SpawnCosmeticBox(PrefabRef prefabRef, Vector3 position, Quaternion rotation, float scale) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { object[] array = new object[3] { scale, scale, scale }; return PhotonNetwork.InstantiateRoomObject(prefabRef.ResourcePath, position, rotation, (byte)0, array); } GameObject prefab = prefabRef.Prefab; if (!Object.op_Implicit((Object)(object)prefab)) { return null; } return Object.Instantiate<GameObject>(prefab, position, rotation); } private static void RegisterSpawnedObject(ArenaRacePhysGrabObjectSpawner spawner, GameObject spawnedObject) { try { if (!ArenaRaceCosmeticBoxTrapPlugin.RegisterToTrackPieceCleanup.Value) { return; } ArenaRaceTrackPiece componentInParent = ((Component)spawner).GetComponentInParent<ArenaRaceTrackPiece>(); if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)spawnedObject) && !(SpawnedObjectsField == null)) { object value = SpawnedObjectsField.GetValue(componentInParent); if (value is List<GameObject> list && !list.Contains(spawnedObject)) { list.Add(spawnedObject); } } } catch (Exception ex) { ArenaRaceCosmeticBoxTrapPlugin.WriteWarning("Failure: Register spawned cosmetic box\n" + ex); } } } public class ArenaRaceCosmeticBoxTrapTrigger : MonoBehaviour { private Rarity rarity; private float scale; private float spawnTime; private bool exploded; private PhysGrabObjectImpactDetector impactDetector; private PhotonView photonView; public void Setup(Rarity setupRarity, float setupScale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) rarity = setupRarity; scale = setupScale; spawnTime = Time.time; exploded = false; impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); photonView = ((Component)this).GetComponent<PhotonView>(); } private void Awake() { spawnTime = Time.time; } private void Start() { if (!Object.op_Implicit((Object)(object)impactDetector)) { impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); } if (!Object.op_Implicit((Object)(object)photonView)) { photonView = ((Component)this).GetComponent<PhotonView>(); } } private void OnCollisionEnter(Collision collision) { if (collision != null && (Object)(object)collision.collider != (Object)null) { TryExplodeFromCollider(collision.collider, "collision enter"); } } private void OnCollisionStay(Collision collision) { if (collision != null && (Object)(object)collision.collider != (Object)null) { TryExplodeFromCollider(collision.collider, "collision stay"); } } private void OnTriggerEnter(Collider other) { TryExplodeFromCollider(other, "trigger enter"); } private void OnTriggerStay(Collider other) { TryExplodeFromCollider(other, "trigger stay"); } private void FixedUpdate() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!exploded && CanExplodeNow()) { float num = Mathf.Clamp(ArenaRaceCosmeticBoxTrapPlugin.TouchRadius.Value, 0.1f, 5f) * Mathf.Max(1f, scale * 0.35f); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, num, -1, (QueryTriggerInteraction)2); for (int i = 0; i < array.Length && !TryExplodeFromCollider(array[i], "overlap"); i++) { } } } private bool TryExplodeFromCollider(Collider other, string reason) { try { if (exploded || (Object)(object)other == (Object)null || !CanExplodeNow()) { return false; } if ((Object)(object)((Component)other).transform == (Object)(object)((Component)this).transform || ((Component)other).transform.IsChildOf(((Component)this).transform)) { return false; } if (!IsValidTouchTarget(other)) { return false; } Explode(reason, ((Object)((Component)other).gameObject).name); return true; } catch (Exception ex) { ArenaRaceCosmeticBoxTrapPlugin.WriteWarning("Failure: TryExplodeFromCollider\n" + ex); return false; } } private bool CanExplodeNow() { if (!SafeIsMasterClientOrSingleplayer()) { return false; } float num = Mathf.Clamp(ArenaRaceCosmeticBoxTrapPlugin.SpawnGraceSeconds.Value, 0f, 5f); if (Time.time - spawnTime < num) { return false; } if (!SafeRunIsArena()) { return false; } return true; } private bool IsValidTouchTarget(Collider other) { if (ArenaRaceCosmeticBoxTrapPlugin.TriggerVehicles.Value) { ItemVehicle componentInParent = ((Component)other).GetComponentInParent<ItemVehicle>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return true; } } if (ArenaRaceCosmeticBoxTrapPlugin.TriggerPlayers.Value) { PlayerAvatar componentInParent2 = ((Component)other).GetComponentInParent<PlayerAvatar>(); if (Object.op_Implicit((Object)(object)componentInParent2)) { return true; } PlayerController componentInParent3 = ((Component)other).GetComponentInParent<PlayerController>(); if (Object.op_Implicit((Object)(object)componentInParent3)) { return true; } PlayerTumble componentInParent4 = ((Component)other).GetComponentInParent<PlayerTumble>(); if (Object.op_Implicit((Object)(object)componentInParent4)) { return true; } } return false; } private void Explode(string reason, string targetName) { if (exploded) { return; } exploded = true; if (!Object.op_Implicit((Object)(object)impactDetector)) { impactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); } if (Object.op_Implicit((Object)(object)impactDetector)) { ArenaRaceCosmeticBoxTrapPlugin.WriteDebug("Exploded cosmetic box trap: " + ((object)(Rarity)(ref rarity)).ToString() + " reason=" + reason + " target=" + targetName); impactDetector.DestroyObject(true); return; } ArenaRaceCosmeticBoxTrapPlugin.WriteWarning("Failure: PhysGrabObjectImpactDetector not found. Destroying object fallback."); if (SemiFunc.IsMultiplayer()) { if (!Object.op_Implicit((Object)(object)photonView)) { photonView = ((Component)this).GetComponent<PhotonView>(); } if (Object.op_Implicit((Object)(object)photonView)) { PhotonNetwork.Destroy(((Component)this).gameObject); return; } } Object.Destroy((Object)(object)((Component)this).gameObject); } private bool SafeIsMasterClientOrSingleplayer() { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return false; } } private bool SafeRunIsArena() { try { if ((Object)(object)RunManager.instance == (Object)null) { return false; } return SemiFunc.RunIsArena(); } catch { return false; } } } }