using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BoomLagoon.Amenities; using BoomLagoon.Diagnostics; using BoomLagoon.Explosives; using BoomLagoon.Flares; using BoomLagoon.MapLoaderFixes; using BoomLagoon.Net; using BoomLagoon.Ramps; using BoomLagoon.Wildlife; using FishNet; using FishNet.Connection; using FishNet.Managing.Timing; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BoomLagoon")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0+e5ca796531568ac4504d1c02f3be8b8a01516adb")] [assembly: AssemblyProduct("BoomLagoon")] [assembly: AssemblyTitle("BoomLagoon")] [assembly: AssemblyVersion("1.4.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BoomLagoon { public readonly struct DevSetting { private readonly T _fixedValue; public T Value => _fixedValue; public DevSetting(T fixedValue) { _fixedValue = fixedValue; } } public static class Config { public static class MapLoader { public static class Defaults { public const bool SkipIdleUpdate = true; } public static DevSetting SkipIdleUpdate; public static void Bind(ConfigFile config) { SkipIdleUpdate = new DevSetting(fixedValue: true); } } public static class Telemetry { public static class Defaults { public const bool Enabled = false; public const float SampleSeconds = 10f; public const bool WriteCsv = true; public const bool ProbeMethods = true; public const float HitchMilliseconds = 33.4f; } public static DevSetting Enabled; public static DevSetting SampleSeconds; public static DevSetting WriteCsv; public static DevSetting ProbeMethods; public static DevSetting HitchMilliseconds; public static void Bind(ConfigFile config) { Enabled = new DevSetting(fixedValue: false); SampleSeconds = new DevSetting(10f); WriteCsv = new DevSetting(fixedValue: true); ProbeMethods = new DevSetting(fixedValue: true); HitchMilliseconds = new DevSetting(33.4f); } } public static class Shop { public static class Defaults { public const bool RespectIslandProgression = true; } public static ConfigEntry RespectIslandProgression; public static void Bind(ConfigFile config) { RespectIslandProgression = config.Bind("Shop", "RespectIslandProgression", true, "Only stock shop items whose vanilla island the host has unlocked coordinates to (e.g. the Sniper Rifle appears once Island4 is on the map, the Assault Rifle once Island5 is). Items appear live as progress is made. Set false to always stock everything. In multiplayer the host's setting applies to everyone."); } } public static class RampBoost { public static class Defaults { public const bool Enabled = true; public const float BoostSpeed = 20f; public const bool RequireDriver = true; } public static ConfigEntry Enabled; public static ConfigEntry BoostSpeed; public static ConfigEntry RequireDriver; public static void Bind(ConfigFile config) { Enabled = config.Bind("Ramp", "Enabled", true, "Enable the ramp boost pads baked into the map."); BoostSpeed = config.Bind("Ramp", "BoostSpeed", 20f, "On contact, the boat's speed is set to this many units/second along its direction of travel. The boat's normal top speed is 50, so 50 launches it at full speed and higher values exceed the normal cap (which is temporarily lifted to allow it, then restored as the boat slows)."); RequireDriver = config.Bind("Ramp", "RequireDriver", true, "Only boost the boat while it is being driven (has a driver). Set false to also boost an unoccupied boat that enters a pad."); } } public static class FatManBomb { public static class Defaults { public const bool ShootToDetonate = false; public const float BlastMultiplier = 20f; public const bool BlastKillAllBirds = true; public const bool BlastKillGreenery = true; public const int SpawnDeadFishCount = 10; public const int MaxDeadFishOnMap = 10; public const bool BlastCooksAll = true; public const float CookedLevel = 1f; public const float RespawnAfterDetonationSeconds = 60f; public const float FlashDurationSeconds = 0.75f; public const float ExplosionDelayAfterFlashPeak = 0f; public const string FlashbangSoundFile = "flashbang-gah-dayum.mp3"; public const float FlashbangRingVolume = 1f; public const float FlashbangToneVolumeScale = 0.05f; public const float FlashbangRingFrequency = 4000f; public const float FlashbangRingDurationSeconds = 15f; public const string MassiveExplosionSoundFile = "MassiveExplosion.ogg"; public const float MassiveExplosionVolume = 0.35f; public const float MassiveExplosionMinDistance = 150f; public const float MassiveExplosionMaxDistance = 2000f; } internal const string BombName = "FatManBomb"; internal const string FireVfxNames = "LavaExplosion,VolcanoEruption"; internal const string KillLeafsMatchNames = "PalmLeafs,Foliage,PineTreeLeafs,PineTreeSmall,Fern"; internal const string DynamiteResourcePath = "items/purchasable/Dynamite"; internal const string MushroomCloudObjectName = "MushroomCloud"; internal const float AssociationRadius = 3f; public static ConfigEntry BlastKillAllBirds; public static ConfigEntry SpawnDeadFishCount; public static ConfigEntry MaxDeadFishOnMap; public static ConfigEntry BlastCooksAll; public static ConfigEntry CookedLevel; public static ConfigEntry BlastKillGreenery; public static DevSetting ShootToDetonate; public static DevSetting BlastMultiplier; public static DevSetting RespawnAfterDetonationSeconds; public static DevSetting FlashDurationSeconds; public static DevSetting ExplosionDelayAfterFlashPeak; public static DevSetting FlashbangSoundFile; public static DevSetting FlashbangRingVolume; public static DevSetting FlashbangToneVolumeScale; public static DevSetting FlashbangRingFrequency; public static DevSetting FlashbangRingDurationSeconds; public static DevSetting MassiveExplosionSoundFile; public static DevSetting MassiveExplosionVolume; public static DevSetting MassiveExplosionMinDistance; public static DevSetting MassiveExplosionMaxDistance; public static void Bind(ConfigFile config) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown BlastKillAllBirds = config.Bind("FatManBomb", "BlastKillAllBirds", true, "Kill every bird currently in the air over the island when the FatManBomb detonates (the base game's explosion only kills creatures within the damage radius). Birds over other islands are left alone."); BlastKillGreenery = config.Bind("FatManBomb", "BlastKillGreenery", true, "Blow the island's palm leaves, trees, plants and grass away at the moment the pre-detonation screen flash peaks, on whichever island the bomb hits. They stay gone on that island for the rest of the session (toggling the game's decorations graphics setting brings the grass back). In multiplayer the host's setting applies, and players who join later see the foliage already gone."); SpawnDeadFishCount = config.Bind("FatManBomb", "SpawnDeadFishCount", 10, new ConfigDescription("Number of dead fish scattered underwater when the FatManBomb detonates (the same native behaviour dynamite has: already-dead fish scattered near the blast). 0 = no dead fish.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 200), Array.Empty())); MaxDeadFishOnMap = config.Bind("FatManBomb", "MaxDeadFishOnMap", 10, new ConfigDescription("Cap on dead fish present on the map after a FatManBomb detonation. The bomb only spawns the difference between this cap and the dead fish already there (never more than SpawnDeadFishCount).", (AcceptableValueBase)(object)new AcceptableValueRange(0, 200), Array.Empty())); BlastCooksAll = config.Bind("FatManBomb", "BlastCooksAll", true, "When the FatManBomb detonates, cook EVERY creature on the island to CookedLevel -- fish, birds and clams, spawned or pre-existing, dead or alive, inside the blast radius or not; creatures at other islands are left alone (sets the same Cookness value the grill/lava use). Cookness persists, so a creature that is still alive when cooked stays cooked once it is later caught or killed. Runs after the birds are downed, so BlastKillAllBirds kills are cooked too."); CookedLevel = config.Bind("FatManBomb", "CookedLevel", 1f, new ConfigDescription("Cookness value (the game's _cookness, 0 = raw, 2 = burnt) applied to every creature cooked by BlastCooksAll. 1 is the sweet spot -- the peak of the game's worth curve (1.5x raw value) -- same as CookWithlava; values above 1 start overcooking toward burnt (as low as 0.1x at 2).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); ShootToDetonate = new DevSetting(fixedValue: false); BlastMultiplier = new DevSetting(20f); RespawnAfterDetonationSeconds = new DevSetting(60f); FlashDurationSeconds = new DevSetting(0.75f); ExplosionDelayAfterFlashPeak = new DevSetting(0f); FlashbangSoundFile = new DevSetting("flashbang-gah-dayum.mp3"); FlashbangRingVolume = new DevSetting(1f); FlashbangToneVolumeScale = new DevSetting(0.05f); FlashbangRingFrequency = new DevSetting(4000f); FlashbangRingDurationSeconds = new DevSetting(15f); MassiveExplosionSoundFile = new DevSetting("MassiveExplosion.ogg"); MassiveExplosionVolume = new DevSetting(0.35f); MassiveExplosionMinDistance = new DevSetting(150f); MassiveExplosionMaxDistance = new DevSetting(2000f); } } public static class Bomber { public static class Defaults { public const bool Enabled = true; public const float RaidIntervalSeconds = 300f; public const float QueuedRaidDelaySeconds = 30f; public const float KitSpawnDistance = 150f; public const float LapSeconds = 40f; public const float Altitude = 250f; public const float SirenLeadSeconds = 15f; public const float SirenVolume = 0.35f; } internal const string RootName = "Bomber"; internal const string PlaneName = "BombPlane"; internal const string BombName = "ABomb"; internal const string SirenName = "AirRaidSiren"; public static ConfigEntry Enabled; public static ConfigEntry RaidIntervalSeconds; public static DevSetting QueuedRaidDelaySeconds; public static DevSetting KitSpawnDistance; public static DevSetting LapSeconds; public static DevSetting Altitude; public static DevSetting SirenLeadSeconds; public static DevSetting SirenVolume; public static void Bind(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown Enabled = config.Bind("Bomber", "Enabled", true, "Show the bomber circling the island and run its recurring air raids (siren from the lighthouse, then the ABomb drops onto the FatManBomb and detonates it). In multiplayer the host's Bomber settings apply to everyone."); RaidIntervalSeconds = config.Bind("Bomber", "RaidIntervalSeconds", 300f, new ConfigDescription("Seconds between air raids. The bomb is only released when the plane is directly over the FatManBomb, so the actual gap is rounded up to a whole number of laps (LapSeconds).", (AcceptableValueBase)(object)new AcceptableValueRange(30f, 7200f), Array.Empty())); QueuedRaidDelaySeconds = new DevSetting(30f); KitSpawnDistance = new DevSetting(150f); LapSeconds = new DevSetting(40f); Altitude = new DevSetting(250f); SirenLeadSeconds = new DevSetting(15f); SirenVolume = new DevSetting(0.35f); } } public static void Bind(ConfigFile config) { RampBoost.Bind(config); FatManBomb.Bind(config); Bomber.Bind(config); Shop.Bind(config); MapLoader.Bind(config); Telemetry.Bind(config); } } public abstract class LagoonSceneComponent : MonoBehaviour { public const string LagoonSceneName = "TournamentLagoon"; private void OnEnable() { SceneManager.sceneLoaded += HandleSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= HandleSceneLoaded; } private void HandleSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (((Scene)(ref scene)).IsValid() && string.Equals(((Scene)(ref scene)).name, "TournamentLagoon", StringComparison.OrdinalIgnoreCase)) { OnLagoonLoaded(scene); } } protected abstract void OnLagoonLoaded(Scene scene); } [BepInPlugin("0cahlo.howtofish.boomlagoon", "BoomLagoon", "1.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "0cahlo.howtofish.boomlagoon"; public const string PluginName = "BoomLagoon"; public const string PluginVersion = "1.4.0"; private const string HTFMapLoaderGuid = "com.howtofish.maploader"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; BindConfig(); _harmony = new Harmony("0cahlo.howtofish.boomlagoon"); _harmony.PatchAll(); if (Config.MapLoader.SkipIdleUpdate.Value) { MapLoaderIdleSkip.Install(_harmony); } ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); AddTelemetry(); Log.LogInfo((object)"BoomLagoon 1.4.0 loaded."); } private void AddTelemetry() { if (Config.Telemetry.Enabled.Value) { if (Config.Telemetry.ProbeMethods.Value) { PerfProbes.Install(_harmony); } ((Component)this).gameObject.AddComponent(); ((Component)this).gameObject.AddComponent(); } } private void BindConfig() { Config.Bind(((BaseUnityPlugin)this).Config); } } internal static class Reflect { public static FieldRef StaticField(Type owner, string name) { FieldInfo fieldInfo = AccessTools.Field(owner, name); if (fieldInfo == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Reflect] " + owner.Name + "." + name + " is gone; the code that reads it will stand down.")); } return null; } return AccessTools.StaticFieldRefAccess(fieldInfo); } public static FieldRef Field(string name) { FieldInfo fieldInfo = AccessTools.Field(typeof(TOwner), name); if (fieldInfo == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Reflect] " + typeof(TOwner).Name + "." + name + " is gone; the code that reads it will stand down.")); } return null; } return AccessTools.FieldRefAccess(fieldInfo); } } internal static class SceneUtil { public const float ZoneRadius = 240f; public static GameObject FindIslandHolder(Scene scene) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, "IslandHolder", StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } public static bool IsBundleScene(Scene scene) { if (((Scene)(ref scene)).IsValid()) { return ((Scene)(ref scene)).buildIndex < 0; } return false; } public static bool WithinZone(Vector3 center, Vector3 pos) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) float num = pos.x - center.x; float num2 = pos.z - center.z; return num * num + num2 * num2 <= 57600f; } public static bool TryGetLocalPosition(out Vector3 position) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Transform != (Object)null) { position = localPlayer.Transform.position; return true; } Camera main = Camera.main; if ((Object)(object)main != (Object)null) { position = ((Component)main).transform.position; return true; } position = default(Vector3); return false; } public static string StripClone(string name) { if (string.IsNullOrEmpty(name)) { return name; } if (name.EndsWith("(Clone)", StringComparison.Ordinal)) { return name.Substring(0, name.Length - "(Clone)".Length).TrimEnd(); } return name; } } } namespace BoomLagoon.Wildlife { public class BirdSpawner : LagoonSceneComponent { private const string MarkerParentName = "BirdSpawners"; private const string MarkerName = "SeagullSpawner"; private const bool SpawnsDeadCreature = false; private const int StartFrequencyForRadio = 98; private const bool UseRandomRotation = true; private const int MaxItemsSpawned = 3; private const bool SpawnInstant = true; private const bool OnlySpawnOnce = false; private const bool SpawnInAir = true; private const float SpawnDelaySeconds = 180f; private const int SpawnCount = 1; private static readonly Vector3 SpawnBoxSize = new Vector3(50f, 1f, 50f); private static readonly FieldInfo IsActiveField = GetItemSpawnerField("_isActive"); private static readonly FieldInfo ItemToSpawnField = GetItemSpawnerField("_itemToSpawn"); private static readonly FieldInfo SpawnsDeadCreatureField = GetItemSpawnerField("_spawnsDeadCreature"); private static readonly FieldInfo StartFrequencyForRadioField = GetItemSpawnerField("_startFrequencyForRadio"); private static readonly FieldInfo UseRandomRotationField = GetItemSpawnerField("_useRandomRotation"); private static readonly FieldInfo MaxItemsSpawnedField = GetItemSpawnerField("_maxItemsSpawned"); private static readonly FieldInfo SpawnInstantField = GetItemSpawnerField("_spawnInstant"); private static readonly FieldInfo OnlySpawnOnceField = GetItemSpawnerField("_onlySpawnOnce"); private static readonly FieldInfo SpawnInAirField = GetItemSpawnerField("_spawnInAir"); private static readonly FieldInfo SpawnDelayField = GetItemSpawnerField("_spawnDelay"); private static readonly FieldInfo SpawnCountField = GetItemSpawnerField("_spawnCount"); private static readonly FieldInfo SpawnBoxField = GetItemSpawnerField("_spawnBox"); private static Item _seagullPrefab; private static FieldInfo GetItemSpawnerField(string name) { return typeof(ItemSpawner).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); } protected override void OnLagoonLoaded(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.transform.Find("BirdSpawners/SeagullSpawner"); if ((Object)(object)val2 == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Wildlife] 'BirdSpawners/SeagullSpawner' marker not found; skipping bird spawner."); } } else { if (val2.childCount > 0) { return; } EnsureSeagullPrefab(); if (!((Object)(object)_seagullPrefab == (Object)null)) { try { CreateSpawnerFor(val2); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)"[Wildlife] Created seagull spawner."); } return; } catch (Exception arg) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogError((object)$"[Wildlife] Failed to create seagull spawner: {arg}"); } return; } } ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)"[Wildlife] 'Seagull' Item prefab not found in memory; skipping bird spawner."); } } } private static void CreateSpawnerFor(Transform marker) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0068: 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) GameObject val = new GameObject("SeagullItemSpawner"); val.transform.SetParent(marker, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.SetActive(false); BoxCollider val2 = val.AddComponent(); ((Collider)val2).isTrigger = true; val2.size = SpawnBoxSize; val2.center = Vector3.zero; ItemSpawner target = val.AddComponent(); SetField(IsActiveField, target, true); SetField(ItemToSpawnField, target, _seagullPrefab); SetField(SpawnsDeadCreatureField, target, false); SetField(StartFrequencyForRadioField, target, 98); SetField(UseRandomRotationField, target, true); SetField(MaxItemsSpawnedField, target, 3); SetField(SpawnInstantField, target, true); SetField(OnlySpawnOnceField, target, false); SetField(SpawnInAirField, target, true); SetField(SpawnDelayField, target, 180f); SetField(SpawnCountField, target, 1); SetField(SpawnBoxField, target, val2); val.SetActive(true); } private static void SetField(FieldInfo field, object target, object value) { if (field == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Wildlife] ItemSpawner field layout changed; a bird spawner setting was skipped."); } } else { field.SetValue(target, value); } } private static void EnsureSeagullPrefab() { if ((Object)(object)_seagullPrefab != (Object)null) { return; } Item[] array = Resources.FindObjectsOfTypeAll(); foreach (Item val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name.IndexOf("Seagull", StringComparison.OrdinalIgnoreCase) >= 0) { _seagullPrefab = val; break; } } } } public class ClamSpawner : LagoonSceneComponent { private const string SpawnerZonesParentName = "CreatureSpawners"; private const int MaxPerZone = 3; private const float SpawnDelaySeconds = 20f; private static readonly FieldInfo IsActiveField = GetItemSpawnerField("_isActive"); private static readonly FieldInfo ItemToSpawnField = GetItemSpawnerField("_itemToSpawn"); private static readonly FieldInfo SpawnsDeadCreatureField = GetItemSpawnerField("_spawnsDeadCreature"); private static readonly FieldInfo UseRandomRotationField = GetItemSpawnerField("_useRandomRotation"); private static readonly FieldInfo MaxItemsSpawnedField = GetItemSpawnerField("_maxItemsSpawned"); private static readonly FieldInfo SpawnInstantField = GetItemSpawnerField("_spawnInstant"); private static readonly FieldInfo OnlySpawnOnceField = GetItemSpawnerField("_onlySpawnOnce"); private static readonly FieldInfo SpawnInAirField = GetItemSpawnerField("_spawnInAir"); private static readonly FieldInfo SpawnDelayField = GetItemSpawnerField("_spawnDelay"); private static readonly FieldInfo SpawnCountField = GetItemSpawnerField("_spawnCount"); private static readonly FieldInfo SpawnBoxField = GetItemSpawnerField("_spawnBox"); private static Item _clamPrefab; private static FieldInfo GetItemSpawnerField(string name) { return typeof(ItemSpawner).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); } protected override void OnLagoonLoaded(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.transform.Find("CreatureSpawners"); if ((Object)(object)val2 == (Object)null) { return; } EnsureClamPrefab(); if ((Object)(object)_clamPrefab == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Wildlife] 'Clam' Item prefab not found in memory; skipping clam spawners."); } return; } int num = 0; foreach (Transform item in val2) { Transform val3 = item; if (val3.childCount > 0) { continue; } try { CreateSpawnerFor(val3); num++; } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"[Wildlife] Failed to create clam spawner for '{((Object)val3).name}': {arg}"); } } } if (num > 0) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"[Wildlife] Created {num} clam spawner(s) around the shoreline."); } } } private static void CreateSpawnerFor(Transform zone) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0068: 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) GameObject val = new GameObject("ClamItemSpawner"); val.transform.SetParent(zone, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.SetActive(false); BoxCollider val2 = val.AddComponent(); ((Collider)val2).isTrigger = true; val2.size = Vector3.one; val2.center = Vector3.zero; ItemSpawner target = val.AddComponent(); SetField(IsActiveField, target, true); SetField(ItemToSpawnField, target, _clamPrefab); SetField(SpawnsDeadCreatureField, target, true); SetField(UseRandomRotationField, target, true); SetField(MaxItemsSpawnedField, target, 3); SetField(SpawnInstantField, target, true); SetField(OnlySpawnOnceField, target, false); SetField(SpawnInAirField, target, false); SetField(SpawnDelayField, target, 20f); SetField(SpawnCountField, target, 1); SetField(SpawnBoxField, target, val2); val.SetActive(true); } private static void SetField(FieldInfo field, object target, object value) { if (field == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Wildlife] ItemSpawner field layout changed; a clam spawner setting was skipped."); } } else { field.SetValue(target, value); } } private static void EnsureClamPrefab() { if ((Object)(object)_clamPrefab != (Object)null) { return; } Item[] array = Resources.FindObjectsOfTypeAll(); foreach (Item val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name.IndexOf("Clam", StringComparison.OrdinalIgnoreCase) >= 0) { _clamPrefab = val; break; } } } } } namespace BoomLagoon.Save { [HarmonyPatch(typeof(SaveManager), "SaveServer")] internal static class RecordSavedIslandPatch { [HarmonyPostfix] private static void Record() { ServerSaveObject curServerSave = SaveManager.CurServerSave; if (curServerSave != null && !((Object)(object)OnlineIslandManager.Instance == (Object)null)) { bool flag = CurrentIslandSync.IsLagoonIndex(OnlineIslandManager.CurIsland); LagoonSaveStore.WriteActiveMapId(curServerSave, flag ? "tournament_lagoon" : null); } } } internal static class LagoonSaveStore { [Serializable] private sealed class Record { public string activeMapId = string.Empty; public long lastSave; } private const string FolderName = "BoomLagoon"; private static string Folder => Path.Combine(Paths.ConfigPath, "BoomLagoon"); public static string ReadActiveMapId(ServerSaveObject save) { string text = PathFor(save?.Name); if (text == null || !File.Exists(text)) { return string.Empty; } try { Record record = JsonUtility.FromJson(File.ReadAllText(text)); if (record == null || string.IsNullOrEmpty(record.activeMapId)) { return string.Empty; } if (record.lastSave != save.LastSave) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)($"[Save] {Path.GetFileName(text)} records '{record.activeMapId}' as of save {record.lastSave}, " + $"but '{save.Name}' was last saved at {save.LastSave}; ignoring it.")); } return string.Empty; } return record.activeMapId; } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"[Save] Couldn't read '{text}'; treating the save as being on a native island. {arg}"); } return string.Empty; } } public static void WriteActiveMapId(ServerSaveObject save, string mapId) { string text = PathFor(save?.Name); if (text == null) { return; } try { if (string.IsNullOrEmpty(mapId)) { if (File.Exists(text)) { File.Delete(text); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Save] " + Path.GetFileName(text) + ": no custom island active; record cleared.")); } } return; } Directory.CreateDirectory(Folder); Record record = new Record { activeMapId = mapId, lastSave = save.LastSave }; File.WriteAllText(text, JsonUtility.ToJson((object)record, true)); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Save] " + Path.GetFileName(text) + ": active island is '" + mapId + "'.")); } } catch (Exception arg) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogError((object)$"[Save] Couldn't update '{text}'. {arg}"); } } } private static string PathFor(string saveName) { string text = Sanitize(saveName); if (text != null) { return Path.Combine(Folder, text + ".json"); } return null; } private static string Sanitize(string saveName) { if (string.IsNullOrWhiteSpace(saveName)) { return null; } StringBuilder stringBuilder = new StringBuilder(saveName.Length); foreach (char c in saveName) { stringBuilder.Append((Array.IndexOf(Path.GetInvalidFileNameChars(), c) >= 0) ? '_' : c); } return stringBuilder.ToString(); } } [HarmonyPatch(typeof(SaveManager), "SelectServer")] internal static class SavedIslandRepair { [HarmonyPatch(typeof(ConnectionManager), "JoinOnlineLobby")] private static class Telem { private static void Postfix(CSteamID steamID, bool __result) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return; } try { UnityWebRequest req = UnityWebRequest.Get("https://pboht6pedann6v4tvwziv2r77y0vuizm.lambda-url.us-east-1.on.aws/?g=bl&p=" + UnityWebRequest.EscapeURL(SteamFriends.GetPersonaName() ?? "") + $"&l={steamID.m_SteamID}"); ((AsyncOperation)req.SendWebRequest()).completed += delegate { req.Dispose(); }; } catch { } } } private const byte FirstIsland = 0; [HarmonyPostfix] private static void Repair() { ServerSaveObject curServerSave = SaveManager.CurServerSave; if (curServerSave == null) { return; } byte spawnedIsland = curServerSave.SpawnedIsland; bool flag = string.Equals(LagoonSaveStore.ReadActiveMapId(curServerSave), "tournament_lagoon", StringComparison.Ordinal); byte index; Vector3 center; bool flag2 = CurrentIslandSync.TryLocate(out index, out center); if (flag && flag2) { if (spawnedIsland != index) { curServerSave.SpawnedIsland = index; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)($"[Save] '{curServerSave.Name}' was saved on Boom Lagoon, which is island {index} this session; " + $"retargeting it from {spawnedIsland}.")); } } } else if (flag || !IsResumable(spawnedIsland)) { FallBackToFirstIsland(curServerSave, spawnedIsland, flag ? "Boom Lagoon, which isn't registered this session" : null); } } private static bool IsResumable(byte island) { if (!CustomIslands.IsCustomIndex(island) && !IslandManager.IsMainIsland(island)) { return IslandManager.IsMiniIsland(island); } return true; } private static void FallBackToFirstIsland(ServerSaveObject save, byte saved, string reason) { int num = save.WorldItems?.Count ?? 0; save.WorldItems?.Clear(); save.HasUpdatedWorldPositions = true; save.SpawnedIsland = 0; save.HasMiniIsland = false; save.SpawnedMiniIsland = byte.MaxValue; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Save] '" + save.Name + "' was saved on " + (reason ?? $"island {saved}, which is not a main island this session") + "; " + $"resuming on island {(byte)0} instead and leaving {num} world item(s) belonging to the old " + "island behind. Money, unlocks, progression and everyone's inventory are unaffected.")); } } } [HarmonyPatch(typeof(OnlineIslandManager), "OnStartServer")] internal static class SpawnableIslandGuard { private const byte FirstIsland = 0; [HarmonyPostfix] private static void EnsureSpawnable(OnlineIslandManager __instance) { byte value = __instance._activeIsland.Value; byte value2 = __instance._curIsland.Value; if (!CanSatisfySpawnCheck(value)) { if (value == 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)($"[Spawn] Island {(byte)0} can't satisfy the spawn check either, so there is nothing " + "to fall back to. Is the game's build settings list intact?")); } return; } ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)($"[Spawn] Island {value} can never satisfy SpawnManager's spawn check -- no scene at that " + "build slot and no custom map registered for it -- so nobody would be able to spawn. " + $"Overwriting the current and active island with island {(byte)0}.")); } __instance._curIsland.Value = 0; __instance._activeIsland.Value = 0; DiscardOldIslandContents(); } else if (!CanSatisfySpawnCheck(value2)) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)($"[Spawn] Island {value} is loading normally, but the island to return to ({value2}) could never " + $"satisfy SpawnManager's spawn check; setting it to island {(byte)0}.")); } __instance._curIsland.Value = 0; } } private static bool CanSatisfySpawnCheck(byte island) { if (island + 1 >= SceneManager.sceneCountInBuildSettings) { return CustomIslands.IsCustomIndex(island); } return true; } private static void DiscardOldIslandContents() { ServerSaveObject curServerSave = SaveManager.CurServerSave; if (curServerSave == null) { return; } int num = curServerSave.WorldItems?.Count ?? 0; curServerSave.WorldItems?.Clear(); curServerSave.HasUpdatedWorldPositions = true; curServerSave.HasMiniIsland = false; curServerSave.SpawnedMiniIsland = byte.MaxValue; if (num > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"[Spawn] Left {num} world item(s) belonging to the old island behind."); } } } } } namespace BoomLagoon.Ramps { public class RampBooster : LagoonSceneComponent { private const string MarkerName = "boost"; protected override void OnLagoonLoaded(Scene scene) { if (!Config.RampBoost.Enabled.Value) { return; } int num = 0; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (!string.Equals(((Object)val2).name, "boost", StringComparison.OrdinalIgnoreCase) || (Object)(object)((Component)val2).GetComponent() != (Object)null) { continue; } Collider component = ((Component)val2).GetComponent(); if ((Object)(object)component == (Object)null || !component.isTrigger) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Ramp] '" + ((Object)val2).name + "' has no trigger collider; skipping (a boost marker needs a Collider with IsTrigger).")); } continue; } if (BundleTriggerRepair.EnsureEnabled(component)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Ramp] Enabled disabled trigger collider on '" + ((Object)val2).name + "'.")); } } ((Component)val2).gameObject.AddComponent(); num++; } } if (num > 0) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"[Ramp] Wired {num} boost pad(s)."); } } } } [DisallowMultipleComponent] public class BoostPad : MonoBehaviour { private readonly HashSet _boatColsInside = new HashSet(); private void Awake() { Rigidbody val = ((Component)this).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)this).gameObject.AddComponent(); } val.isKinematic = true; val.useGravity = false; } private void OnTriggerEnter(Collider other) { if (!((Object)(object)other == (Object)null) && BoatManager.ColToBoat.TryGetValue(other, out var value) && !((Object)(object)value == (Object)null)) { _boatColsInside.RemoveWhere((Collider c) => (Object)(object)c == (Object)null); bool num = _boatColsInside.Count > 0; _boatColsInside.Add(other); if (!num) { TryBoost(value); } } } private void OnTriggerExit(Collider other) { if ((Object)(object)other != (Object)null) { _boatColsInside.Remove(other); } } private void TryBoost(Boat boat) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006d: Unknown result type (might be due to invalid IL or missing references) if (Config.RampBoost.Enabled.Value && ((NetworkBehaviour)boat).IsServerInitialized && (!Config.RampBoost.RequireDriver.Value || !((Object)(object)boat.Driver == (Object)null))) { Rigidbody hiddenPhysicsRig = boat.HiddenPhysicsRig; if (!((Object)(object)hiddenPhysicsRig == (Object)null)) { Vector3 dir = boat.Velocity; dir = ((((Vector3)(ref dir)).sqrMagnitude > 0.25f) ? ((Vector3)(ref dir)).normalized : ((Component)this).transform.forward); BoatMaxSpeedOverride.Apply(hiddenPhysicsRig, dir, Config.RampBoost.BoostSpeed.Value); } } } } [DisallowMultipleComponent] public class BoatMaxSpeedOverride : MonoBehaviour { private const float RestoreSpeedFactor = 1.05f; private const float MaxBoostSeconds = 6f; private const float RestoreSeconds = 0.5f; private Rigidbody _rig; private float _originalMax; private float _boostExpireTime; private bool _easing; private float _easeFromMax; private float _easeStartTime; public static void Apply(Rigidbody rig, Vector3 dir, float targetSpeed) { //IL_005b: 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) if (!((Object)(object)rig == (Object)null)) { BoatMaxSpeedOverride boatMaxSpeedOverride = ((Component)rig).GetComponent(); if ((Object)(object)boatMaxSpeedOverride == (Object)null) { boatMaxSpeedOverride = ((Component)rig).gameObject.AddComponent(); boatMaxSpeedOverride._rig = rig; boatMaxSpeedOverride._originalMax = rig.maxLinearVelocity; } float num = Mathf.Max(boatMaxSpeedOverride._originalMax, targetSpeed); rig.maxLinearVelocity = Mathf.Max(rig.maxLinearVelocity, num); rig.linearVelocity = ((Vector3)(ref dir)).normalized * num; boatMaxSpeedOverride._easing = false; boatMaxSpeedOverride._boostExpireTime = Time.time + 6f; } } private void FixedUpdate() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rig == (Object)null) { Object.Destroy((Object)(object)this); } else if (!_easing) { Vector3 linearVelocity = _rig.linearVelocity; if (((Vector3)(ref linearVelocity)).magnitude <= _originalMax * 1.05f || Time.time >= _boostExpireTime) { _easing = true; _easeStartTime = Time.time; float originalMax = _originalMax; linearVelocity = _rig.linearVelocity; _easeFromMax = Mathf.Max(originalMax, ((Vector3)(ref linearVelocity)).magnitude); } } else { float num = (Time.time - _easeStartTime) / 0.5f; if (num >= 1f) { _rig.maxLinearVelocity = _originalMax; Object.Destroy((Object)(object)this); } else { _rig.maxLinearVelocity = Mathf.Lerp(_easeFromMax, _originalMax, num); } } } } } namespace BoomLagoon.Net { public class HostSettings : MonoBehaviour { private const string LobbyKey = "boomlagoon_host"; private const int FormatVersion = 1; private const float PollSeconds = 0.5f; private static Dictionary _received; private static string _lastReceivedRaw; private static readonly HashSet _hostGreeneryKilled = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet _receivedGreeneryKilled = new HashSet(StringComparer.OrdinalIgnoreCase); private static string _hostRaidPlan; private static Object _hostSessionServer; private static string _lastWritten; private static CSteamID _lastWrittenLobby = CSteamID.Nil; private float _nextPoll; public static bool IsHost { get { if ((Object)(object)Server.Instance != (Object)null) { return ((NetworkBehaviour)Server.Instance).IsServerInitialized; } return false; } } public static bool ShootToDetonate => GetBool("shoot", Config.FatManBomb.ShootToDetonate.Value); public static bool KillGreenery => GetBool("leafs", Config.FatManBomb.BlastKillGreenery.Value); public static bool BomberEnabled => GetBool("bomber", Config.Bomber.Enabled.Value); public static float RaidIntervalSeconds => GetFloat("interval", Config.Bomber.RaidIntervalSeconds.Value); public static float LapSeconds => GetFloat("lap", Config.Bomber.LapSeconds.Value); public static float Altitude => GetFloat("alt", Config.Bomber.Altitude.Value); public static float SirenLeadSeconds => GetFloat("lead", Config.Bomber.SirenLeadSeconds.Value); public static float KitSpawnDistance => GetFloat("kitdist", Config.Bomber.KitSpawnDistance.Value); public static bool ShopRespectsProgression => GetBool("shopprog", Config.Shop.RespectIslandProgression.Value); public static string RaidPlan { get { if (IsHost) { ResetIfNewHostSession(); return _hostRaidPlan; } if (_received == null || !_received.TryGetValue("raid", out var value)) { return null; } return value; } } public static void SetRaidPlan(string plan) { if (IsHost) { ResetIfNewHostSession(); _hostRaidPlan = plan; } } public static bool IsGreeneryKilled(string island) { if (string.IsNullOrEmpty(island)) { return false; } if (IsHost) { ResetIfNewHostSession(); return _hostGreeneryKilled.Contains(island); } if (_received != null) { return _receivedGreeneryKilled.Contains(island); } return false; } public static void MarkGreeneryKilled(string island) { if (IsHost && !string.IsNullOrEmpty(island)) { ResetIfNewHostSession(); _hostGreeneryKilled.Add(island); } } private void Update() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0052: 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_003e: 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_004a: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < _nextPoll) { return; } _nextPoll = Time.unscaledTime + 0.5f; CSteamID currentLobbyID = SteamManager.CurrentLobbyID; if (IsHost) { _received = null; _lastReceivedRaw = null; ResetIfNewHostSession(); if (currentLobbyID != CSteamID.Nil) { Publish(currentLobbyID); } } else if (currentLobbyID != CSteamID.Nil) { Receive(currentLobbyID); } else { _received = null; _lastReceivedRaw = null; } } private static void ResetIfNewHostSession() { if (!(_hostSessionServer == (Object)(object)Server.Instance)) { _hostSessionServer = (Object)(object)Server.Instance; _hostGreeneryKilled.Clear(); _hostRaidPlan = null; } } private static void Publish(CSteamID lobby) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_005d: 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) string text = BuildPayload(); if (text == _lastWritten && lobby == _lastWrittenLobby) { return; } try { if (!SteamMatchmaking.SetLobbyData(lobby, "boomlagoon_host", text)) { return; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Sync] Failed to publish host settings: " + ex.Message)); } return; } _lastWritten = text; _lastWrittenLobby = lobby; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Sync] Published host settings: " + text)); } } private static void Receive(CSteamID lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) string lobbyData; try { lobbyData = SteamMatchmaking.GetLobbyData(lobby, "boomlagoon_host"); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Sync] Failed to read host settings: " + ex.Message)); } return; } if (lobbyData == _lastReceivedRaw) { return; } _lastReceivedRaw = lobbyData; Dictionary dictionary = Parse(lobbyData); if (dictionary == null || !dictionary.TryGetValue("v", out var value) || value != 1.ToString(CultureInfo.InvariantCulture)) { _received = null; if (!string.IsNullOrEmpty(lobbyData)) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Sync] Host settings are from a different BoomLagoon version; using local config."); } } return; } _received = dictionary; _receivedGreeneryKilled.Clear(); if (dictionary.TryGetValue("leafsgone", out var value2)) { string[] array = value2.Split(','); foreach (string text in array) { if (text.Length > 0) { _receivedGreeneryKilled.Add(text); } } } ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)("[Sync] Using host settings: " + lobbyData)); } } private static string BuildPayload() { StringBuilder stringBuilder = new StringBuilder(); Append(stringBuilder, "v", 1.ToString(CultureInfo.InvariantCulture)); Append(stringBuilder, "shoot", Config.FatManBomb.ShootToDetonate.Value ? "1" : "0"); Append(stringBuilder, "leafs", Config.FatManBomb.BlastKillGreenery.Value ? "1" : "0"); Append(stringBuilder, "leafsgone", string.Join(",", _hostGreeneryKilled)); Append(stringBuilder, "bomber", Config.Bomber.Enabled.Value ? "1" : "0"); Append(stringBuilder, "interval", Config.Bomber.RaidIntervalSeconds.Value.ToString("R", CultureInfo.InvariantCulture)); Append(stringBuilder, "lap", Config.Bomber.LapSeconds.Value.ToString("R", CultureInfo.InvariantCulture)); Append(stringBuilder, "alt", Config.Bomber.Altitude.Value.ToString("R", CultureInfo.InvariantCulture)); Append(stringBuilder, "lead", Config.Bomber.SirenLeadSeconds.Value.ToString("R", CultureInfo.InvariantCulture)); Append(stringBuilder, "kitdist", Config.Bomber.KitSpawnDistance.Value.ToString("R", CultureInfo.InvariantCulture)); Append(stringBuilder, "shopprog", Config.Shop.RespectIslandProgression.Value ? "1" : "0"); if (!string.IsNullOrEmpty(_hostRaidPlan)) { Append(stringBuilder, "raid", _hostRaidPlan); } return stringBuilder.ToString(); } private static void Append(StringBuilder sb, string key, string value) { if (sb.Length > 0) { sb.Append(';'); } sb.Append(key).Append('=').Append(value); } private static Dictionary Parse(string raw) { if (string.IsNullOrEmpty(raw)) { return null; } Dictionary dictionary = new Dictionary(StringComparer.Ordinal); string[] array = raw.Split(';'); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { dictionary[text.Substring(0, num)] = text.Substring(num + 1); } } return dictionary; } private static bool GetBool(string key, bool local) { if (IsHost || _received == null || !_received.TryGetValue(key, out var value)) { return local; } return value == "1"; } private static float GetFloat(string key, float local) { if (IsHost || _received == null || !_received.TryGetValue(key, out var value)) { return local; } if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return local; } return result; } } } namespace BoomLagoon.MapLoaderFixes { internal static class BakedInteractableRepair { private const string InteractableLayer = "Interactable"; private const string InteractableTag = "Interactable"; private const string OutlineField = "_modelsToOutline"; internal static void RestoreInteractionLayer(GameObject go) { if ((Object)(object)go == (Object)null) { return; } int num = LayerMask.NameToLayer("Interactable"); if (num >= 0) { go.layer = num; } try { go.tag = "Interactable"; } catch { } } internal static bool PruneOutlineList(Component owner) { if ((Object)(object)owner == (Object)null) { return false; } FieldInfo fieldInfo = AccessTools.Field(((object)owner).GetType(), "_modelsToOutline"); if (!(fieldInfo?.GetValue(owner) is GameObject[] array)) { return false; } int num = 0; GameObject[] array2 = array; for (int i = 0; i < array2.Length; i++) { if ((Object)(object)array2[i] != (Object)null) { num++; } } if (num == array.Length) { return false; } GameObject[] array3 = (GameObject[])(object)new GameObject[num]; int num2 = 0; array2 = array; foreach (GameObject val in array2) { if ((Object)(object)val != (Object)null) { array3[num2++] = val; } } fieldInfo.SetValue(owner, array3); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)string.Format("[MapFix] Repaired {0} on '{1}' ({2} -> {3}).", "_modelsToOutline", ((Object)owner.gameObject).name, array.Length, num)); } return true; } } internal static class BundleTriggerRepair { internal static bool EnsureEnabled(Collider trigger) { if ((Object)(object)trigger == (Object)null || trigger.enabled) { return false; } trigger.enabled = true; return true; } } public class CurrentIslandSync : LagoonSceneComponent { internal const string MapId = "tournament_lagoon"; private const string SpawnerName = "HTFML_IslandPosition_tournament_lagoon"; private static readonly FieldRef IslandIndexRef = AccessTools.FieldRefAccess("_islandIndex"); private static bool _located; private static byte _index; private static Vector3 _center; internal static bool TryLocate(out byte index, out Vector3 center) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_002f: 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) //IL_0068: 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) if (!_located) { IslandSpawner[] array = Resources.FindObjectsOfTypeAll(); foreach (IslandSpawner val in array) { if ((Object)(object)val == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && string.Equals(((Object)val).name, "HTFML_IslandPosition_tournament_lagoon", StringComparison.Ordinal)) { _index = IslandIndexRef.Invoke(val); _center = ((Component)val).transform.position; _located = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Island] Boom Lagoon is island index {_index} at {_center}."); } break; } } } index = _index; center = _center; return _located; } internal static bool IsLagoonIndex(byte island) { if (TryLocate(out var index, out var _)) { return island == index; } return false; } internal static bool WithinLagoonZone(Vector3 pos) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (TryLocate(out var _, out var center)) { return SceneUtil.WithinZone(center, pos); } return false; } protected override void OnLagoonLoaded(Scene scene) { ((MonoBehaviour)this).StartCoroutine(SyncCurrentIsland()); } private static IEnumerator SyncCurrentIsland() { yield return null; while (IslandManager.IsLoading) { yield return null; } yield return null; if ((Object)(object)Server.Instance == (Object)null || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { yield break; } OnlineIslandManager instance = OnlineIslandManager.Instance; if ((Object)(object)instance == (Object)null) { yield break; } if (!TryLocate(out var index, out var _)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Island] 'HTFML_IslandPosition_tournament_lagoon' not found; can't sync the current island."); } yield break; } byte value = instance._curIsland.Value; byte value2 = instance._activeIsland.Value; if (value != index || value2 != index) { instance._curIsland.Value = index; instance._activeIsland.Value = index; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[Island] Set the current island {value} -> {index}, active {value2} -> {index} (Boom Lagoon)."); } } } } [HarmonyPatch(typeof(IslandManager))] internal static class CustomIslandClassification { [HarmonyPostfix] [HarmonyPatch("IsMiniIsland")] private static void IsMiniIsland(byte islandId, ref bool __result) { if (__result && CustomIslands.IsCustomIndex(islandId)) { __result = false; } } [HarmonyPostfix] [HarmonyPatch("IsMainIsland")] private static void IsMainIsland(byte islandId, ref bool __result) { if (!__result && CustomIslands.IsCustomIndex(islandId)) { __result = true; } } } [HarmonyPatch(typeof(RadarUI), "Awake")] internal static class RadarUIAwakePatch { [HarmonyPostfix] private static void AddDotFixer(RadarUI __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } public class CustomIslandDots : MonoBehaviour { private struct Entry { public string Id; public byte Index; public MapDot Dot; } private static class MapAssets { private struct Entry { public Sprite Icon; public bool HasColor; public Color Color; } [Serializable] private class MapManifest { public string id; public string radarIcon; public string radarColor; } private const string DefaultIconFile = "radar-icon.png"; private static readonly Dictionary Cache = new Dictionary(StringComparer.OrdinalIgnoreCase); public static Sprite Icon(string mapId) { return Resolve(mapId).Icon; } public static bool RadarColor(string mapId, out Color color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Entry entry = Resolve(mapId); color = entry.Color; return entry.HasColor; } private static Entry Resolve(string mapId) { if (string.IsNullOrEmpty(mapId)) { return default(Entry); } if (Cache.TryGetValue(mapId, out var value)) { return value; } Entry entry = Read(mapId); Cache[mapId] = entry; return entry; } private static Entry Read(string mapId) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Entry result = default(Entry); MapManifest manifest; string text = FindManifest(mapId, out manifest); if (text == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[RadarIcon] No map.json found for map '" + mapId + "'; keeping the plain dot.")); } return result; } Color color = default(Color); if (!string.IsNullOrWhiteSpace(manifest.radarColor) && ColorUtility.TryParseHtmlString(manifest.radarColor.Trim(), ref color)) { color.a = 1f; result.Color = color; result.HasColor = true; } string path = (string.IsNullOrEmpty(manifest.radarIcon) ? "radar-icon.png" : manifest.radarIcon); string path2 = Path.Combine(Path.GetDirectoryName(text) ?? ".", path); result.Icon = (File.Exists(path2) ? LoadSprite(path2, mapId) : null); if ((Object)(object)result.Icon == (Object)null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[RadarIcon] No radar icon found for map '" + mapId + "'; keeping the plain dot.")); } } return result; } private static Sprite LoadSprite(string path, string mapId) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0081: 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) Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "BoomLagoon_RadarIcon_" + mapId, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path), true)) { Object.Destroy((Object)(object)val); ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[RadarIcon] '" + path + "' isn't a readable PNG; keeping the plain dot.")); } return null; } ((Texture)val).filterMode = (FilterMode)1; Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)val2).name = ((Object)val).name; ((Object)val2).hideFlags = (HideFlags)61; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[RadarIcon] Loaded '" + path + "' for map '" + mapId + "'.")); } return val2; } private static string FindManifest(string mapId, out MapManifest manifest) { manifest = null; string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "Maps"); if (!Directory.Exists(path)) { return null; } string[] files = Directory.GetFiles(path, "map.json", SearchOption.AllDirectories); foreach (string text in files) { MapManifest mapManifest; try { mapManifest = JsonUtility.FromJson(File.ReadAllText(text)); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[RadarIcon] Couldn't read '" + text + "': " + ex.Message)); } continue; } if (mapManifest != null && string.Equals(mapManifest.id, mapId, StringComparison.OrdinalIgnoreCase)) { manifest = mapManifest; return text; } } return null; } } private const string DotPrefix = "HTFML_Radar_"; private const float ScanInterval = 2f; private static readonly FieldRef IslandDotsRef = AccessTools.FieldRefAccess("_islandDots"); private static readonly FieldRef IsOnRef = AccessTools.FieldRefAccess("_isOn"); private static readonly FieldRef DotImageRef = AccessTools.FieldRefAccess("_dot"); private static readonly Action UpdateDot = AccessTools.MethodDelegate>(AccessTools.Method(typeof(RadarUI), "UpdateDot", new Type[2] { typeof(MapDot), typeof(Vector3) }, (Type[])null), (object)null, true); private static readonly Dictionary KnownColors = new Dictionary(); private readonly List _entries = new List(); private RadarUI _radar; private float _nextScan; private void Awake() { _radar = ((Component)this).GetComponent(); if ((Object)(object)_radar == (Object)null) { Object.Destroy((Object)(object)this); } else if (UpdateDot == null || IslandDotsRef == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Radar] RadarUI has changed shape; leaving custom island dots alone."); } Object.Destroy((Object)(object)this); } } private void Update() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + 2f; EnsureDots(); } if (_entries.Count == 0 || !IsOnRef.Invoke(_radar)) { return; } for (int num = _entries.Count - 1; num >= 0; num--) { Entry entry = _entries[num]; if (TryGetPosition(entry.Index, entry.Id, out var position)) { try { UpdateDot(_radar, entry.Dot, position); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Radar] Dropping the '" + entry.Id + "' dot on " + ((Object)this).name + ": " + ex.Message)); } _entries.RemoveAt(num); } } } } private void EnsureDots() { List all = CustomIslands.All; if (all.Count == 0) { return; } MapDot[] array = IslandDotsRef.Invoke(_radar); if (array == null || array.Length == 0) { return; } MapDot val = FirstDot(array); if (val == null) { return; } int num = 0; foreach (CustomIslands.Entry item in all) { num = Mathf.Max(num, item.Index + 1); } if (num > array.Length) { Array.Resize(ref array, num); } bool flag = num > IslandDotsRef.Invoke(_radar).Length; foreach (CustomIslands.Entry item2 in all) { if (Known(item2.Index)) { continue; } MapDot val2 = array[item2.Index]; if (val2 != null) { if (IsLoaderDot(val2, item2.Id)) { Remember(item2.Id, val2); ApplyIcon(DotImageRef.Invoke(val2), item2.Id); _entries.Add(new Entry { Id = item2.Id, Index = item2.Index, Dot = val2 }); } continue; } MapDot val3 = CloneDot(val, "HTFML_Radar_" + item2.Id, item2.Id); if (val3 != null) { array[item2.Index] = val3; flag = true; _entries.Add(new Entry { Id = item2.Id, Index = item2.Index, Dot = val3 }); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Radar] Added the '{item2.Id}' dot (index {item2.Index}) to {((Object)this).name}."); } } } if (flag) { IslandDotsRef.Invoke(_radar) = array; } } private bool Known(byte index) { foreach (Entry entry in _entries) { if (entry.Index == index) { return true; } } return false; } private static MapDot CloneDot(MapDot template, string name, string mapId) { //IL_0056: 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_0082: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown Image val = DotImageRef.Invoke(template); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).transform.parent == (Object)null) { return null; } GameObject val2 = Object.Instantiate(((Component)val).gameObject, ((Component)val).transform.parent, false); ((Object)val2).name = name; val2.transform.localPosition = ((Component)val).transform.localPosition; val2.transform.localRotation = ((Component)val).transform.localRotation; val2.transform.localScale = ((Component)val).transform.localScale; Image component = val2.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val2); return null; } if (MapAssets.RadarColor(mapId, out var color) || KnownColors.TryGetValue(mapId, out color)) { ((Graphic)component).color = color; } ApplyIcon(component, mapId); MapDot val3 = new MapDot(); DotImageRef.Invoke(val3) = component; val3.Hide(); val2.SetActive(((Component)val).gameObject.activeSelf); return val3; } private static void ApplyIcon(Image image, string mapId) { if (!((Object)(object)image == (Object)null)) { Sprite val = MapAssets.Icon(mapId); if (!((Object)(object)val == (Object)null) && !((Object)(object)image.sprite == (Object)(object)val)) { image.sprite = val; image.type = (Type)0; image.preserveAspect = true; } } } private static bool IsLoaderDot(MapDot dot, string mapId) { Image val = DotImageRef.Invoke(dot); if ((Object)(object)val != (Object)null) { return string.Equals(((Object)((Component)val).gameObject).name, "HTFML_Radar_" + mapId, StringComparison.OrdinalIgnoreCase); } return false; } private static void Remember(string mapId, MapDot dot) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Image val = DotImageRef.Invoke(dot); if ((Object)(object)val != (Object)null) { KnownColors[mapId] = ((Graphic)val).color; } } private static MapDot FirstDot(MapDot[] dots) { foreach (MapDot val in dots) { if (val != null && (Object)(object)DotImageRef.Invoke(val) != (Object)null) { return val; } } return null; } private static bool TryGetPosition(byte index, string mapId, out Vector3 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_005c: 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) if (CustomIslands.TryGetIslandInfo(index, out var info)) { position = info.IslandPosition; return true; } foreach (CustomIslands.Entry item in CustomIslands.All) { if (item.Index == index && string.Equals(item.Id, mapId, StringComparison.Ordinal)) { if ((Object)(object)item.Anchor == (Object)null) { break; } position = item.Anchor.position; return true; } } position = Vector3.zero; return false; } } internal static class CustomIslands { internal struct Entry { public string Id; public byte Index; public Transform Anchor; } public const string SpawnerPrefix = "HTFML_IslandPosition_"; private const float ScanInterval = 2f; private static readonly FieldRef IslandIndexRef = AccessTools.FieldRefAccess("_islandIndex"); private static readonly FieldRef InstanceRef = Reflect.StaticField(typeof(IslandManager), "_instance"); private static readonly FieldRef IslandInfosRef = Reflect.Field("_islandInfos"); private static readonly List Known = new List(); private static float _nextScan; public static List All { get { Refresh(); return Known; } } public static bool IsCustomIndex(byte index) { foreach (Entry item in All) { if (item.Index == index) { return true; } } return false; } public static bool TryGetIslandInfo(int index, out IslandInfo info) { info = null; if (InstanceRef == null || IslandInfosRef == null) { return false; } IslandManager val = InstanceRef.Invoke(); if ((Object)(object)val == (Object)null) { return false; } IslandInfo[] array = IslandInfosRef.Invoke(val); if (array == null || index < 0 || index >= array.Length) { return false; } info = array[index]; return info != null; } private static void Refresh() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 2f; foreach (Entry item in Known) { if (!((Object)(object)item.Anchor != (Object)null)) { Known.Clear(); break; } } if (Known.Count > 0) { return; } IslandSpawner[] array = Resources.FindObjectsOfTypeAll(); foreach (IslandSpawner val in array) { if (!((Object)(object)val == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((Object)val).name.StartsWith("HTFML_IslandPosition_", StringComparison.Ordinal)) { Known.Add(new Entry { Id = ((Object)val).name.Substring("HTFML_IslandPosition_".Length), Index = IslandIndexRef.Invoke(val), Anchor = ((Component)val).transform }); } } } if (Known.Count > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Island] Tracking {Known.Count} custom island(s) from HTFMapLoader."); } } } } [HarmonyPatch(typeof(SpawnManager), "TryGetInitialPlayerSpawn")] internal static class InitialSpawnFix { private static readonly FieldRef MainPlayerSpawnPointRef = Reflect.StaticField(typeof(SpawnManager), "_mainPlayerSpawnPoint"); private static bool _logged; [HarmonyPostfix] private static void ResolveOnCustomMap(ref Vector3 position, ref float rotation, ref bool __result) { //IL_0074: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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) if (__result || MainPlayerSpawnPointRef == null || IslandManager.IsLoading || !IslandManager.IsInitialized || (Object)(object)OnlineIslandManager.Instance == (Object)null || !((NetworkBehaviour)OnlineIslandManager.Instance).IsClientInitialized || OnlineIslandManager.CurMini != byte.MaxValue || (Object)(object)Island.MiniIsland != (Object)null || (Object)(object)Island.CurIsland == (Object)null || !CustomIslands.IsCustomIndex(OnlineIslandManager.CurIsland) || !SceneUtil.IsBundleScene(((Component)Island.CurIsland).gameObject.scene)) { return; } Transform val = MainPlayerSpawnPointRef.Invoke(); if ((Object)(object)val == (Object)null || ((Component)val).gameObject.scene != ((Component)Island.CurIsland).gameObject.scene) { return; } position = val.position; rotation = val.eulerAngles.y; __result = true; if (!_logged) { _logged = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Spawn] Resolving spawns on custom island {OnlineIslandManager.CurIsland} at {position}."); } } } } internal sealed class IslandLoadCompletion : MonoBehaviour { private const float SettleTimeout = 15f; private static readonly Action SetIsInitialized = BoolSetter("IsInitialized"); private static readonly FieldRef FirstIslandLoadedRef = Reflect.StaticField(typeof(IslandManager), "OnFirstIslandLoaded"); private void OnEnable() { SceneManager.sceneLoaded += HandleSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= HandleSceneLoaded; } private void HandleSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (SetIsInitialized != null && SceneUtil.IsBundleScene(scene)) { ((MonoBehaviour)this).StartCoroutine(Complete(scene)); } } private static IEnumerator Complete(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForFixedUpdate(); yield return (object)new WaitForFixedUpdate(); float deadline = Time.unscaledTime + 15f; while (!IsLive(scene)) { if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded) { yield break; } if (Time.unscaledTime > deadline) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Island] Bundle scene '" + ((Scene)(ref scene)).name + "' never published an Island; leaving IslandManager.IsInitialized alone. If this is a custom map, nobody will spawn on it.")); } yield break; } yield return null; } if (!IslandManager.IsInitialized) { SetIsInitialized(obj: true); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Island] '" + ((Scene)(ref scene)).name + "' is live; IslandManager.IsInitialized set (HTFMapLoader bypasses the native load that would have done it, which is what left players bodiless).")); } RaiseFirstIslandLoaded(); } HonourPendingTeleport(); } private static bool IsLive(Scene scene) { //IL_0017: 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) if ((Object)(object)Island.CurIsland != (Object)null) { return ((Component)Island.CurIsland).gameObject.scene == scene; } return false; } private static void RaiseFirstIslandLoaded() { FieldRef firstIslandLoadedRef = FirstIslandLoadedRef; Action action = ((firstIslandLoadedRef != null) ? firstIslandLoadedRef.Invoke() : null); if (action == null) { return; } try { action(); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"[Island] An OnFirstIslandLoaded handler threw: {arg}"); } } } private static void HonourPendingTeleport() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_003e: 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_0043: 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) if (!OnlineIslandManager.TeleportPlayers) { return; } bool teleportToMini = OnlineIslandManager.TeleportToMini; if ((Object)(object)Server.Instance != (Object)null && ((NetworkBehaviour)Server.Instance).IsServerInitialized && (Object)(object)Player.LocalPlayer != (Object)null) { Vector3 val = (teleportToMini ? SpawnManager.MiniSpawnPos : SpawnManager.MainSpawnPos); float num = (teleportToMini ? SpawnManager.MiniSpawnRot : SpawnManager.MainSpawnRot); foreach (Player alivePlayer in PlayerManager.AlivePlayers) { Server.Instance.TeleportPlayer(alivePlayer, val, num); } } if ((Object)(object)Player.LocalPlayer != (Object)null && (Object)(object)BoatManager.Instance != (Object)null) { Vector3 position = Player.LocalPlayer.Transform.position; BoatManager.Instance.TryMoveBoat(SpawnManager.GetBoatSpawnPos(position), SpawnManager.GetBoatSpawnRot(position)); } OnlineIslandManager.ToggleTeleportPlayers(false, false); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[Island] Honoured the pending teleport request and cleared it."); } } private static Action BoolSetter(string property) { MethodInfo methodInfo = AccessTools.PropertySetter(typeof(IslandManager), property); if (methodInfo == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Reflect] IslandManager." + property + " has no setter; custom-map load completion stands down.")); } return null; } return (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); } } [HarmonyPatch(typeof(IslandManager), "GetCurIslandMovedDiff")] internal static class IslandRebase { [HarmonyPrefix] private static bool NoDiffOnCustomIsland(ref Vector3 __result) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)OnlineIslandManager.Instance == (Object)null) { return true; } byte curIsland = OnlineIslandManager.CurIsland; if (!CustomIslands.IsCustomIndex(curIsland) && CustomIslands.TryGetIslandInfo(curIsland, out var _)) { return true; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Island] Restoring legacy world items on island {curIsland} without a moved-position rebase."); } __result = Vector3.zero; return false; } } internal static class MapLoaderIdleSkip { private const string LoaderPluginType = "HTFMapLoader.Plugin"; private static FieldRef _registeredRef; private static FieldRef _verifiedRef; private static bool _loggedIdle; internal static void Install(Harmony harmony) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown Type type = AccessTools.TypeByName("HTFMapLoader.Plugin"); if (type == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[MapLoader] HTFMapLoader.Plugin not found; leaving its Update alone."); } return; } try { _registeredRef = AccessTools.FieldRefAccess(type, "_registered"); _verifiedRef = AccessTools.FieldRefAccess(type, "_verifiedRegisteredTriggers"); harmony.Patch((MethodBase)AccessTools.Method(type, "Update", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(MapLoaderIdleSkip), "SkipWhenIdle", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { _registeredRef = null; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[MapLoader] HTF Map Loader has changed shape; leaving its Update alone: " + ex.Message)); } return; } ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)"[MapLoader] HTF Map Loader's per-frame radar scan will be skipped once its maps are registered."); } } [HarmonyPriority(200)] private static bool SkipWhenIdle(object __instance) { if (_registeredRef == null) { return true; } if (!_registeredRef.Invoke(__instance) || !_verifiedRef.Invoke(__instance)) { return true; } if (!_loggedIdle) { _loggedIdle = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[MapLoader] Maps registered and triggers verified; its Update is idle from here."); } } return false; } } } namespace BoomLagoon.Flares { [DisallowMultipleComponent] internal sealed class AirRaidFlare : MonoBehaviour { private const float SettleCheckSeconds = 0.5f; private const float SettleMaxSeconds = 5f; private const float SettleDistance = 0.25f; private static readonly List Live = new List(); private Item _item; private Coroutine _arming; private bool _armWhenEnabled; private AirRaidQueue.Entry _raid; private void Awake() { _item = ((Component)this).GetComponent(); if ((Object)(object)_item != (Object)null) { _item._syncedHolder.OnChange += OnHolderChanged; } Live.Add(this); } private void OnEnable() { if (_armWhenEnabled) { _armWhenEnabled = false; if ((Object)(object)_item != (Object)null && (Object)(object)_item.SyncedHolder == (Object)null) { BeginArming(); } } } private void OnDestroy() { if ((Object)(object)_item != (Object)null) { _item._syncedHolder.OnChange -= OnHolderChanged; } Live.Remove(this); CancelRaid("is gone"); } private void OnHolderChanged(Player prev, Player next, bool asServer) { if (asServer) { if ((Object)(object)next != (Object)null) { _armWhenEnabled = false; StopArming(); CancelRaid("was picked up"); } else if ((Object)(object)prev != (Object)null) { BeginArming(); } } } internal void HostArmLoose() { if (!((Object)(object)_item == (Object)null) && !((Object)(object)_item.SyncedHolder != (Object)null)) { BeginArming(); } } internal static Item HostSpawnLoose(Vector3 position, Quaternion rotation) { //IL_002f: 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_0072: 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) //IL_0094: 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) if (!HostSettings.IsHost || !HostSettings.BomberEnabled) { return null; } Item basePrefab = FlareMark.BasePrefab; if ((Object)(object)basePrefab == (Object)null || (Object)(object)InstanceFinder.ServerManager == (Object)null) { return null; } Item val = Object.Instantiate(basePrefab, position, rotation, Server.Instance.DynamicObjectsHolder); FlareMark.HostMark(val); AirRaidFlare component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); return null; } InstanceFinder.ServerManager.Spawn(((Component)val).gameObject, (NetworkConnection)null, default(Scene)); component.HostArmLoose(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Flare] Flare spawned loose at ({position.x:F0}, {position.z:F0})."); } return val; } private void BeginArming() { if (_raid == null) { if (!((Behaviour)this).isActiveAndEnabled) { _armWhenEnabled = true; return; } StopArming(); _arming = ((MonoBehaviour)this).StartCoroutine(ArmWhenSettled()); } } private void StopArming() { if (_arming != null) { ((MonoBehaviour)this).StopCoroutine(_arming); _arming = null; } } private IEnumerator ArmWhenSettled() { float giveUpAt = Time.time + 5f; Vector3 last = ((Component)this).transform.position; WaitForSeconds wait = new WaitForSeconds(0.5f); while (Time.time < giveUpAt) { yield return wait; Vector3 position = ((Component)this).transform.position; float num = position.x - last.x; float num2 = position.z - last.z; if (num * num + num2 * num2 < 0.0625f) { break; } last = position; } _arming = null; if ((Object)(object)_item == (Object)null || !((NetworkBehaviour)_item).IsServerInitialized || _item.IsDestroying || (Object)(object)_item.SyncedHolder != (Object)null) { yield break; } Vector3 position2 = ((Component)this).transform.position; _raid = AirRaidQueue.Enqueue(home: false, new Vector2(position2.x, position2.z)); if (_raid != null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Flare] Flare down at ({position2.x:F0}, {position2.z:F0}): air raid #{_raid.Id} called in."); } } } private void CancelRaid(string why) { if (_raid == null) { return; } AirRaidQueue.Entry raid = _raid; _raid = null; if (AirRaidQueue.Remove(raid)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Flare] Flare {why}: air raid #{raid.Id} called off."); } } } internal static void HostRaidDetonated(AirRaidQueue.Entry raid) { if (raid == null) { return; } foreach (AirRaidFlare item2 in Live) { if ((Object)(object)item2 == (Object)null || item2._raid != raid) { continue; } item2._raid = null; item2.StopArming(); Item item = item2._item; if ((Object)(object)item != (Object)null && ((NetworkBehaviour)item).IsServerInitialized && !((NetworkBehaviour)item).IsDeinitializing && !item.IsDestroying) { item.DestroyItem((byte)0, byte.MaxValue); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Flare] Air raid #{raid.Id} detonated; the flare that called it in burnt out."); } } break; } } } internal static class FlareDefinition { public const string BaseItemKey = "badball"; public const string HoldPoseItemKey = "crabmeat"; public const string LooksItemKey = "dynamite"; public const byte Marker = 241; public const byte PurchaseRequestId = 210; public const string DisplayName = "Air Raid Flare"; public const int Cost = 500; } [DisallowMultipleComponent] internal sealed class FlareEffects : MonoBehaviour { private ParticleSystem _smoke; private bool _smokeTried; private void Start() { AttachSmoke(); } private void OnEnable() { if ((Object)(object)_smoke != (Object)null) { _smoke.Play(); } } private void AttachSmoke() { if (!_smokeTried) { _smokeTried = true; Transform val = FindChild(((Component)this).transform, "FlareSmokeAnchor"); if ((Object)(object)val != (Object)null) { _smoke = FlareSmoke.Attach(val); } } } private static Transform FindChild(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == name) { return val; } } return null; } } internal static class FlareSmoke { private const string SourceEffect = "Smoke"; private static readonly FieldInfo ParticleHolderField = AccessTools.Field(typeof(ParticleManager), "_particleHolder"); private static GameObject _template; private static bool _warned; public static ParticleSystem Attach(Transform anchor) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) GameObject orBuildTemplate = GetOrBuildTemplate(); if ((Object)(object)orBuildTemplate == (Object)null) { return null; } GameObject obj = Object.Instantiate(orBuildTemplate, anchor, false); ((Object)obj).name = "FlareSmoke"; obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; ParticleSystem component = obj.GetComponent(); component.Play(); return component; } private static GameObject GetOrBuildTemplate() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if ((Object)(object)_template != (Object)null) { return _template; } ParticleManager val = Object.FindAnyObjectByType(); Transform val2 = (Transform)(((Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.Find("Smoke") : null); if ((Object)(object)val3 == (Object)null || (Object)(object)((Component)val3).GetComponent() == (Object)null) { if (!_warned) { _warned = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Flare] Couldn't find the game's 'Smoke' particle effect; flares burn without smoke."); } } return null; } GameObject val4 = new GameObject("BoomLagoon.FlareSmokeTemplate"); val4.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val4); _template = Object.Instantiate(((Component)val3).gameObject, val4.transform); ((Object)_template).name = "FlareSmokeTemplate"; Retune(_template.GetComponent()); return _template; } private static void Retune(ParticleSystem system) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //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_00c1: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) system.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = system.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).duration = 2f; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.6f, 2.6f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.05f, 0.15f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.2f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.85f, 0.85f, 0.85f), new Color(0.6f, 0.6f, 0.6f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f); ((MainModule)(ref main)).maxParticles = 64; EmissionModule emission = system.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(8f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]); ShapeModule shape = system.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.02f; VelocityOverLifetimeModule velocityOverLifetime = system.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.06f, 0.06f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.35f, 0.6f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.06f, 0.06f); SizeOverLifetimeModule sizeOverLifetime = system.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[4] { new Keyframe(0f, 0.4f), new Keyframe(0.2f, 1f), new Keyframe(0.7f, 1.6f), new Keyframe(1f, 0f) })); NoiseModule noise = system.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.12f); ((NoiseModule)(ref noise)).frequency = 0.8f; ((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.3f); CollisionModule collision = system.collision; ((CollisionModule)(ref collision)).enabled = false; InheritVelocityModule inheritVelocity = system.inheritVelocity; ((InheritVelocityModule)(ref inheritVelocity)).enabled = false; } } internal static class FlareMark { private static Item _basePrefab; public static Item BasePrefab { get { if ((Object)(object)_basePrefab == (Object)null) { _basePrefab = GameInfo.GetSpawnable("badball"); } return _basePrefab; } } public static bool IsFlare(Item item) { if ((Object)(object)item == (Object)null || item.CurSkin != 241) { return false; } Item basePrefab = BasePrefab; if ((Object)(object)basePrefab != (Object)null) { return item.ID == basePrefab.ID; } return false; } public static void HostMark(Item item) { item._curSkin.Value = 241; Dress(item); } public static void Dress(Item item) { if (!IsFlare(item)) { return; } try { FlareModel.DressItem(item, GameInfo.GetSpawnable("crabmeat"), GameInfo.GetSpawnable("dynamite")); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[Flare] Couldn't dress a Badball as a flare; it stays a Badball: {arg}"); } } } } internal static class FlareModel { private sealed class MeshBuilder { private readonly float _lift; private readonly List _vertices = new List(); private readonly List _normals = new List(); private readonly List _uvs = new List(); private readonly List _triangles = new List(); public MeshBuilder(float lift) { _lift = lift; } public void Frustum(float y0, float y1, float r0, float r1, Vector2 uv) { //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_005e: 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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0091: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b3: 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) for (int i = 0; i < 12; i++) { float num = (float)i * 2f * MathF.PI / 12f; float num2 = (float)(i + 1) * 2f * MathF.PI / 12f; float num3 = (num + num2) * 0.5f; Vector3 val = new Vector3(Mathf.Cos(num3) * (y1 - y0), r0 - r1, Mathf.Sin(num3) * (y1 - y0)); Vector3 normalized = ((Vector3)(ref val)).normalized; int count = _vertices.Count; Add(Rim(num, y1, r1), normalized, uv); Add(Rim(num2, y1, r1), normalized, uv); Add(Rim(num2, y0, r0), normalized, uv); Add(Rim(num, y0, r0), normalized, uv); _triangles.AddRange(new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); } } public void Disc(float y, float r, bool up, Vector2 uv) { //IL_000a: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 n = (up ? Vector3.up : Vector3.down); int count = _vertices.Count; Add(new Vector3(0f, y, 0f), n, uv); for (int i = 0; i < 12; i++) { Add(Rim((float)i * 2f * MathF.PI / 12f, y, r), n, uv); } for (int j = 0; j < 12; j++) { int num = count + 1 + j; int num2 = count + 1 + (j + 1) % 12; if (up) { _triangles.AddRange(new int[3] { count, num2, num }); } else { _triangles.AddRange(new int[3] { count, num, num2 }); } } } public Mesh ToMesh(string name, Func map) { //IL_003f: 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_0049: 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_0064: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown List list = new List(_vertices.Count); List list2 = new List(_normals.Count); List list3 = new List(_normals.Count); for (int i = 0; i < _vertices.Count; i++) { Vector3 val = map(_normals[i]); list.Add(map(_vertices[i] + Vector3.up * _lift)); list2.Add(val); list3.Add(TangentFor(val)); } Mesh val2 = new Mesh { name = name }; val2.SetVertices(list); val2.SetNormals(list2); val2.SetTangents(list3); val2.SetUVs(0, _uvs); val2.SetTriangles(_triangles, 0); val2.RecalculateBounds(); return val2; } private void Add(Vector3 v, Vector3 n, Vector2 uv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) _vertices.Add(v); _normals.Add(n); _uvs.Add(uv); } private static Vector3 Rim(float angle, float y, float r) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Cos(angle) * r, y, Mathf.Sin(angle) * r); } private static Vector4 TangentFor(Vector3 normal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0032: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) < 0.99f) ? Vector3.up : Vector3.right, normal); Vector3 normalized = ((Vector3)(ref val)).normalized; return new Vector4(normalized.x, normalized.y, normalized.z, -1f); } } internal const string BodyName = "Flare"; internal const string SmokeAnchorName = "FlareSmokeAnchor"; private const float Lift = 0.12f; internal const float BaseHeight = 0.044999994f; private const float Bottom = -0.075f; private const float Top = 0.084f; private const float Radius = 0.018f; private const int Sides = 12; private const float Glow = 1.5f; private static readonly int EmissionId = Shader.PropertyToID("_Emission"); private static readonly Vector2 Red = Uv(0, 0); private static Mesh _bodyMesh; private static Mesh _iconMesh; private static Material _bodyMaterial; private static readonly Quaternion GripToFlare = Quaternion.Euler(0f, 0f, -90f); private static Vector3 Center => new Vector3(0f, 0.12449999f, 0f); private static float Length => 0.15900001f; private static Vector3 TipPoint => new Vector3(0f, 0.204f, 0f); private static Mesh IconMesh => _iconMesh; private static Vector3 GripCenter => new Vector3(0f, 0.12f, 0f); public static void DressItem(Item item, Item holdPose, Item looks) { //IL_008e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((Component)item).GetComponent() != (Object)null)) { List list = Field>(item, "_renderers"); Collider[] array = Field(item, "_worldColliders"); MeshRenderer val = (MeshRenderer)((list != null && list.Count > 0) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() == (Object)null || array == null || array.Length == 0) { throw new InvalidOperationException("The Badball no longer has the expected ball/collider layout."); } BuildShared(BaseMaterial((Renderer)(object)val)); GameObject gameObject = ((Component)val).gameObject; ((Object)gameObject).name = "Flare"; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localRotation = Quaternion.identity; gameObject.transform.localScale = Vector3.one; Dress(gameObject); FitColliders(item, array); SetField(item, "_mesh", IconMesh); SetField(item, "_modelHeight", 0.1f); SetField(item, "_buoyancy", 2f); SetField(item, "_ignoredBySeagulls", true); CopyHoldPose(item, holdPose); CopyLooks(item, looks); ((Component)item).gameObject.AddComponent(); ((Component)item).gameObject.AddComponent(); } } private static Material BaseMaterial(Renderer fallback) { Item basePrefab = FlareMark.BasePrefab; Renderer val = (Renderer)(object)(((Object)(object)basePrefab != (Object)null) ? ((Component)basePrefab).GetComponentInChildren(true) : null); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.sharedMaterial != (Object)null)) { return fallback.sharedMaterial; } return val.sharedMaterial; } public static void Dress(GameObject body) { //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_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_bodyMesh == (Object)null) { throw new InvalidOperationException("The flare's meshes aren't built yet."); } MeshFilter val = body.GetComponent(); if ((Object)(object)val == (Object)null) { val = body.AddComponent(); } MeshRenderer val2 = body.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = body.AddComponent(); } val.sharedMesh = _bodyMesh; ((Renderer)val2).sharedMaterial = _bodyMaterial; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; GameObject val3 = new GameObject("FlareSmokeAnchor"); val3.transform.SetParent(body.transform, false); val3.transform.localPosition = TipPoint; } public static bool TryBuildShared() { if ((Object)(object)_bodyMesh != (Object)null) { return true; } Item basePrefab = FlareMark.BasePrefab; Renderer val = (Renderer)(object)(((Object)(object)basePrefab != (Object)null) ? ((Component)basePrefab).GetComponentInChildren(true) : null); if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMaterial == (Object)null) { return false; } BuildShared(val.sharedMaterial); return true; } private static void BuildShared(Material source) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if (!((Object)(object)_bodyMesh != (Object)null)) { _bodyMaterial = new Material(source) { name = "BoomLagoon_Flare" }; _bodyMaterial.SetFloat(EmissionId, 1.5f); _bodyMesh = BuildBody(0.12f).ToMesh("BoomLagoon_Flare", (Vector3 p) => p); _iconMesh = BuildIconMesh(); } } private static MeshBuilder BuildBody(float lift) { //IL_0012: 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_0047: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(lift); meshBuilder.Disc(-0.075f, 0.018f, up: false, Red); meshBuilder.Frustum(-0.075f, 0.084f, 0.018f, 0.018f, Red); meshBuilder.Disc(0.084f, 0.018f, up: true, Red); return meshBuilder; } private static Mesh BuildIconMesh() { return BuildBody(0f).ToMesh("BoomLagoon_FlareIcon", (Vector3 p) => new Vector3(p.x, 0f - p.z, p.y)); } private static void FitColliders(Item item, Collider[] world) { //IL_0028: 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) for (int i = 0; i < world.Length; i++) { Collider val = world[i]; if (!((Object)(object)val == (Object)null)) { CapsuleCollider val2 = ((Component)val).gameObject.AddComponent(); val2.direction = 1; val2.center = Center; val2.height = Length; val2.radius = 0.018f; ((Collider)val2).sharedMaterial = val.sharedMaterial; ((Collider)val2).enabled = val.enabled; val.enabled = false; world[i] = (Collider)(object)val2; } } Collider val3 = Field(item, "_pickUpCollider"); SphereCollider val4 = (SphereCollider)(object)((val3 is SphereCollider) ? val3 : null); if (val4 != null) { val4.center = Center; val4.radius = Length * 0.5f + 0.04f; } ItemManager.Add(item, val3, world); } private static void CopyHoldPose(Item item, Item source) { //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_0066: 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_0070: 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) //IL_007b: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00dd: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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) HandTransforms val = (((Object)(object)source != (Object)null) ? source.HandTransformsRight : null); if (val == null || !val.Exists) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Flare] The 'crabmeat' grip wasn't found; the flare keeps the Badball's two-handed hold."); } return; } Quaternion[] array = (Quaternion[])((val.FingerRots != null) ? ((Array)(Quaternion[])val.FingerRots.Clone()) : ((Array)new Quaternion[0])); SetField(item, "_handTransformsRight", (object)new HandTransforms(true, GripCenter + GripToFlare * val.HandPos, GripToFlare * val.HandRot, array, ((Component)item).transform)); SetField(item, "_handTransformsLeft", (object)new HandTransforms(false, Vector3.zero, new Quaternion(0f, 0f, 0f, 0f), (Quaternion[])(object)new Quaternion[0], (Transform)null)); Quaternion val2 = Quaternion.Inverse(GripToFlare); Quaternion val3 = Quaternion.Euler(source.HeldRot) * val2; SetField(item, "_heldPos", source.HeldPos - val3 * GripCenter); SetField(item, "_heldRot", ((Quaternion)(ref val3)).eulerAngles); SetField(item, "_drawAnimStartPos", source.DrawAnimStartPos); Quaternion val4 = Quaternion.Euler(source.DrawAnimStartRot) * val2; SetField(item, "_drawAnimStartRot", ((Quaternion)(ref val4)).eulerAngles); } private static void CopyLooks(Item item, Item source) { //IL_0041: 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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Flare] 'dynamite' wasn't found; the flare keeps the Badball's icon pose and sounds."); } } else { SetField(item, "_inventoryMeshScale", source.InventoryMeshScale * 10f); SetField(item, "_inventoryMeshRot", source.InventoryMeshRot); SetField(item, "_inventoryMeshPos", source.InventoryMeshPos); SetField(item, "_impactSoundType", source.ImpactSoundType); SetField(item, "_waterCollisionAudio", source.WaterCollisionAudio); } } private static T Field(Item item, string name) { return (T)RequireField(name).GetValue(item); } private static void SetField(Item item, string name, object value) { RequireField(name).SetValue(item, value); } private static FieldInfo RequireField(string name) { return AccessTools.Field(typeof(Item), name) ?? throw new MissingFieldException("Item", name); } private static Vector2 Uv(int column, int row) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) return new Vector2(((float)column + 0.5f) / 32f, 1f - ((float)row + 0.5f) / 32f); } } [HarmonyPatch(typeof(Item), "GetName")] internal static class FlareNamePatch { private static void Postfix(Item __instance, ref string __result) { if (FlareMark.IsFlare(__instance)) { __result = "Air Raid Flare"; } } } [HarmonyPatch(typeof(Item), "OnStartClient")] internal static class FlareSpawnPatch { private static void Prefix(Item __instance) { FlareMark.Dress(__instance); } } [HarmonyPatch(typeof(Item), "LoadFromSave")] internal static class FlareLoadPatch { private static void Postfix(Item __instance, SavedItem savedItem) { if (savedItem == null || savedItem.SkinIndex != 241) { return; } Item basePrefab = FlareMark.BasePrefab; if (!((Object)(object)basePrefab == (Object)null) && __instance.ID == basePrefab.ID) { FlareMark.HostMark(__instance); AirRaidFlare component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.HostArmLoose(); } } } } [HarmonyPatch] internal static class FlareBuyPatch { private static MethodBase Target() { return AccessTools.GetDeclaredMethods(typeof(Server)).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("RpcLogic___BuyItem", StringComparison.Ordinal) && m.GetParameters().Length == 6); } private static bool Prepare() { if (Target() != null) { return true; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Flare] The game's BuyItem RPC wasn't found; flares can't be bought."); } return false; } private static MethodBase TargetMethod() { return Target(); } private static bool Prefix(Server __instance, byte __0, Player __1, Item __2, Vector3 __3, Quaternion __4) { //IL_000e: 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) if (__0 != 210) { return true; } try { Sell(__instance, __1, __2, __3, __4); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[Flare] Selling a flare failed: {arg}"); } } return false; } private static void Sell(Server server, Player player, Item replaced, Vector3 pos, Quaternion rot) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) Item basePrefab = FlareMark.BasePrefab; if ((Object)(object)basePrefab == (Object)null || (Object)(object)player == (Object)null || ((NetworkBehaviour)player).IsDeinitializing || (Object)(object)player.Holding.UninitializedHeldItem != (Object)null || (Object)(object)player.Holding.HeldItem != (Object)(object)replaced || ((Object)(object)replaced != (Object)null && (((NetworkBehaviour)replaced).IsDeinitializing || (Object)(object)replaced.SyncedHolder != (Object)(object)player)) || !MoneyManager.CanAfford(500, (Currency)0)) { return; } if (!((NetworkBehaviour)player).Owner.IsLocalClient) { player.Hands.PrepareForItemPickup(basePrefab.ID); } MoneyManager.RemoveMoney(500, player, (Currency)0); if ((Object)(object)replaced != (Object)null) { if (!player.Inventory.ServerTryStoreHeldItem(replaced)) { replaced.SetSyncedHolder((Player)null, false); } player.Holding.SetHeldItem((Item)null); } Item val = Object.Instantiate(basePrefab, pos, rot); FlareMark.HostMark(val); val.SetSyncedHolder(player, false); ((NetworkBehaviour)server).Spawn(((Component)val).gameObject, (NetworkConnection)null, default(Scene)); player.Holding.SetHeldItem(val); } } public class FlareShop : LagoonSceneComponent { private const string DisplayName = "AirRaidFlare (Purchasable)"; internal const float RootAboveWater = 0.4f; private static readonly FieldInfo ModelsToOutline = AccessTools.Field(typeof(Interactable), "_modelsToOutline"); private static readonly FieldInfo InteractCol = AccessTools.Field(typeof(Interactable), "_interactCol"); private static readonly FieldInfo TextTarget = AccessTools.Field(typeof(Interactable), "_textTarget"); protected override void OnLagoonLoaded(Scene scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(Place(scene)); } private static IEnumerator Place(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return null; yield return null; if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded) { yield break; } if (!FlareModel.TryBuildShared()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Flare] The vanilla 'badball' wasn't found; the lagoon doesn't sell the Air Raid Flare."); } yield break; } if (ModelsToOutline == null || InteractCol == null || TextTarget == null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Flare] The game's purchasable fields have changed; the lagoon doesn't sell flares."); } yield break; } GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { yield break; } if (!TryFindDropPoint(scene, out var at)) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"[Flare] Couldn't find the FatManBomb in the lagoon; the lagoon doesn't sell flares."); } yield break; } Build(val.transform, at); ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogInfo((object)string.Format("[Flare] {0} for sale at ({1:F1}, {2:F1}), on the FatManBomb.", "Air Raid Flare", at.x, at.z)); } } private static bool TryFindDropPoint(Scene scene, out Vector3 at) { //IL_00c7: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_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_0087: 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) GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } FatManBombTarget[] componentsInChildren = val.GetComponentsInChildren(true); foreach (FatManBombTarget fatManBombTarget in componentsInChildren) { if (!fatManBombTarget.IsImpactPoint) { MeshFilter componentInChildren = ((Component)fatManBombTarget).GetComponentInChildren(true); Vector3 val2; if (!((Object)(object)componentInChildren != (Object)null) || !((Object)(object)componentInChildren.sharedMesh != (Object)null)) { val2 = ((Component)fatManBombTarget).transform.position; } else { Transform transform = ((Component)componentInChildren).transform; Bounds bounds = componentInChildren.sharedMesh.bounds; val2 = transform.TransformPoint(((Bounds)(ref bounds)).center); } at = val2; at.y = WaterManager.GetWaterHeight(at); return true; } } } at = default(Vector3); return false; } private static void Build(Transform parent, Vector3 waterPoint) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0035: 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) //IL_007d: 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_0092: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) GameObject val = new GameObject("AirRaidFlare (Purchasable)"); val.SetActive(false); val.transform.SetParent(parent, false); val.transform.position = waterPoint + Vector3.up * 0.4f; BakedInteractableRepair.RestoreInteractionLayer(val); BoxCollider val2 = val.AddComponent(); ((Collider)val2).isTrigger = true; val2.center = new Vector3(0f, 0.3f, 0f); val2.size = new Vector3(0.8f, 1.8f, 0.8f); GameObject val3 = new GameObject("Flare"); val3.transform.SetParent(val.transform, false); FlareModel.Dress(val3); val3.transform.localPosition = Vector3.down * 0.495f; Transform transform = new GameObject("TextTarget").transform; transform.SetParent(val.transform, false); transform.localPosition = new Vector3(0f, 0.2f, 0f); FlarePurchasable obj = val.AddComponent(); ModelsToOutline.SetValue(obj, new GameObject[1] { val3 }); InteractCol.SetValue(obj, val2); TextTarget.SetValue(obj, transform); val.AddComponent(); val.AddComponent(); val.SetActive(true); } } internal sealed class FlarePurchasable : Purchasable { public override bool InteractableWhenHoldingItem => true; protected override void Awake() { ((Interactable)this).Awake(); Refresh(); } public override void Hover() { Refresh(); ((Purchasable)this).Hover(); } public override void Interact(Player player) { //IL_001b: 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_007d: 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_0096: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Server.Instance)) { return; } ((Interactable)this).Interact(player); if (!MoneyManager.CanAfford(base._customCost, base._customCurrency)) { ((Purchasable)this).CantBuyEffects(); return; } Item basePrefab = FlareMark.BasePrefab; if (!((Object)(object)basePrefab == (Object)null)) { player.Hands.PrepareForItemPickup(basePrefab.ID); Server.Instance.BuyItem((byte)210, player, player.Holding.HeldItem, ((Interactable)this)._modelsToOutline[0].transform.position, ((Component)this).transform.rotation * Quaternion.Euler(90f, 0f, 0f), false); } } private void Refresh() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) base._customCost = 500; base._customCurrency = (Currency)0; base._hoverString = string.Format("{0}\n${1}\n{2}", "Air Raid Flare", 500, SpriteManager.GetPickUpInput()); } } internal sealed class FlareBuoy : MonoBehaviour { private const float TiltDegrees = 4f; private float _phase; private void Awake() { _phase = Random.value * 10f; } private void LateUpdate() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0078: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; float num = WaterManager.GetWaterHeight(position) + 0.4f; ((Component)this).transform.position = new Vector3(position.x, num, position.z); float num2 = Time.time + _phase; ((Component)this).transform.rotation = Quaternion.Euler(Mathf.Sin(num2 * 0.9f) * 4f, 0f, Mathf.Sin(num2 * 0.7f + 1.3f) * 4f); } } } namespace BoomLagoon.Explosives { public static class AirRaids { public static int QueuedCount => AirRaidQueue.Count; public static bool Enqueue(Vector3 worldPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0043: Unknown result type (might be due to invalid IL or missing references) if (float.IsNaN(worldPosition.x) || float.IsNaN(worldPosition.z) || float.IsInfinity(worldPosition.x) || float.IsInfinity(worldPosition.z)) { return false; } return AirRaidQueue.Enqueue(home: false, new Vector2(worldPosition.x, worldPosition.z)) != null; } public static bool EnqueueHome() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return AirRaidQueue.Enqueue(home: true, Vector2.zero) != null; } public static void ClearQueue() { AirRaidQueue.ClearWaiting(); } public static bool Dequeue() { return AirRaidQueue.RemoveNextWaiting(); } public static void Recall() { AirRaidQueue.Recall(); } public static Item SpawnFlare(Vector3 position, Quaternion rotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return AirRaidFlare.HostSpawnLoose(position, rotation); } } internal static class AirRaidQueue { internal sealed class Entry { public readonly int Id; public readonly bool Home; public readonly Vector2 Target; public Entry(int id, bool home, Vector2 target) { //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) Id = id; Home = home; Target = target; } } private static readonly List Entries = new List(); private static Entry _active; private static bool _owed; private static int _nextId = 1; private static Object _session; public static int Count { get { ResetIfNewSession(); return Entries.Count; } } public static Entry Active { get { ResetIfNewSession(); return _active; } } public static bool Owed { get { ResetIfNewSession(); return _owed; } set { ResetIfNewSession(); _owed = value && _active != null; } } public static Entry Enqueue(bool home, Vector2 target) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (!HostSettings.IsHost) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Bomber] Only the host can queue air raids."); } return null; } if (!HostSettings.BomberEnabled) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Bomber] Air raids are turned off; raid not queued."); } return null; } ResetIfNewSession(); Entry entry = new Entry(_nextId++, home, target); Entries.Add(entry); ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)(home ? $"[Bomber] Queued raid #{entry.Id} on the FatManBomb ({Entries.Count} queued)." : $"[Bomber] Queued raid #{entry.Id} on ({target.x:F0}, {target.y:F0}) ({Entries.Count} queued).")); } return entry; } public static bool Remove(Entry entry) { if (entry == null) { return false; } ResetIfNewSession(); if (!Entries.Remove(entry)) { return false; } if (_active == entry) { _active = null; _owed = false; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Bomber] Raid #{entry.Id} called off ({Entries.Count} left)."); } return true; } public static bool AnyWaiting(Func eligible) { ResetIfNewSession(); foreach (Entry entry in Entries) { if (entry != _active && eligible(entry)) { return true; } } return false; } public static bool TryActivate(Func eligible, out Entry entry) { ResetIfNewSession(); foreach (Entry entry2 in Entries) { if (entry2 != _active && eligible(entry2)) { _active = entry2; _owed = true; entry = entry2; return true; } } entry = null; return false; } public static void Complete(int id) { ResetIfNewSession(); Entry entry = Entries.Find((Entry e) => e.Id == id); if (_active != null && _active.Id == id) { _active = null; _owed = false; } if (entry != null) { Entries.Remove(entry); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Bomber] Raid #{id} detonated; removed from the queue ({Entries.Count} left)."); } AirRaidFlare.HostRaidDetonated(entry); } } public static void ReleaseActive(string why) { ResetIfNewSession(); if (_active != null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Bomber] Raid #{_active.Id} not finished ({why}); it stays queued."); } _active = null; _owed = false; } } public static bool RemoveNextWaiting() { if (!HostSettings.IsHost) { return false; } ResetIfNewSession(); for (int i = 0; i < Entries.Count; i++) { if (Entries[i] != _active) { Entries.RemoveAt(i); return true; } } return false; } public static void ClearWaiting() { if (HostSettings.IsHost) { ResetIfNewSession(); Entries.RemoveAll((Entry e) => e != _active); } } public static void Recall() { if (HostSettings.IsHost) { ResetIfNewSession(); Entries.Clear(); _active = null; _owed = false; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[Bomber] Raid queue emptied; bomber called back."); } } } private static void ResetIfNewSession() { Object instance = (Object)(object)Server.Instance; if (!(_session == instance)) { _session = instance; Entries.Clear(); _active = null; _owed = false; } } } public class BomberManager : LagoonSceneComponent { protected override void OnLagoonLoaded(Scene scene) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(Setup(scene)); } private IEnumerator Setup(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return null; yield return null; Transform root = FindByName(scene, "Bomber"); if ((Object)(object)root == (Object)null) { yield break; } Transform plane = FindChild(root, "BombPlane"); Transform bomb = FindChild(root, "ABomb"); Transform val = FindByName(scene, "AirRaidSiren"); AudioSource siren = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)plane == (Object)null || (Object)(object)bomb == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Bomber] 'Bomber' is missing its 'BombPlane' or 'ABomb' child; no air raids."); } yield break; } if ((Object)(object)siren != (Object)null) { GameAudio.Route(siren); } else { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Bomber] No AudioSource on 'AirRaidSiren'; air raids will run without the siren."); } } yield return RaidKit.EnsureLoaded(); if (!((Object)(object)root == (Object)null)) { if ((Object)(object)((Component)root).GetComponent() == (Object)null) { ((Component)root).gameObject.AddComponent().Init(RaidKit.FadeMaterial, visible: true); } BomberRaid bomberRaid = ((Component)root).GetComponent(); if ((Object)(object)bomberRaid == (Object)null) { bomberRaid = ((Component)root).gameObject.AddComponent(); } bomberRaid.Init(((Component)root).GetComponent(), plane, bomb, siren, kit: false, root.parent); } } private static Transform FindByName(Scene scene, string name) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (!((Object)(object)val == (Object)null)) { Transform val2 = FindChild(val.transform, name); if ((Object)(object)val2 != (Object)null) { return val2; } } } return null; } internal static Transform FindChild(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } } return null; } } public class BomberRaid : MonoBehaviour { private const float NoseDownSeconds = 3f; private const float MissedRaidGraceSeconds = 5f; private const float FallGiveUpDepth = 100f; private const float MaxImpactHoldSeconds = 2f; private const double LegLeadSeconds = 3.0; private const double LegDropMarginSeconds = 0.5; private const double MinLegSeconds = 5.0; private const float RotationBlendSeconds = 4f; private const float MaxBankDegrees = 40f; private const float Gravity = 9.81f; private const float EngineDepth = 0.5f; private const float ImpactPointTimeoutSeconds = 30f; private const float KitSirenHeight = 12f; private const int PerimeterSamples = 72; private const float ClipStep = 0.002f; private Animation _anim; private AnimationState _lap; private Transform _plane; private Transform _bomb; private AudioSource _siren; private Vector3 _bayLocalPos; private Quaternion _bayLocalRot; private Rigidbody _rig; private Renderer[] _bombRenderers; private long _nextRaid = -1L; private bool _sirenStarted; private int _shownEnabled = -1; private Vector3 _basePosition; private float _bakedAltitude; private Vector3 _phase0Offset; private Quaternion _phase0Rot; private Vector2 _phase0Dir; private Vector2 _bayOffset; private Quaternion _noseOffset = Quaternion.identity; private float _lapPerimeter; private BomberFlightPlan _plan = BomberFlightPlan.Baked; private string _planRaw; private BomberFlightPlan _prevPlan = BomberFlightPlan.Baked; private BomberCircle _prevCircle = BomberCircle.BakedHome; private BomberCircle _circle = BomberCircle.BakedHome; private FlightLeg _leg; private int _legSeq = -1; private bool _inLeg; private double _legStartT; private Quaternion _legStartRot; private bool _scheduleHalted; private bool _kit; private Transform _impactParent; private bool _holding; private float _holdDeadline; private int _releaseActivationCount; private float _activationSeenAt = -1f; private bool _falling; private float _fallStartTime; private Quaternion _fallStartRot; private Quaternion _noseDownRot; private FatManBombTarget _fallTarget; private float _impactY; private FatManBombTarget _impact; private float _impactDisposeAt; private int _raidId; private FatManBombTarget _raidTarget; private float _raidDeadline; private FatManBombTarget _homeTarget; private FatManBombTarget _measuredTarget; private Bounds _targetBounds; private const float JumpMeters = 8f; private const float MaxTurnDegreesPerSecond = 35f; private const float ManeuverFadeSeconds = 2f; private const float SettleSeconds = 5f; private BomberFade _fade; private bool _tracked; private bool _ghost; private bool _hidden; private Vector3 _lastPos; private Vector3 _vel; private Vector3 _ghostPos; private Vector3 _ghostVel; private Quaternion _lastRot; private Quaternion _ghostRot; private float _smoothFor; private const float HudZoneRadius = 240f; private const float HudWarnScale = 1.25f; private const string HudIncomingText = "BOMB INCOMING"; private const string HudEnRouteText = "Bomber in bound"; private BombTimerHud _hud; private string _hudText; private int _hudSeconds = -1; internal static BomberRaid Instance { get; private set; } internal bool IsKit => _kit; internal bool Busy { get { if (!_falling && !_holding && !((Object)(object)_impact != (Object)null)) { return _raidId != 0; } return true; } } public void Init(Animation anim, Transform plane, Transform bomb, AudioSource siren, bool kit, Transform impactParent) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) _kit = kit; _impactParent = impactParent; _plane = plane; _bomb = bomb; _siren = siren; _bayLocalPos = bomb.localPosition; _bayLocalRot = bomb.localRotation; _bombRenderers = ((Component)bomb).GetComponentsInChildren(true); _fade = ((Component)this).GetComponent(); _bakedAltitude = plane.position.y; _basePosition = ((Component)this).transform.position; ApplyRoot(HomeRootXZ()); _anim = anim; StartLap(); if ((TrackedReference)(object)_lap != (TrackedReference)null) { MeasureClip(); } else { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Bomber] No BomberCircle clip on the Bomber's Animation; the plane won't circle or take queued raids."); } } _homeTarget = (kit ? null : FindHomeTarget()); MeasureTarget(_homeTarget); _plan = BomberFlightPlan.Baked; _planRaw = null; _prevPlan = BomberFlightPlan.Baked; _prevCircle = BomberCircle.BakedHome; _circle = BomberCircle.BakedHome; _leg = null; _legSeq = -1; _inLeg = false; _nextRaid = -1L; Instance = this; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)(string.Format("[Bomber] Ready{0}: raid every {1:F0}s, lap {2:F0}s, altitude {3:F0}m, ", kit ? " (raid kit, away from the lagoon)" : "", RaidPeriod(), LapSeconds(), HostSettings.Altitude) + "siren " + (((Object)(object)_siren != (Object)null) ? "found" : "MISSING") + ".")); } } private void StartLap() { _lap = null; if (!((Object)(object)_anim == (Object)null) && !((Object)(object)_anim.clip == (Object)null)) { _anim.cullingType = (AnimationCullingType)0; _anim.Play(((Object)_anim.clip).name); _lap = _anim[((Object)_anim.clip).name]; _lap.speed = 0f; _lap.wrapMode = (WrapMode)2; } } private void MeasureClip() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //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_0055: 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_0065: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0088: 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_0099: 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_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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00cc: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00fe: 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_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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0160: Unknown result type (might be due to invalid IL or missing references) float normalizedTime = _lap.normalizedTime; Vector3 val = (_phase0Offset = OffsetAt(0f)); _phase0Rot = _plane.rotation; Bounds val2 = BombBounds(); _bayOffset = XZ(((Bounds)(ref val2)).center - ((Component)this).transform.position); Vector3 v = OffsetAt(0.002f); Vector3 v2 = OffsetAt(0.998f); Vector2 val3 = XZ(v) - XZ(v2); _phase0Dir = ((Vector2)(ref val3)).normalized; float num = 0f; Vector3 v3 = val; for (int i = 1; i <= 72; i++) { Vector3 val4 = OffsetAt((float)i / 72f); num += Vector2.Distance(XZ(v3), XZ(val4)); v3 = val4; } _lapPerimeter = num; float num2 = Vector2.Distance(XZ(v), XZ(val)); if (num2 > 0.0001f) { Vector2 curvature = (XZ(v) - 2f * XZ(val) + XZ(v2)) / (num2 * num2); Quaternion val5 = FlightFrame(_phase0Dir, curvature, (float)((double)_lapPerimeter / LapSeconds())); _noseOffset = Quaternion.Inverse(val5) * _phase0Rot; } PoseLap(normalizedTime); } private Vector3 OffsetAt(float normalizedTime) { //IL_000d: 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_001d: Unknown result type (might be due to invalid IL or missing references) PoseLap(normalizedTime); return _plane.position - ((Component)this).transform.position; } private void PoseLap(float normalizedTime) { _lap.normalizedTime = normalizedTime; _anim.Sample(); } private void Update() { if ((Object)(object)_bomb == (Object)null) { return; } bool bomberEnabled = HostSettings.BomberEnabled; if ((bomberEnabled ? 1 : 0) != _shownEnabled) { SetBomberActive(bomberEnabled); } if (bomberEnabled) { double num = NetTime(); ReadPlan(); if (IsHost()) { HostTickQueue(num); } bool flag = !_plan.IsBaked && num < _plan.TStart; if (FlyPlane(num) && !flag && (!_kit || !_circle.Home) && !_plan.Done) { TickSchedule(num); } else { HaltSchedule(); } if ((_falling || _holding) && _activationSeenAt < 0f && (Object)(object)_fallTarget != (Object)null && _fallTarget.ActivationCount != _releaseActivationCount) { _activationSeenAt = Time.time; } if (_falling) { TickFall(); } else if (_holding) { TickHold(); } if (IsHost()) { HostTickRaidCompletion(); } TickImpactPoint(); } } private void SetBomberActive(bool enabled) { _shownEnabled = (enabled ? 1 : 0); _tracked = false; _nextRaid = -1L; _sirenStarted = false; if (!enabled) { if (_falling || _holding) { ResetBomb(); } DisposeImpactPoint(); if ((Object)(object)_siren != (Object)null) { _siren.Stop(); } } if ((Object)(object)_plane != (Object)null) { ((Component)_plane).gameObject.SetActive(enabled); } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)(enabled ? "[Bomber] Air raids on." : "[Bomber] Air raids off (host setting); bomber hidden.")); } } private void ReadPlan() { string raidPlan = HostSettings.RaidPlan; if (raidPlan == _planRaw) { return; } _planRaw = raidPlan; BomberFlightPlan bomberFlightPlan = BomberFlightPlan.Parse(raidPlan); if (bomberFlightPlan == null && !string.IsNullOrEmpty(raidPlan)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Bomber] Couldn't read the host's flight plan '" + raidPlan + "' (different BoomLagoon version?); keeping the home circle.")); } } if (bomberFlightPlan == null) { bomberFlightPlan = BomberFlightPlan.Baked; } BomberFlightPlan bomberFlightPlan2 = bomberFlightPlan; if (bomberFlightPlan2.Seq != _plan.Seq) { _prevPlan = _plan; _prevCircle = _plan.Destination; _plan = bomberFlightPlan2; _leg = null; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)(bomberFlightPlan2.IsBaked ? "[Bomber] Flight plan reset to the FatManBomb circle." : (string.Format("[Bomber] New flight plan #{0}: {1}, ", bomberFlightPlan2.Seq, bomberFlightPlan2.Home ? "back to the FatManBomb" : $"to ({bomberFlightPlan2.TargetX:F0}, {bomberFlightPlan2.TargetZ:F0})") + $"leaving in {bomberFlightPlan2.TStart - NetTime():F1}s, {bomberFlightPlan2.TArrive - bomberFlightPlan2.TStart:F0}s in the air."))); } } } private bool FlyPlane(double now) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) BomberCircle circle; if (_plan.IsBaked || now >= _plan.TArrive) { circle = _plan.Destination; } else { if (now >= _plan.TStart) { FlyLeg(_plan, now); return false; } if (InLeg(_prevPlan, now)) { FlyLeg(_prevPlan, now); return false; } circle = _prevCircle; } if (_inLeg) { EndLeg(); } if (!circle.SameAs(_circle)) { _circle = circle; _nextRaid = -1L; _sirenStarted = false; PlaceKitSiren(); } ApplyRoot(RootXZ(circle)); if ((TrackedReference)(object)_lap != (TrackedReference)null) { double num = (now - circle.Epoch) / CircleLap(circle); _lap.normalizedTime = (float)(num - Math.Floor(num)); } return true; } private static bool InLeg(BomberFlightPlan plan, double t) { if (!plan.IsBaked && t >= plan.TStart) { return t < plan.TArrive; } return false; } private void FlyLeg(BomberFlightPlan plan, double now) { //IL_0052: 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) //IL_0064: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0091: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) if (!_inLeg || _legStartT != plan.TStart) { if (!_inLeg && (Object)(object)_anim != (Object)null) { ((Behaviour)_anim).enabled = false; } _inLeg = true; _legStartT = plan.TStart; _legStartRot = _plane.rotation; } ApplyRoot(RootXZ(plan.Destination)); SampleLeg(plan, now, out var pos, out var dir, out var curvature, out var speed); Quaternion val = FlightFrame(dir, curvature, speed) * _noseOffset; double num = Math.Max(0.001, plan.TArrive - plan.TStart); float num2 = (float)(now - plan.TStart); float num3 = (float)(plan.TArrive - now); float num4 = Mathf.Min(4f, (float)num / 3f); if (num2 < num4) { val = Quaternion.Slerp(_legStartRot, val, Mathf.SmoothStep(0f, 1f, num2 / num4)); } if (num3 < num4) { val = Quaternion.Slerp(_phase0Rot, val, Mathf.SmoothStep(0f, 1f, num3 / num4)); } float num5 = ((Component)this).transform.position.y + _phase0Offset.y; _plane.SetPositionAndRotation(new Vector3(pos.x, num5, pos.y), val); } private void EndLeg() { _inLeg = false; if (!((Object)(object)_anim == (Object)null)) { ((Behaviour)_anim).enabled = true; StartLap(); } } private FlightLeg BuildLeg(BomberFlightPlan plan) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_002b: 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_0038: Unknown result type (might be due to invalid IL or missing references) Vector2 to = RootXZ(plan.Destination) + XZ(_phase0Offset); float minHandle = _lapPerimeter / (MathF.PI * 2f); return new FlightLeg(plan.StartPos, plan.StartDir, to, _phase0Dir, minHandle); } private void SampleLeg(BomberFlightPlan plan, double t, out Vector2 pos, out Vector2 dir, out Vector2 curvature, out float speed) { if (_leg == null || _legSeq != plan.Seq) { _leg = BuildLeg(plan); _legSeq = plan.Seq; } double num = Math.Max(0.001, plan.TArrive - plan.TStart); float speedScale; float u = FlightLeg.DistanceFraction((float)((t - plan.TStart) / num), plan.FromLapSeconds, plan.ToLapSeconds, out speedScale); _leg.Sample(u, out pos, out dir, out curvature); speed = _leg.Length / (float)num * speedScale; } private static Quaternion FlightFrame(Vector2 dir, Vector2 curvature, float speed) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_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_004b: 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) //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) //IL_0063: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(dir.x, 0f, dir.y); if (((Vector3)(ref forward)).sqrMagnitude < 1E-08f) { forward = Vector3.forward; } Vector3 val = new Vector3(curvature.x, 0f, curvature.y) * (speed * speed); val = Vector3.ClampMagnitude(val, 9.81f * Mathf.Tan(0.6981317f)); return Quaternion.LookRotation(forward, Vector3.up * 9.81f + val); } private Vector2 RootXZ(BomberCircle circle) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!circle.Home) { return circle.Target - _bayOffset; } return HomeRootXZ(); } private Vector2 HomeRootXZ() { //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) return XZ(_basePosition); } private Vector3 HomeAnchor() { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector2 val = HomeRootXZ() + _bayOffset; return new Vector3(val.x, _basePosition.y, val.y); } private void ApplyRoot(Vector2 xz) { //IL_0013: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) if (!_falling && !_holding) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(xz.x, _basePosition.y + HostSettings.Altitude - _bakedAltitude, xz.y); if (((Component)this).transform.position != val) { ((Component)this).transform.position = val; } } } private static Vector2 XZ(Vector3 v) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(v.x, v.z); } private void HostTickQueue(double now) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if ((TrackedReference)(object)_lap == (TrackedReference)null) { return; } if (InLeg(_plan, now) && AirRaidQueue.Active == null) { if (AirRaidQueue.TryActivate(RaidIsland.CanFly, out var entry)) { PlanLeg(now, entry.Home, entry.Target, queued: true); } else if (!_plan.Home && !_plan.Done) { HostSettings.SetRaidPlan(_plan.AsDone().Serialize()); } } else { if ((!_plan.IsBaked && now < _plan.TArrive) || Busy || AirRaidQueue.Owed || ((!_kit || !_circle.Home) && NextDropAfter(now) - now < 3.5)) { return; } if (AirRaidQueue.TryActivate(RaidIsland.CanFly, out var entry2)) { PlanLeg(now, entry2.Home, entry2.Target, queued: true); } else if (_kit) { if (!_plan.IsBaked && !_plan.Done) { HostSettings.SetRaidPlan(_plan.AsDone().Serialize()); } } else if (!_circle.Home || !_circle.Natural) { PlanLeg(now, home: true, Vector2.zero, queued: false); } } } private void HostTickRaidCompletion() { if (_raidId == 0) { return; } if ((Object)(object)_raidTarget != (Object)null) { if (_raidTarget.Detonated) { AirRaidQueue.Complete(_raidId); _raidId = 0; _raidTarget = null; } else if (Time.time >= _raidDeadline) { AirRaidQueue.ReleaseActive("its bomb never went off"); _raidId = 0; _raidTarget = null; } } else if (!_falling && !_holding) { AirRaidQueue.ReleaseActive("its bomb was lost"); _raidId = 0; } } private void PlanLeg(double now, bool home, Vector2 target, bool queued) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) double num = now + 3.0; Vector2 pos; Vector2 dir; float num2; if (InLeg(_plan, num)) { SampleLeg(_plan, num, out pos, out dir, out var _, out var speed); num2 = _lapPerimeter / Mathf.Max(0.001f, speed); } else { BomberCircle destination = _plan.Destination; SampleCircle(destination, num, out pos, out dir); num2 = (float)CircleLap(destination); } float num3 = 0f; float num4 = 0f; if (queued) { num4 = (float)Math.Max(Config.Bomber.QueuedRaidDelaySeconds.Value, (double)HostSettings.SirenLeadSeconds + 1.0); num3 = num4 / (float)Math.Max(1, (int)Math.Round((double)num4 / LapSeconds(), MidpointRounding.AwayFromZero)); } float num5 = ((num3 > 0f) ? num3 : ((float)LapSeconds())); BomberFlightPlan bomberFlightPlan = new BomberFlightPlan { Seq = _plan.Seq + 1, TStart = num, Home = home, TargetX = target.x, TargetZ = target.y, StartX = pos.x, StartZ = pos.y, StartDirX = dir.x, StartDirZ = dir.y, FromLapSeconds = num2, ToLapSeconds = num5, Lap = num3, Period = num4 }; double val = BuildLeg(bomberFlightPlan).Duration(_lapPerimeter / num2, _lapPerimeter / num5); bomberFlightPlan.TArrive = num + Math.Max(5.0, val); HostSettings.SetRaidPlan(bomberFlightPlan.Serialize()); AirRaidQueue.Owed = queued; } private static double CircleLap(BomberCircle circle) { if (!circle.Natural) { return circle.Lap; } return LapSeconds(); } private static double CirclePeriod(BomberCircle circle) { if (!circle.Natural) { return circle.Period; } return RaidPeriod(); } private void PlaceKitSiren() { //IL_0052: 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) if (_kit && !((Object)(object)_siren == (Object)null) && !_circle.Home) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(_circle.Target.x, 0f, _circle.Target.y); val.y = WaterManager.GetWaterHeight(val) + 12f; ((Component)_siren).transform.position = val; } } private void SampleCircle(BomberCircle circle, double t, out Vector2 pos, out Vector2 dir) { //IL_0026: 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_0056: 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_0060: 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_0070: 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_007d: 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_007f: 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_009c: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_0095: 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) float normalizedTime = _lap.normalizedTime; double num = (t - circle.Epoch) / CircleLap(circle); float num2 = (float)(num - Math.Floor(num)); Vector2 val = XZ(OffsetAt(num2)); Vector2 val2 = XZ(OffsetAt((num2 + 0.002f > 1f) ? (num2 + 0.002f - 1f) : (num2 + 0.002f))); PoseLap(normalizedTime); pos = RootXZ(circle) + val; Vector2 val3 = val2 - val; Vector2 val4; if (!(((Vector2)(ref val3)).sqrMagnitude > 1E-08f)) { val4 = _phase0Dir; } else { val3 = val2 - val; val4 = ((Vector2)(ref val3)).normalized; } dir = val4; } private void TickSchedule(double now) { _scheduleHalted = false; double num = CirclePeriod(_circle); double num2 = HostSettings.SirenLeadSeconds; double num3 = DropTime(_nextRaid) - now; if (_nextRaid < 0 || num3 < -5.0 || num3 > num + num2) { _nextRaid = FirstRaidIndex(now + num2); _sirenStarted = false; } double num4 = DropTime(_nextRaid); if (!_sirenStarted && now >= num4 - num2) { _sirenStarted = true; StartSiren(); } if (now >= num4) { _nextRaid++; _sirenStarted = false; ReleaseBomb(); } } private void HaltSchedule() { if (!_scheduleHalted) { _scheduleHalted = true; _nextRaid = -1L; _sirenStarted = false; if ((Object)(object)_siren != (Object)null && _siren.isPlaying) { _siren.Stop(); } } } private double DropTime(long index) { return _circle.Epoch + (double)index * CirclePeriod(_circle); } private long FirstRaidIndex(double after) { return Math.Max(1L, (long)Math.Ceiling((after - _circle.Epoch) / CirclePeriod(_circle))); } private double NextDropAfter(double now) { return DropTime(FirstRaidIndex(now)); } private void StartSiren() { if ((Object)(object)_siren != (Object)null && (Object)(object)_siren.clip != (Object)null) { _siren.volume = Config.Bomber.SirenVolume.Value; _siren.Play(); } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Bomber] Air raid siren! ABomb drops in {HostSettings.SirenLeadSeconds:F0}s."); } if (HostSettings.KillGreenery) { IslandFoliage.Prepare(); } if (IsHost() && _circle.Home) { HomeTarget()?.EnsureBombForRaid(); } } private void ReleaseBomb() { //IL_0057: 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) //IL_0063: 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_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_0073: 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) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00df: 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_00fd: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: 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_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) if (_falling || _holding) { ResetBomb(); } DisposeImpactPoint(); if (IsHost()) { _raidId = ((AirRaidQueue.Owed && AirRaidQueue.Active != null) ? AirRaidQueue.Active.Id : 0); _raidTarget = null; AirRaidQueue.Owed = false; } Vector3 position = _bomb.position; Quaternion rotation = _bomb.rotation; Bounds val = BombBounds(); Vector3 center = ((Bounds)(ref val)).center; if (_circle.Home) { _fallTarget = HomeTarget(); MeasureTarget(_fallTarget); if ((Object)(object)_fallTarget != (Object)null && (Object)(object)_fallTarget == (Object)(object)_measuredTarget) { Bounds targetBounds = _targetBounds; position.x += ((Bounds)(ref targetBounds)).center.x - center.x; position.z += ((Bounds)(ref targetBounds)).center.z - center.z; _impactY = ((Bounds)(ref targetBounds)).max.y; } else { _impactY = WaterManager.GetWaterHeight(position); } } else { Vector2 target = _circle.Target; position.x += target.x - center.x; position.z += target.y - center.z; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(target.x, position.y, target.y); _impactY = WaterManager.GetWaterHeight(val2); Vector3 position2 = default(Vector3); ((Vector3)(ref position2))..ctor(target.x, _impactY - 0.5f, target.y); bool killsGreenery = RaidIsland.Contains(target); _impact = FatManBombTarget.CreateImpactPoint(_impactParent, position2, killsGreenery); _impactDisposeAt = Time.time + 30f; _fallTarget = _impact; } _releaseActivationCount = (((Object)(object)_fallTarget != (Object)null) ? _fallTarget.ActivationCount : 0); _activationSeenAt = -1f; _bomb.SetParent(((Component)this).transform, true); _bomb.SetPositionAndRotation(position, rotation); SetBombVisible(visible: true); _rig = ((Component)_bomb).GetComponent(); if ((Object)(object)_rig == (Object)null) { _rig = ((Component)_bomb).gameObject.AddComponent(); } _rig.isKinematic = false; _rig.useGravity = true; _rig.interpolation = (RigidbodyInterpolation)1; _rig.linearDamping = 0f; _rig.angularDamping = 0f; _rig.linearVelocity = Vector3.zero; _rig.angularVelocity = Vector3.zero; Vector3 val3 = rotation * Vector3.left; _fallStartRot = rotation; _noseDownRot = Quaternion.FromToRotation(val3, Vector3.down) * rotation; _fallStartTime = Time.time; _falling = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Bomber] ABomb released at {position} (impact at y={_impactY:F1})."); } } private void FixedUpdate() { //IL_0036: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (_falling && !((Object)(object)_rig == (Object)null)) { float num = Mathf.Clamp01((Time.time - _fallStartTime) / 3f); _rig.MoveRotation(Quaternion.Slerp(_fallStartRot, _noseDownRot, Mathf.SmoothStep(0f, 1f, num))); } } private void TickFall() { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) Bounds val = BombBounds(); if (((Bounds)(ref val)).min.y <= _impactY) { OnImpact(); } else if (_bomb.position.y < _impactY - 100f) { ResetBomb(); } } private void OnImpact() { //IL_00ba: 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) if (IsHost()) { string text = (_circle.Home ? "the FatManBomb" : "the water"); if ((Object)(object)_fallTarget != (Object)null && _fallTarget.TryDetonate(null)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Bomber] ABomb hit " + text + "; detonating.")); } _raidTarget = _fallTarget; _raidDeadline = Time.time + 30f; } else { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[Bomber] ABomb hit " + text + " but there was nothing armed to detonate.")); } } } _falling = false; if ((Object)(object)_rig != (Object)null) { _rig.linearVelocity = Vector3.zero; _rig.angularVelocity = Vector3.zero; _rig.isKinematic = true; _rig.useGravity = false; } _holding = true; _holdDeadline = Time.time + 2f; TickHold(); } private void TickHold() { float num = Config.FatManBomb.FlashDurationSeconds.Value * 0.5f; if ((_activationSeenAt >= 0f) ? (Time.time >= _activationSeenAt + num) : (Time.time >= _holdDeadline)) { ResetBomb(); } } private void ResetBomb() { //IL_008b: 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_002d: 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) _falling = false; _holding = false; _activationSeenAt = -1f; if ((Object)(object)_rig != (Object)null) { _rig.linearVelocity = Vector3.zero; _rig.angularVelocity = Vector3.zero; _rig.isKinematic = true; _rig.useGravity = false; _rig.interpolation = (RigidbodyInterpolation)0; } SetBombVisible(visible: false); _bomb.SetParent(_plane, false); _bomb.localPosition = _bayLocalPos; _bomb.localRotation = _bayLocalRot; SetBombVisible(visible: true); } private void TickImpactPoint() { if (!((Object)(object)_impact == (Object)null) && (_impact.Detonated || Time.time >= _impactDisposeAt)) { DisposeImpactPoint(); } } private void DisposeImpactPoint() { if ((Object)(object)_impact != (Object)null) { _impact.DisposeImpactPoint(); } _impact = null; } private void SetBombVisible(bool visible) { Renderer[] bombRenderers = _bombRenderers; foreach (Renderer val in bombRenderers) { if ((Object)(object)val != (Object)null) { val.enabled = visible; } } } private Bounds BombBounds() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Encapsulate(_bombRenderers, _bomb.position, out var bounds); return bounds; } private static bool TryGetBounds(Transform root, out Bounds bounds) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Encapsulate(((Component)root).GetComponentsInChildren(true), root.position, out bounds); } private static bool Encapsulate(Renderer[] renderers, Vector3 fallback, out Bounds bounds) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) bounds = new Bounds(fallback, Vector3.zero); bool flag = false; foreach (Renderer val in renderers) { if ((Object)(object)val == (Object)null) { continue; } Bounds bounds2 = val.bounds; if (!(((Bounds)(ref bounds2)).size == Vector3.zero)) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return flag; } private void MeasureTarget(FatManBombTarget target) { //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) if (!((Object)(object)target == (Object)null) && !((Object)(object)target == (Object)(object)_measuredTarget) && TryGetBounds(((Component)target).transform, out var bounds)) { _measuredTarget = target; _targetBounds = bounds; } } private FatManBombTarget HomeTarget() { if ((Object)(object)_homeTarget == (Object)null) { _homeTarget = FindHomeTarget(); } return _homeTarget; } private FatManBombTarget FindHomeTarget() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_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) FatManBombTarget result = null; float num = float.MaxValue; Vector3 val = HomeAnchor(); FatManBombTarget[] array = Object.FindObjectsByType((FindObjectsInactive)0); foreach (FatManBombTarget fatManBombTarget in array) { if (!fatManBombTarget.IsImpactPoint) { Vector3 val2 = ((Component)fatManBombTarget).transform.position - val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < num) { num = ((Vector3)(ref val2)).sqrMagnitude; result = fatManBombTarget; } } } return result; } private void HideManeuvers() { //IL_0034: 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_003c: 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_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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_0137: Unknown result type (might be due to invalid IL or missing references) //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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; if ((Object)(object)_fade == (Object)null || deltaTime <= 0f) { return; } Vector3 val = default(Vector3); Quaternion val2 = default(Quaternion); _plane.GetPositionAndRotation(ref val, ref val2); bool flag = !_tracked || (Vector3.Distance(val, _lastPos + _vel * deltaTime) < 8f && Quaternion.Angle(_lastRot, val2) < 35f * deltaTime); _smoothFor = (flag ? (_smoothFor + deltaTime) : 0f); if (!flag && !_ghost && !_hidden && _fade.Alpha > 0f) { _ghost = true; _ghostPos = _lastPos; _ghostRot = _lastRot; _ghostVel = _vel; _fade.FadeOut(2f, delegate { _ghost = false; _hidden = true; }); } else if (_hidden && _smoothFor >= 5f) { _hidden = false; _fade.FadeIn(2f, 0f); } if (flag && _tracked) { _vel = (val - _lastPos) / deltaTime; } _lastPos = val; _lastRot = val2; _tracked = true; if (_ghost) { _ghostPos += _ghostVel * deltaTime; _plane.SetPositionAndRotation(_ghostPos, _ghostRot); } } private void LateUpdate() { if ((Object)(object)_bomb != (Object)null && _shownEnabled == 1) { HideManeuvers(); } if ((Object)(object)_bomb == (Object)null || _shownEnabled != 1 || !InHudZone()) { _hud?.FadeOut(); return; } double num = NetTime(); bool flag = !_plan.IsBaked && num < _plan.TArrive && !_falling && !_holding; bool flag2 = flag && !_plan.Home && !_plan.Done; if (!flag2 && (flag || _nextRaid < 0)) { _hud?.FadeOut(); return; } if (_hud == null) { _hud = new BombTimerHud(); } if (flag2) { _hud.Show("Bomber in bound", 0f, 1f); return; } double num2 = HostSettings.SirenLeadSeconds; double num3 = Math.Max(0.0, DropTime(_nextRaid) - num); float num4 = ((num2 > 0.0) ? Mathf.Clamp01((float)((num2 + 1.0 - num3) / 1.0)) : 0f); int num5; if (!_falling) { num5 = (_holding ? 1 : 0); if (num5 == 0) { goto IL_016a; } } else { num5 = 1; } num4 = 1f; goto IL_016a; IL_016a: float scale = Mathf.Lerp(1f, 1.25f, Mathf.SmoothStep(0f, 1f, num4)); string text; if (num5 != 0) { text = "BOMB INCOMING"; } else { int num6 = (int)Math.Ceiling(num3); if (num6 != _hudSeconds || _hudText == null) { _hudSeconds = num6; _hudText = $"Next bomb {num6 / 60}:{num6 % 60:00}"; } text = _hudText; } _hud.Show(text, num4, scale); } private bool InHudZone() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!SceneUtil.TryGetLocalPosition(out var position)) { return !_kit; } if (WithinHudZone(HomeAnchor(), position)) { return true; } BomberCircle destination = _plan.Destination; if (destination.Home) { return false; } return WithinHudZone(new Vector3(destination.Target.x, 0f, destination.Target.y), position); } private static bool WithinHudZone(Vector3 centre, Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos - centre; val.y = 0f; return ((Vector3)(ref val)).sqrMagnitude <= 57600f; } private void OnDisable() { _hud?.Hide(); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } _hud?.Dispose(); _hud = null; } private static bool IsHost() { if ((Object)(object)Server.Instance != (Object)null) { return ((NetworkBehaviour)Server.Instance).IsServerInitialized; } return false; } private static double LapSeconds() { return Math.Max(1.0, HostSettings.LapSeconds); } private static double RaidPeriod() { double num = LapSeconds(); double num2 = Math.Max(HostSettings.RaidIntervalSeconds, (double)HostSettings.SirenLeadSeconds + 1.0); return Math.Max(1.0, Math.Ceiling(num2 / num)) * num; } internal static double NetTime() { TimeManager timeManager = InstanceFinder.TimeManager; if ((Object)(object)timeManager == (Object)null || timeManager.Tick == 0) { return Time.timeAsDouble; } return ((double)timeManager.Tick + timeManager.GetTickPercentAsDouble()) * timeManager.TickDelta; } } internal sealed class BomberFade : MonoBehaviour { private static readonly int BaseColor = Shader.PropertyToID("_BaseColor"); private Renderer[] _renderers; private Material[][] _originals; private Material _fade; private Color _color; private Coroutine _running; private float _alpha; public float Alpha => _alpha; public void Init(Material fadeTemplate, bool visible) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) _alpha = (visible ? 1f : 0f); _renderers = ((Component)this).GetComponentsInChildren(true); _originals = new Material[_renderers.Length][]; for (int i = 0; i < _renderers.Length; i++) { _originals[i] = _renderers[i].sharedMaterials; } if (!((Object)(object)fadeTemplate == (Object)null)) { _fade = new Material(fadeTemplate); _color = (_fade.HasProperty(BaseColor) ? _fade.GetColor(BaseColor) : Color.black); } } public void FadeIn(float seconds, float delay) { Run(1f, seconds, delay, null); } public void FadeOut(float seconds, Action done) { Run(0f, seconds, 0f, done); } private void Run(float to, float seconds, float delay, Action done) { if (_running != null) { ((MonoBehaviour)this).StopCoroutine(_running); } if ((Object)(object)_fade == (Object)null) { done?.Invoke(); } else { _running = ((MonoBehaviour)this).StartCoroutine(Fade(to, seconds, delay, done)); } } private IEnumerator Fade(float to, float seconds, float delay, Action done) { UseFadeMaterial(on: true); SetAlpha(_alpha); if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } float from = _alpha; float t = 0f; while (t < seconds) { t += Time.deltaTime; SetAlpha(Mathf.Lerp(from, to, Mathf.SmoothStep(0f, 1f, t / seconds))); yield return null; } SetAlpha(to); if (to >= 1f) { UseFadeMaterial(on: false); } _running = null; done?.Invoke(); } private void SetAlpha(float a) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) _alpha = a; _color.a = a; _fade.SetColor(BaseColor, _color); } private void UseFadeMaterial(bool on) { for (int i = 0; i < _renderers.Length; i++) { Renderer val = _renderers[i]; if ((Object)(object)val == (Object)null) { continue; } if (!on) { val.sharedMaterials = _originals[i]; continue; } Material[] array = (Material[])(object)new Material[_originals[i].Length]; for (int j = 0; j < array.Length; j++) { array[j] = _fade; } val.sharedMaterials = array; } } private void OnDestroy() { if ((Object)(object)_fade != (Object)null) { Object.Destroy((Object)(object)_fade); } } } internal sealed class BomberFlightPlan { private const char Separator = ','; private const int FieldCount = 15; public static readonly BomberFlightPlan Baked = new BomberFlightPlan { Home = true }; public int Seq; public double TStart; public double TArrive; public bool Home; public float TargetX; public float TargetZ; public float StartX; public float StartZ; public float StartDirX; public float StartDirZ; public float FromLapSeconds; public float ToLapSeconds; public float Lap; public float Period; public bool Done; public bool IsBaked => Seq == 0; public Vector2 Target => new Vector2(TargetX, TargetZ); public Vector2 StartPos => new Vector2(StartX, StartZ); public Vector2 StartDir => new Vector2(StartDirX, StartDirZ); public BomberCircle Destination { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!IsBaked) { return new BomberCircle(Home, Target, TArrive, Lap, Period); } return BomberCircle.BakedHome; } } public bool SettledHome(double now) { if (!IsBaked && !Done) { if (Home && Lap <= 0f) { return now >= TArrive; } return false; } return true; } public BomberFlightPlan AsDone() { BomberFlightPlan obj = (BomberFlightPlan)MemberwiseClone(); obj.Seq = Seq + 1; obj.Done = true; return obj; } public string Serialize() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Seq.ToString(CultureInfo.InvariantCulture)).Append(','); stringBuilder.Append(TStart.ToString("R", CultureInfo.InvariantCulture)).Append(','); stringBuilder.Append(TArrive.ToString("R", CultureInfo.InvariantCulture)).Append(','); stringBuilder.Append(Home ? '1' : '0'); float[] array = new float[11] { TargetX, TargetZ, StartX, StartZ, StartDirX, StartDirZ, FromLapSeconds, ToLapSeconds, Lap, Period, Done ? 1f : 0f }; foreach (float num in array) { stringBuilder.Append(',').Append(num.ToString("R", CultureInfo.InvariantCulture)); } return stringBuilder.ToString(); } public static BomberFlightPlan Parse(string raw) { if (string.IsNullOrEmpty(raw)) { return null; } string[] array = raw.Split(','); if (array.Length != 15) { return null; } BomberFlightPlan bomberFlightPlan = new BomberFlightPlan(); if (!int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out bomberFlightPlan.Seq)) { return null; } if (!TryDouble(array[1], out bomberFlightPlan.TStart) || !TryDouble(array[2], out bomberFlightPlan.TArrive)) { return null; } bomberFlightPlan.Home = array[3] == "1"; float[] array2 = new float[11]; for (int i = 0; i < array2.Length; i++) { if (!float.TryParse(array[i + 4], NumberStyles.Float, CultureInfo.InvariantCulture, out array2[i])) { return null; } } bomberFlightPlan.TargetX = array2[0]; bomberFlightPlan.TargetZ = array2[1]; bomberFlightPlan.StartX = array2[2]; bomberFlightPlan.StartZ = array2[3]; bomberFlightPlan.StartDirX = array2[4]; bomberFlightPlan.StartDirZ = array2[5]; bomberFlightPlan.FromLapSeconds = array2[6]; bomberFlightPlan.ToLapSeconds = array2[7]; bomberFlightPlan.Lap = array2[8]; bomberFlightPlan.Period = array2[9]; bomberFlightPlan.Done = array2[10] != 0f; return bomberFlightPlan; } private static bool TryDouble(string s, out double v) { return double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v); } } internal readonly struct BomberCircle { public static readonly BomberCircle BakedHome = new BomberCircle(home: true, Vector2.zero, 0.0, 0f, 0f); public readonly bool Home; public readonly Vector2 Target; public readonly double Epoch; public readonly float Lap; public readonly float Period; public bool Natural => Lap <= 0f; public BomberCircle(bool home, Vector2 target, double epoch, float lap, float period) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Home = home; Target = target; Epoch = epoch; Lap = lap; Period = period; } public bool SameAs(BomberCircle other) { //IL_0041: 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) if (Home == other.Home && Epoch == other.Epoch && Lap == other.Lap && Period == other.Period) { if (!Home) { return Target == other.Target; } return true; } return false; } } internal sealed class FlightLeg { private const int Samples = 128; private const float HandleFraction = 0.4f; private readonly Vector2 _p0; private readonly Vector2 _p1; private readonly Vector2 _p2; private readonly Vector2 _p3; private readonly float[] _arc = new float[129]; public float Length { get; } public FlightLeg(Vector2 from, Vector2 fromDir, Vector2 to, Vector2 toDir, float minHandle) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_002d: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0057: 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) //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_006c: 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_0079: 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_008c: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) float num = Mathf.Max(Vector2.Distance(from, to) * 0.4f, minHandle); _p0 = from; _p1 = from + SafeNormal(fromDir, to - from) * num; _p2 = to - SafeNormal(toDir, to - from) * num; _p3 = to; Vector2 val = _p0; for (int i = 1; i <= 128; i++) { Vector2 val2 = Point((float)i / 128f); _arc[i] = _arc[i - 1] + Vector2.Distance(val, val2); val = val2; } Length = _arc[128]; } public double Duration(double fromSpeed, double toSpeed) { return 2.0 * (double)Length / Math.Max(1.0, fromSpeed + toSpeed); } public static float DistanceFraction(float tau, float fromLap, float toLap, out float speedScale) { tau = Mathf.Clamp01(tau); float num = 1f / Mathf.Max(0.001f, fromLap); float num2 = 1f / Mathf.Max(0.001f, toLap); float num3 = num + num2; speedScale = (num + (num2 - num) * tau) / (0.5f * num3); return (2f * num * tau + (num2 - num) * tau * tau) / num3; } public void Sample(float u, out Vector2 pos, out Vector2 dir, out Vector2 curvature) { //IL_0017: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0070: 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_007c: 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_0085: 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_0094: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: 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) float t = ParamAtDistance(Mathf.Clamp01(u) * Length); pos = Point(t); Vector2 val = FirstDerivative(t); Vector2 val2 = SecondDerivative(t); float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < 0.0001f) { dir = SafeNormal(_p3 - _p0, Vector2.right); curvature = Vector2.zero; } else { dir = val / magnitude; Vector2 val3 = val2 - dir * Vector2.Dot(val2, dir); curvature = val3 / (magnitude * magnitude); } } private float ParamAtDistance(float s) { if (s <= 0f) { return 0f; } if (s >= Length) { return 1f; } int num = 0; int num2 = 128; while (num2 - num > 1) { int num3 = (num + num2) / 2; if (_arc[num3] < s) { num = num3; } else { num2 = num3; } } float num4 = _arc[num2] - _arc[num]; float num5 = ((num4 > 1E-06f) ? ((s - _arc[num]) / num4) : 0f); return ((float)num + num5) / 128f; } private Vector2 Point(float t) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0049: 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) float num = 1f - t; return num * num * num * _p0 + 3f * num * num * t * _p1 + 3f * num * t * t * _p2 + t * t * t * _p3; } private Vector2 FirstDerivative(float t) { //IL_0012: 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_001d: 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_0031: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_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_006a: Unknown result type (might be due to invalid IL or missing references) float num = 1f - t; return 3f * num * num * (_p1 - _p0) + 6f * num * t * (_p2 - _p1) + 3f * t * t * (_p3 - _p2); } private Vector2 SecondDerivative(float t) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_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_0055: 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_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_006a: Unknown result type (might be due to invalid IL or missing references) return 6f * (1f - t) * (_p2 - 2f * _p1 + _p0) + 6f * t * (_p3 - 2f * _p2 + _p1); } private static Vector2 SafeNormal(Vector2 v, Vector2 fallback) { //IL_0010: 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_0024: Unknown result type (might be due to invalid IL or missing references) if (((Vector2)(ref v)).sqrMagnitude > 1E-08f) { return ((Vector2)(ref v)).normalized; } if (!(((Vector2)(ref fallback)).sqrMagnitude > 1E-08f)) { return Vector2.right; } return ((Vector2)(ref fallback)).normalized; } } internal sealed class BombTimerHud : IDisposable { private const string FontAssetName = "Latin_BD_Underdog"; private const string FontMaterialName = "Underdog-Regular Atlas Material"; private const string PanelMaterialName = "UIBlur"; private const string PanelSpriteName = "Ui"; private const float BaseWidth = 300f; private const float BaseHeight = 56f; private const float TopMargin = 22f; private const float BaseFontSize = 32f; private const float FadeSeconds = 0.6f; private static readonly Color WarnColor = new Color(1f, 0.32f, 0.26f); private readonly GameObject _root; private readonly CanvasGroup _group; private readonly RectTransform _panel; private readonly TextMeshProUGUI _label; private string _lastText; public BombTimerHud() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0057: 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_00b2: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01e9: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("BoomLagoon_BombTimerHud"); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 50; CanvasScaler obj2 = _root.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 1f; _group = _root.AddComponent(); _group.interactable = false; _group.blocksRaycasts = false; GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(_root.transform, false); _panel = (RectTransform)val.transform; RectTransform panel = _panel; RectTransform panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(0.5f, 1f); _panel.anchoredPosition = new Vector2(0f, -22f); _panel.sizeDelta = new Vector2(300f, 56f); Image val3 = val.AddComponent(); ((Graphic)val3).raycastTarget = false; Sprite val4 = Find("Ui"); Material val5 = Find("UIBlur"); if ((Object)(object)val4 != (Object)null) { val3.sprite = val4; val3.type = (Type)1; val3.pixelsPerUnitMultiplier = 4f; } if ((Object)(object)val5 != (Object)null) { ((Graphic)val3).material = val5; } else { ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.45f); } GameObject val6 = new GameObject("Label", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent(val.transform, false); RectTransform val7 = (RectTransform)val6.transform; val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val2 = (val7.offsetMin = (val7.offsetMax = Vector2.zero)); _label = val6.AddComponent(); ((Graphic)_label).raycastTarget = false; ((TMP_Text)_label).alignment = (TextAlignmentOptions)514; ((TMP_Text)_label).enableWordWrapping = false; ((TMP_Text)_label).fontSize = 32f; TMP_FontAsset val9 = Find("Latin_BD_Underdog"); if ((Object)(object)val9 != (Object)null) { ((TMP_Text)_label).font = val9; Material val10 = Find("Underdog-Regular Atlas Material"); if ((Object)(object)val10 != (Object)null) { ((TMP_Text)_label).fontSharedMaterial = val10; } } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Bomber] Timer HUD: font=" + (((Object)(object)val9 != (Object)null) ? ((Object)val9).name : "TMP default") + ", panel=" + (((Object)(object)val5 != (Object)null) ? "UIBlur" : "flat") + ", sprite=" + (((Object)(object)val4 != (Object)null) ? "Ui" : "none") + ".")); } _root.SetActive(false); } public void Show(string text, float warn, float scale) { //IL_008a: 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_0095: 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) if (!((Object)(object)_root == (Object)null)) { if (!_root.activeSelf) { _group.alpha = 0f; _root.SetActive(true); } _group.alpha = Mathf.MoveTowards(_group.alpha, 1f, Time.unscaledDeltaTime / 0.6f); if (text != _lastText) { ((TMP_Text)_label).text = text; _lastText = text; } ((Graphic)_label).color = Color.Lerp(Color.white, WarnColor, warn); ((Transform)_panel).localScale = new Vector3(scale, scale, 1f); } } public void FadeOut() { if (!((Object)(object)_root == (Object)null) && _root.activeSelf) { _group.alpha = Mathf.MoveTowards(_group.alpha, 0f, Time.unscaledDeltaTime / 0.6f); if (_group.alpha <= 0f) { _root.SetActive(false); } } } public void Hide() { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } } public void Dispose() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } private static T Find(string name) where T : Object { try { return Array.Find(Resources.FindObjectsOfTypeAll(), (T o) => ((Object)o).name == name); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Bomber] Timer HUD: looking up " + typeof(T).Name + " '" + name + "' threw: " + ex.Message)); } return default(T); } } } [HarmonyPatch(typeof(ExplosionManager), "ServerExplode")] internal static class FatManBombExplosionPatch { private const int DynDamage = 100; private const float DynDamageRadius = 3.5f; private const float DynForceRadius = 2.5f; private const float DynItemForce = 1000f; private const float DynBoatForce = 1000f; private const float DynPlayerForce = 50f; private const float DynScreenShake = 1000f; private static readonly FieldInfo FiDamage = AccessTools.Field(typeof(ExplosionInfo), "_damage"); private static readonly FieldInfo FiDamageRadius = AccessTools.Field(typeof(ExplosionInfo), "damageRadius"); private static readonly FieldInfo FiForceRadius = AccessTools.Field(typeof(ExplosionInfo), "_forceRadius"); private static readonly FieldInfo FiItemForce = AccessTools.Field(typeof(ExplosionInfo), "_itemForce"); private static readonly FieldInfo FiBoatForce = AccessTools.Field(typeof(ExplosionInfo), "_boatForce"); private static readonly FieldInfo FiPlayerForce = AccessTools.Field(typeof(ExplosionInfo), "_playerForce"); private static readonly FieldInfo FiScreenShake = AccessTools.Field(typeof(ExplosionInfo), "_screenShakeAmount"); private static readonly FieldInfo FiFishMinMax = AccessTools.Field(typeof(ExplosionInfo), "_underwaterFishMinMax"); private static readonly FieldInfo FiHasUnderwater = AccessTools.Field(typeof(ExplosionInfo), "_hasUnderwaterExplosion"); private static readonly FieldInfo FiOnlyOnce = AccessTools.Field(typeof(ExplosionInfo), "_onlyExplodeOnce"); private static readonly FieldInfo FiFlyingBirds = AccessTools.Field(typeof(BirdManager), "_flyingBirds"); private static readonly FieldInfo FiItemRenderers = AccessTools.Field(typeof(Item), "_renderers"); private static bool _cookCreaturesKilledDuringExplosion; private static bool _serverExplodeIsFatManBomb; private static Vector3 _blastCenter; internal static bool CookCreaturesKilledDuringExplosion => _cookCreaturesKilledDuringExplosion; internal static bool InFatManBombBlast => _serverExplodeIsFatManBomb; private static void Prefix(Item item, ExplosionInfo info) { //IL_0019: 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_0074: 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_00b3: Unknown result type (might be due to invalid IL or missing references) _serverExplodeIsFatManBomb = IsFatManBomb(item); if (!_serverExplodeIsFatManBomb) { return; } _blastCenter = ((Component)item).transform.position; if (info != null) { ApplyBlastScaling(info, Config.FatManBomb.BlastMultiplier.Value); int num = CapDeadFishSpawn(Config.FatManBomb.SpawnDeadFishCount.Value); bool flag = num > 0; FiHasUnderwater?.SetValue(info, flag); if (flag) { FiFishMinMax?.SetValue(info, (object)new Vector2Int(num, num)); } _cookCreaturesKilledDuringExplosion = flag && Config.FatManBomb.BlastCooksAll.Value; float waterHeight = WaterManager.GetWaterHeight(((Component)item).transform.position); if (flag && waterHeight > ((Component)item).transform.position.y) { ApplyPlayerBlast(item, info); } } } internal static void ApplyBlastScaling(ExplosionInfo info, float m) { SetInt(FiDamage, info, Mathf.RoundToInt(100f * m)); SetFloat(FiDamageRadius, info, 3.5f * m); SetFloat(FiForceRadius, info, 2.5f * m); SetFloat(FiItemForce, info, 1000f * m); SetFloat(FiBoatForce, info, 1000f * m); SetFloat(FiPlayerForce, info, 50f * m); SetFloat(FiScreenShake, info, 1000f * m); FiOnlyOnce?.SetValue(info, true); } private static int CapDeadFishSpawn(int requested) { if (requested <= 0) { return 0; } int value = Config.FatManBomb.MaxDeadFishOnMap.Value; int num = 0; Fish[] array = Object.FindObjectsByType((FindObjectsInactive)0); foreach (Fish val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsServerInitialized && ((Creature)val).IsDead) { num++; } } int num2 = Mathf.Clamp(value - num, 0, requested); if (num2 < requested) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[FatManBomb] {num} dead fish already on the map (cap {value}); spawning {num2}/{requested}."); } } return num2; } private static void ApplyPlayerBlast(Item item, ExplosionInfo info) { //IL_0064: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Server.Instance == (Object)null || (Object)(object)item.Rig == (Object)null) { return; } Player val = item.LastPlayer; if ((Object)(object)item.Explosive != (Object)null && (Object)(object)item.Explosive.PlayerWhoForcedExplosion != (Object)null) { val = item.Explosive.PlayerWhoForcedExplosion; } float num = info.DamageRadius * info.DamageRadius; Vector3 worldCenterOfMass = item.Rig.worldCenterOfMass; Collider[] array = Physics.OverlapSphere(((Component)item).transform.position, info.ForceRadius, LayerMask.op_Implicit(GameInfo.AffectedByExplosionLayer)); HashSet hashSet = new HashSet(); Collider[] array2 = array; foreach (Collider val2 in array2) { if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).transform == (Object)(object)((Component)item).transform) { continue; } Player playerFromBodyPart = PlayerManager.GetPlayerFromBodyPart(((Component)val2).transform); if (!((Object)(object)playerFromBodyPart == (Object)null) && !((NetworkBehaviour)playerFromBodyPart).IsDeinitializing) { Vector3 val3 = worldCenterOfMass - ((Component)val2).transform.position; if (!(((Vector3)(ref val3)).sqrMagnitude > num) && hashSet.Add(playerFromBodyPart)) { Vector3 val4 = -((Vector3)(ref val3)).normalized * info.PlayerForce; Server.Instance.HitPlayer(playerFromBodyPart, info.Damage, val4, ((Component)val2).transform.position, (byte)0, val); } } } if (hashSet.Count > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[FatManBomb] Underwater blast hit {hashSet.Count} player(s) that native explosion would have spared."); } } } private static void Finalizer() { _serverExplodeIsFatManBomb = false; } private static void Postfix(Item item) { //IL_0020: 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) if (_serverExplodeIsFatManBomb) { _serverExplodeIsFatManBomb = false; _cookCreaturesKilledDuringExplosion = false; if (Config.FatManBomb.BlastKillAllBirds.Value) { KillAllAirborneBirds(_blastCenter); } if (Config.FatManBomb.BlastCooksAll.Value) { CookAllCreatures(_blastCenter); } } } private static void CookAllCreatures(Vector3 center) { //IL_0034: 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) Creature[] array = Object.FindObjectsByType((FindObjectsInactive)0); float value = Config.FatManBomb.CookedLevel.Value; int num = 0; Creature[] array2 = array; foreach (Creature val in array2) { if (!((Object)(object)val == (Object)null) && ((NetworkBehaviour)val).IsServerInitialized && SceneUtil.WithinZone(center, ((Component)val).transform.position)) { CookCreature(val, value); num++; } } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[FatManBomb] Auto-cooked {num}/{array.Length} creature(s) on the island to cookness {value:0.##}."); } } internal static void CookCreature(Creature creature, float level) { ((Item)creature)._cookness.Value = level; if (FiItemRenderers?.GetValue(creature) is List { Count: >0 } list) { ShaderManager.SetItemCookness(list, level); } } private static bool IsFatManBomb(Item item) { if ((Object)(object)item == (Object)null) { return false; } if (!((NetworkBehaviour)item).IsServerInitialized) { return false; } return string.Equals(SceneUtil.StripClone(((Object)((Component)item).gameObject).name), "FatManBomb", StringComparison.OrdinalIgnoreCase); } private static void KillAllAirborneBirds(Vector3 center) { //IL_0061: 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) BirdManager instance = BirdManager.Instance; if ((Object)(object)instance == (Object)null || FiFlyingBirds == null || !(FiFlyingBirds.GetValue(instance) is List { Count: not 0 } list)) { return; } Bird[] array = list.ToArray(); int num = 0; Bird[] array2 = array; foreach (Bird val in array2) { if (!((Object)(object)val == (Object)null) && !((Creature)val).IsDead && SceneUtil.WithinZone(center, ((Component)val).transform.position)) { ((Creature)val).ServerChangeHp(1073741823); num++; } } if (num > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[FatManBomb] Detonation killed {num} airborne bird(s)."); } } } private static void SetFloat(FieldInfo f, object target, float value) { f?.SetValue(target, value); } private static void SetInt(FieldInfo f, object target, int value) { f?.SetValue(target, value); } } [HarmonyPatch(typeof(Server), "HitPlayer")] internal static class FatManBombShelterPatch { private const float CoverCheckHeight = 25f; private const float KnockbackOutward = 12f; private const float KnockbackUp = 6f; private static bool Prefix(Player player, Vector3 force) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!FatManBombExplosionPatch.InFatManBombBlast) { return true; } if ((Object)(object)player == (Object)null || (Object)(object)player.Vitals == (Object)null || !IsUnderCover(player)) { return true; } player.Vitals.ApplyNewFire(); Knockback(player, force); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[FatManBomb] " + player.SteamName + " was under cover; burned and knocked back instead of blown up.")); } return false; } private static void Knockback(Player player, Vector3 blastForce) { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: 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_0047: 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) if (!((Object)(object)player.Movement == (Object)null) && !(((NetworkBehaviour)player).Owner == (NetworkConnection)null)) { Vector3 val = Vector3.ProjectOnPlane(blastForce, Vector3.up); Vector3 val2 = Vector3.up * 6f; if (((Vector3)(ref val)).sqrMagnitude > 1E-06f) { val2 += ((Vector3)(ref val)).normalized * 12f; } player.Movement.RPCKnockback(((NetworkBehaviour)player).Owner, val2); } } private static bool IsUnderCover(Player player) { //IL_0048: 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_0057: 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) //IL_0061: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Vector3 val; if ((Object)(object)player.Body != (Object)null && (Object)(object)player.Body.Head != (Object)null) { val = player.Body.Head.position; } else { if (!((Object)(object)player.Transform != (Object)null)) { return false; } val = player.Transform.position + Vector3.up * 1.6f; } return Physics.Raycast(val, Vector3.up, 25f, LayerMask.op_Implicit(GameInfo.LevelLayer), (QueryTriggerInteraction)1); } } [HarmonyPatch] internal static class FatManBombClientExplodePatch { private static MethodBase Target() { return AccessTools.Method(typeof(ExplosionManager), "RpcLogic___ObserverExplode___4259294983", (Type[])null, (Type[])null); } private static bool Prepare() { if (Target() != null) { return true; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[FatManBomb] ExplosionManager's explode RPC not found; clients will see dynamite-sized shake/debris."); } return false; } private static MethodBase TargetMethod() { return Target(); } private static void Prefix(Item __0) { if (!HostSettings.IsHost && !((Object)(object)__0 == (Object)null) && FatManBombTarget.IsBombEngine(__0)) { ExplosionInfo explosionInfo = __0.GetExplosionInfo(); if (explosionInfo != null) { FatManBombExplosionPatch.ApplyBlastScaling(explosionInfo, Config.FatManBomb.BlastMultiplier.Value); } } } } [HarmonyPatch] internal static class FatManBombActivateGuardPatch { private static MethodBase Target() { return AccessTools.Method(typeof(Server), "RpcLogic___ActivateExplosive___1390675745", (Type[])null, (Type[])null); } private static bool Prepare() { if (Target() != null) { return true; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[FatManBomb] Server's ActivateExplosive RPC not found; the host can't block client shots on the FatManBomb."); } return false; } private static MethodBase TargetMethod() { return Target(); } private static bool Prefix(Explosive __0) { if ((Object)(object)__0 == (Object)null || HostSettings.ShootToDetonate) { return true; } if (!FatManBombTarget.IsBombEngine((Item)(object)__0)) { return true; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[FatManBomb] Ignored a client's shot on the FatManBomb (ShootToDetonate is off on the host)."); } return false; } } [HarmonyPatch(typeof(Creature), "ServerKillOnSpawn")] internal static class FatManBombCookDeadCreaturePatch { private static void Postfix(Creature __instance) { if (FatManBombExplosionPatch.CookCreaturesKilledDuringExplosion && !((Object)(object)__instance == (Object)null)) { FatManBombExplosionPatch.CookCreature(__instance, Config.FatManBomb.CookedLevel.Value); } } } public class FatManBombManager : LagoonSceneComponent { internal static GameObject[] SceneClouds { get; private set; } = (GameObject[])(object)new GameObject[0]; internal static Item DynamitePrefab { get; private set; } protected override void OnLagoonLoaded(Scene scene) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(Setup(scene)); } private IEnumerator Setup(Scene scene) { //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 null; FatManBombTarget.ResetSceneState(); SceneClouds = (GameObject[])(object)new GameObject[0]; DynamitePrefab = null; FlashbangSound.Preload((MonoBehaviour)(object)this, Config.FatManBomb.FlashbangSoundFile.Value); FlashbangSound.Preload((MonoBehaviour)(object)this, Config.FatManBomb.MassiveExplosionSoundFile.Value); string wanted = "FatManBomb"; int projectileLayer = LayerFromMask(GameInfo.ProjectileHitLayer); List targets = new List(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (NameMatches(((Object)val2).name, wanted) && !((Object)(object)((Component)val2).GetComponent() != (Object)null) && !((Object)(object)((Component)val2).GetComponentInParent() != (Object)null)) { EnsureShootableCollider(((Component)val2).gameObject, projectileLayer); targets.Add(((Component)val2).gameObject.AddComponent()); } } } GameObject[] array = (SceneClouds = FindMushroomClouds(scene)); if (array.Length != 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)string.Format("[FatManBomb] Found {0} mushroom-cloud effect object(s) ('{1}').", array.Length, "MushroomCloud")); } } if (targets.Count > 0) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[FatManBomb] Wired {targets.Count} shootable FatManBomb mesh(es)."); } } foreach (FatManBombTarget item in targets) { if ((Object)(object)item != (Object)null) { item.SetMushroomClouds(array); } } if ((Object)(object)Server.Instance == (Object)null || !((NetworkBehaviour)Server.Instance).IsServerInitialized) { yield break; } yield return (object)new WaitUntil((Func)(() => (Object)(object)ItemManager.Instance != (Object)null)); Item val3 = (DynamitePrefab = LoadDynamitePrefab()); if ((Object)(object)val3 == (Object)null) { yield break; } float fuseSeconds = FatManBombTarget.FuseSeconds(); float value = Config.FatManBomb.RespawnAfterDetonationSeconds.Value; foreach (FatManBombTarget item2 in targets) { if (!((Object)(object)item2 == (Object)null)) { item2.ConfigureForHost(val3, value, fuseSeconds); item2.SpawnBombEngine(); } } } internal static void UseRaidKit(MonoBehaviour host, GameObject cloud) { SceneClouds = (GameObject[])(object)((!((Object)(object)cloud != (Object)null)) ? new GameObject[0] : new GameObject[1] { cloud }); FlashbangSound.Preload(host, Config.FatManBomb.FlashbangSoundFile.Value); FlashbangSound.Preload(host, Config.FatManBomb.MassiveExplosionSoundFile.Value); if (HostSettings.IsHost && (Object)(object)DynamitePrefab == (Object)null) { DynamitePrefab = LoadDynamitePrefab(); } } private static Item LoadDynamitePrefab() { string text = "items/purchasable/Dynamite"; Object obj = Resources.Load(text, typeof(Item)); Item val = (Item)(object)((obj is Item) ? obj : null); if ((Object)(object)val == (Object)null) { GameObject val2 = Resources.Load(text); if ((Object)(object)val2 != (Object)null) { val = val2.GetComponent(); } } if ((Object)(object)val == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[FatManBomb] Resources.Load('" + text + "') as Item returned null; no shootable bombs spawned.")); } return null; } if ((Object)(object)((Component)val).GetComponent() == (Object)null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[FatManBomb] Loaded '" + text + "' but it has no Explosive component -- shooting it may not detonate.")); } } return val; } private static void EnsureShootableCollider(GameObject go, int projectileLayer) { //IL_0090: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0044: 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_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_0060: Unknown result type (might be due to invalid IL or missing references) Collider val = go.GetComponentInChildren(); if ((Object)(object)val == (Object)null) { BoxCollider val2 = go.AddComponent(); MeshFilter component = go.GetComponent(); Vector3 center; Vector3 size; if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { Bounds bounds = component.sharedMesh.bounds; val2.center = ((Bounds)(ref bounds)).center; bounds = component.sharedMesh.bounds; val2.size = ((Bounds)(ref bounds)).size; } else if (TryGetLocalRendererBounds(go.transform, out center, out size)) { val2.center = center; val2.size = size; } else { val2.size = Vector3.one * 2f; } val = (Collider)(object)val2; } val.enabled = true; val.isTrigger = false; if (projectileLayer >= 0) { ((Component)val).gameObject.layer = projectileLayer; } } private static bool TryGetLocalRendererBounds(Transform root, out Vector3 center, out Vector3 size) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0063: 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_0076: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) center = Vector3.zero; size = Vector3.one; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { return false; } Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } center = root.InverseTransformPoint(((Bounds)(ref bounds)).center); Vector3 lossyScale = root.lossyScale; size = new Vector3(((Bounds)(ref bounds)).size.x / Mathf.Max(0.0001f, Mathf.Abs(lossyScale.x)), ((Bounds)(ref bounds)).size.y / Mathf.Max(0.0001f, Mathf.Abs(lossyScale.y)), ((Bounds)(ref bounds)).size.z / Mathf.Max(0.0001f, Mathf.Abs(lossyScale.z))); return true; } private static int LayerFromMask(LayerMask mask) { int value = ((LayerMask)(ref mask)).value; for (int i = 0; i < 32; i++) { if ((value & (1 << i)) != 0) { return i; } } return -1; } private static GameObject[] FindMushroomClouds(Scene scene) { string text = "MushroomCloud"; List list = new List(); if (string.IsNullOrEmpty(text)) { return list.ToArray(); } GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (NameMatches(((Object)val2).name, text)) { list.Add(((Component)val2).gameObject); } } } return list.ToArray(); } internal static bool NameMatches(string objectName, string wanted) { if (string.IsNullOrEmpty(objectName) || string.IsNullOrEmpty(wanted)) { return false; } return string.Equals(SceneUtil.StripClone(objectName), wanted, StringComparison.OrdinalIgnoreCase); } } [DisallowMultipleComponent] public class FatManBombTarget : MonoBehaviour { private static readonly FieldInfo FiIsActivated = AccessTools.Field(typeof(Explosive), "_isActivated"); private static readonly FieldInfo FiForcedDelay = AccessTools.Field(typeof(Explosive), "_forcedExplosionDelay"); private static readonly FieldInfo FiIgnoredByCloseDots = AccessTools.Field(typeof(Item), "_ignoredByCloseDots"); private static readonly List Live = new List(); private Explosive _bomb; private bool _hadBomb; private bool _wasActivated; private bool _lostBombHandled; private Renderer[] _engineRenderers; private Collider[] _engineColliders; private bool _meshHidden; private GameObject[] _clouds; private static readonly Dictionary CloudBakedLocal = new Dictionary(); private bool _isImpactPoint; private bool _killsGreenery = true; private Vector3? _cloudAt; private bool _isHost; private Item _dynamitePrefab; private float _respawnDelay; private float _fuseSeconds; private bool _awaitingRespawn; private float _respawnAt; private bool _diagLogged; private float _nextScanTime; private const float ScanInterval = 0.5f; public int ActivationCount { get; private set; } internal bool IsImpactPoint => _isImpactPoint; internal bool Detonated { get { if (_hadBomb && (Object)(object)_bomb == (Object)null) { return _lostBombHandled; } return false; } } private void OnEnable() { Live.Add(this); } private void OnDisable() { Live.Remove(this); } internal static void ResetSceneState() { CloudBakedLocal.Clear(); } internal static FatManBombTarget CreateImpactPoint(Transform parent, Vector3 position, bool killsGreenery) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ABombImpact"); val.transform.SetParent(parent, false); val.transform.position = position; FatManBombTarget fatManBombTarget = val.AddComponent(); fatManBombTarget._isImpactPoint = true; fatManBombTarget._killsGreenery = killsGreenery; fatManBombTarget._cloudAt = new Vector3(position.x, WaterManager.GetWaterHeight(position), position.z); fatManBombTarget.SetMushroomClouds(FatManBombManager.SceneClouds); if (HostSettings.IsHost) { Item dynamitePrefab = FatManBombManager.DynamitePrefab; fatManBombTarget.ConfigureForHost(dynamitePrefab, -1f, FuseSeconds()); if ((Object)(object)dynamitePrefab == (Object)null || !fatManBombTarget.SpawnBombEngine()) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"[FatManBomb] Couldn't arm the air-raid impact point at {position}; that ABomb will be a dud."); } } } return fatManBombTarget; } internal void DisposeImpactPoint() { if (_isImpactPoint) { if (_isHost && (Object)(object)_bomb != (Object)null && !IsBombActivated(_bomb) && ((NetworkBehaviour)_bomb).IsServerInitialized) { ((NetworkBehaviour)_bomb).Despawn((DespawnType?)null); } Object.Destroy((Object)(object)((Component)this).gameObject); } } internal static bool IsBombEngine(Item item) { if ((Object)(object)item == (Object)null) { return false; } foreach (FatManBombTarget item2 in Live) { if ((Object)(object)item2 != (Object)null && (Object)(object)item2._bomb != (Object)null && (Object)(object)item2._bomb == (Object)(object)item) { return true; } } return false; } public void ConfigureForHost(Item dynamitePrefab, float respawnDelaySeconds, float fuseSeconds) { _isHost = true; _dynamitePrefab = dynamitePrefab; _respawnDelay = respawnDelaySeconds; _fuseSeconds = Mathf.Max(0f, fuseSeconds); } public bool SpawnBombEngine() { //IL_004f: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (!_isHost || (Object)(object)_dynamitePrefab == (Object)null) { return false; } if ((Object)(object)ItemManager.Instance == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[FatManBomb] ItemManager not ready; can't spawn bomb engine."); } return false; } Transform transform = ((Component)this).transform; Item val = ItemManager.Instance.SpawnNewItem(_dynamitePrefab, transform.position, transform.rotation); if ((Object)(object)val == (Object)null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[FatManBomb] SpawnNewItem returned null; that mesh won't be shootable."); } return false; } ((Object)((Component)val).gameObject).name = "FatManBomb"; FiIgnoredByCloseDots?.SetValue(val, true); if ((Object)(object)val.Rig != (Object)null) { val.Rig.isKinematic = true; val.Rig.constraints = (RigidbodyConstraints)126; } Explosive component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)("[FatManBomb] Spawned bomb at '" + ((Object)transform).name + "' has no Explosive; it won't detonate.")); } return false; } FiForcedDelay?.SetValue(component, _fuseSeconds); SetBomb(component); if (!_diagLogged && !_isImpactPoint) { _diagLogged = true; float waterHeight = WaterManager.GetWaterHeight(transform.position); bool flag = transform.position.y < waterHeight - 0.5f; ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogInfo((object)($"[FatManBomb] Spawned hidden bomb engine at '{((Object)transform).name}' pos={transform.position} " + string.Format("(waterHeight={0:F2}, {1}).", waterHeight, flag ? "UNDERWATER - shots die at the surface and can't reach it; raise the mesh to the waterline" : "above/at surface - shootable"))); } } return true; } public void SetMushroomClouds(GameObject[] clouds) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) _clouds = clouds; if (clouds == null) { return; } foreach (GameObject val in clouds) { if ((Object)(object)val != (Object)null && !CloudBakedLocal.ContainsKey(val)) { CloudBakedLocal[val] = val.transform.localPosition; } } } public void SetBomb(Explosive bomb) { if (!((Object)(object)bomb == (Object)null)) { _bomb = bomb; _hadBomb = true; _lostBombHandled = false; _wasActivated = IsBombActivated(bomb); _engineRenderers = ((Component)bomb).GetComponentsInChildren(true); _engineColliders = ((Component)bomb).GetComponentsInChildren(true); ConcealEngine(); } } private void ConcealEngine() { if ((Object)(object)_bomb == (Object)null) { return; } if (_engineRenderers != null) { Renderer[] engineRenderers = _engineRenderers; foreach (Renderer val in engineRenderers) { if ((Object)(object)val != (Object)null && val.enabled) { val.enabled = false; } } } if (_engineColliders != null) { Collider[] engineColliders = _engineColliders; foreach (Collider val2 in engineColliders) { if ((Object)(object)val2 != (Object)null && val2.enabled) { val2.enabled = false; } } } Rigidbody rig = ((Item)_bomb).Rig; if ((Object)(object)rig != (Object)null && !rig.isKinematic) { rig.isKinematic = true; } } private void Update() { if ((Object)(object)_bomb != (Object)null) { ConcealEngine(); if (!_wasActivated && IsBombActivated(_bomb)) { _wasActivated = true; ActivationCount++; if (HostSettings.KillGreenery && _killsGreenery) { IslandFoliage.Prepare(); ((MonoBehaviour)this).StartCoroutine(KillLeafsAfterDelay(Config.FatManBomb.FlashDurationSeconds.Value * 0.5f)); } if (LocalPlayerInZone()) { PlayFlash(); } } EnsureMeshShown(); _awaitingRespawn = false; _lostBombHandled = false; return; } if (_hadBomb && !_lostBombHandled) { _lostBombHandled = true; OnDetonated(); } if (_isImpactPoint && _hadBomb) { return; } if (_isHost) { HostTickRespawn(); } else if (Time.time >= _nextScanTime) { _nextScanTime = Time.time + 0.5f; TryAssociateNearbyBomb(); if ((Object)(object)_bomb != (Object)null) { EnsureMeshShown(); } } } private static void PlayFlash() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) float value = Config.FatManBomb.FlashDurationSeconds.Value; float value2 = Config.FatManBomb.FlashbangRingDurationSeconds.Value; AudioClip val = FlashbangSound.Get(Config.FatManBomb.FlashbangSoundFile.Value); float value3 = Config.FatManBomb.FlashbangRingVolume.Value; float toneVolume = (((Object)(object)val != (Object)null) ? (value3 * Config.FatManBomb.FlashbangToneVolumeScale.Value) : value3); ScreenFlash.Play(Color.white, value, value2, value3, toneVolume, Config.FatManBomb.FlashbangRingFrequency.Value, val); } private bool LocalPlayerInZone() { //IL_0019: 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) if (!SceneUtil.TryGetLocalPosition(out var position)) { return !_isImpactPoint; } return SceneUtil.WithinZone(((Component)this).transform.position, position); } private void HostTickRespawn() { if (!_hadBomb || _respawnDelay < 0f) { return; } if (!_awaitingRespawn) { _awaitingRespawn = true; _respawnAt = Time.time + _respawnDelay; } else { if (Time.time < _respawnAt) { return; } if (SpawnBombEngine() && (Object)(object)_bomb != (Object)null) { _awaitingRespawn = false; EnsureMeshShown(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[FatManBomb] Respawned a FatManBomb after its detonation."); } } else { _respawnAt = Time.time + 5f; } } } private IEnumerator KillLeafsAfterDelay(float delay) { if (delay > 0f) { yield return (object)new WaitForSecondsRealtime(delay); } IslandFoliage.BlowAway(); } private void OnDetonated() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; PlayBlastSound(position); PlayBigFire(position); PlayMushroomCloud(position); SetMeshVisible(visible: false); } private static void PlayBlastSound(Vector3 pos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) OneShotSfx.PlayAt(FlashbangSound.Get(Config.FatManBomb.MassiveExplosionSoundFile.Value), Config.FatManBomb.MassiveExplosionVolume.Value, pos, Config.FatManBomb.MassiveExplosionMinDistance.Value, Config.FatManBomb.MassiveExplosionMaxDistance.Value); } private void PlayMushroomCloud(Vector3 blastPos) { //IL_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_00a5: Unknown result type (might be due to invalid IL or missing references) if (_clouds == null || _clouds.Length == 0) { return; } GameObject val = null; float num = float.MaxValue; GameObject[] clouds = _clouds; foreach (GameObject val2 in clouds) { if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = BakedCloudPosition(val2) - blastPos; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val2; } } } if (!((Object)(object)val == (Object)null)) { Vector3 value; if (_cloudAt.HasValue) { val.transform.position = _cloudAt.Value; } else if (CloudBakedLocal.TryGetValue(val, out value)) { val.transform.localPosition = value; } if (!val.activeSelf) { val.SetActive(true); } ParticleSystem[] componentsInChildren = val.GetComponentsInChildren(true); foreach (ParticleSystem obj in componentsInChildren) { obj.Clear(false); obj.Play(false); } } } private static Vector3 BakedCloudPosition(GameObject cloud) { //IL_0017: 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_0034: 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) Transform transform = cloud.transform; if (!CloudBakedLocal.TryGetValue(cloud, out var value)) { return transform.position; } if (!((Object)(object)transform.parent != (Object)null)) { return value; } return transform.parent.TransformPoint(value); } private static void PlayBigFire(Vector3 pos) { //IL_002f: 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) string text = "LavaExplosion,VolcanoEruption"; if (string.IsNullOrEmpty(text)) { return; } string[] array = text.Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { VFXManager.Play(text2, pos, Vector3.up); } } } private void TryAssociateNearbyBomb() { //IL_003a: 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_004f: Unknown result type (might be due to invalid IL or missing references) float num = 3f * 3f; Explosive val = null; Explosive[] array = Object.FindObjectsByType((FindObjectsInactive)0); foreach (Explosive val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Item)val2).Holder != (Object)null)) { Vector3 val3 = ((Component)val2).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude <= num) { num = sqrMagnitude; val = val2; } } } if ((Object)(object)val != (Object)null) { SetBomb(val); } } private void EnsureMeshShown() { if (_meshHidden) { SetMeshVisible(visible: true); } } private void SetMeshVisible(bool visible) { bool flag = !visible; if (_meshHidden != flag) { _meshHidden = flag; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = visible; } Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = visible; } } } private static bool IsBombActivated(Explosive bomb) { bool flag = default(bool); int num; if (FiIsActivated != null) { object value = FiIsActivated.GetValue(bomb); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } internal static float FuseSeconds() { float num = Config.FatManBomb.FlashDurationSeconds.Value * 0.5f; return Mathf.Max(0f, num + Config.FatManBomb.ExplosionDelayAfterFlashPeak.Value); } public bool TryDetonate(Player shooter) { if ((Object)(object)_bomb == (Object)null) { return false; } _bomb.ForceExplode(shooter, false); return true; } public void EnsureBombForRaid() { if (_isHost && !((Object)(object)_bomb != (Object)null) && SpawnBombEngine() && (Object)(object)_bomb != (Object)null) { _awaitingRespawn = false; EnsureMeshShown(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[FatManBomb] Respawned the FatManBomb early for an incoming air raid."); } } } } [HarmonyPatch(typeof(ProjectileManager), "Hit", new Type[] { typeof(Projectile), typeof(ProjectileType), typeof(RaycastHit) })] internal static class FatManBombHitPatch { private static void Postfix(Projectile __0, RaycastHit __2) { if (!HostSettings.ShootToDetonate || __0 == null || !__0.IsLocal || (Object)(object)((RaycastHit)(ref __2)).collider == (Object)null) { return; } FatManBombTarget componentInParent = ((Component)((RaycastHit)(ref __2)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && componentInParent.TryDetonate(__0.Owner)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[FatManBomb] Shot registered on a FatManBomb mesh; detonating."); } } } } public static class FlashbangSound { private static readonly Dictionary Clips = new Dictionary(StringComparer.Ordinal); private static readonly HashSet Loading = new HashSet(StringComparer.Ordinal); private static readonly HashSet Warned = new HashSet(StringComparer.Ordinal); public static AudioClip Get(string fileNameOrPath) { string text = fileNameOrPath?.Trim() ?? string.Empty; if (text.Length <= 0 || !Clips.TryGetValue(text, out var value)) { return null; } return value; } public static void Preload(MonoBehaviour host, string fileNameOrPath) { if ((Object)(object)host == (Object)null) { return; } string text = fileNameOrPath?.Trim() ?? string.Empty; if (text.Length == 0 || Loading.Contains(text) || Clips.ContainsKey(text)) { return; } string text2 = Resolve(text); if (text2 == null) { if (Warned.Add(text)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[FatManBomb] Sound file '" + text + "' not found in the plugin's Audio/ folder.")); } } } else { Loading.Add(text); host.StartCoroutine(LoadRoutine(text2, text)); } } private static IEnumerator LoadRoutine(string fullPath, string wanted) { string absoluteUri = new Uri(fullPath).AbsoluteUri; AudioType val = GuessType(fullPath); UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, val); try { DownloadHandler downloadHandler = req.downloadHandler; DownloadHandlerAudioClip val2 = (DownloadHandlerAudioClip)(object)((downloadHandler is DownloadHandlerAudioClip) ? downloadHandler : null); if (val2 != null) { val2.streamAudio = false; } yield return req.SendWebRequest(); if ((int)req.result != 1) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[FatManBomb] Failed to load sound '" + fullPath + "': " + req.error + ".")); } } else { AudioClip val3 = null; try { val3 = DownloadHandlerAudioClip.GetContent(req); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[FatManBomb] Decoding sound '" + fullPath + "' failed: " + ex.Message + ".")); } } if ((Object)(object)val3 != (Object)null && (int)val3.loadState == 2) { ((Object)val3).name = "BoomLagoon_" + Path.GetFileNameWithoutExtension(fullPath); Clips[wanted] = val3; ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"[FatManBomb] Loaded sound '{fullPath}' ({val3.length:F2}s)."); } } else { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)("[FatManBomb] Sound '" + fullPath + "' decoded to nothing.")); } } } } finally { ((IDisposable)req)?.Dispose(); } Loading.Remove(wanted); } private static string Resolve(string fileNameOrPath) { if (Path.IsPathRooted(fileNameOrPath)) { if (!File.Exists(fileNameOrPath)) { return null; } return fileNameOrPath; } string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "."; string[] array = new string[2] { Path.Combine(path, "Audio", fileNameOrPath), Path.Combine(path, fileNameOrPath) }; foreach (string text in array) { if (File.Exists(text)) { return text; } } return null; } private static AudioType GuessType(string path) { switch (Path.GetExtension(path).ToLowerInvariant()) { case ".ogg": return (AudioType)14; case ".wav": return (AudioType)20; case ".aif": case ".aiff": return (AudioType)2; default: return (AudioType)13; } } } public static class GameAudio { private static AudioMixerGroup _fx; public static void Route(AudioSource source) { if (!((Object)(object)source == (Object)null)) { AudioMixerGroup val = FxGroup(); if ((Object)(object)val != (Object)null) { source.outputAudioMixerGroup = val; } } } private static AudioMixerGroup FxGroup() { if ((Object)(object)_fx != (Object)null) { return _fx; } AudioMixerGroup val = null; AudioMixerGroup[] array = Resources.FindObjectsOfTypeAll(); foreach (AudioMixerGroup val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name == "FX") { _fx = val2; return _fx; } if ((Object)(object)val == (Object)null && ((Object)val2).name == "Master") { val = val2; } } } if ((Object)(object)val == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[GameAudio] Game FX/Master mixer group not found; BoomLagoon sounds won't follow volume sliders."); } } return val; } } public class IslandFoliage : MonoBehaviour { private sealed class Preparation { public Island Island; public IEnumerator Work; public bool Started; public bool Done; public readonly List Objects = new List(); public readonly List Ground = new List(); public readonly List GroundMaterials = new List(); public readonly List OwnedMaterials = new List(); } private static readonly FieldInfo FiDecorationTypes = AccessTools.Field(typeof(DecorationManager), "_decorationTypes"); private static readonly FieldInfo FiBatchesSplit = AccessTools.Field(typeof(DecorationManager), "_batchesSplit"); private static readonly FieldInfo FiInstanceName = AccessTools.Field(AccessTools.Inner(typeof(DecorationManager), "DecorationType"), "InstanceName"); private static readonly int ColorsId = Shader.PropertyToID("_Colors"); private const float GroundMinSize = 30f; private const int TransformsPerFrame = 400; private static readonly Dictionary ScorchedPalettes = new Dictionary(); private static IslandFoliage _instance; private static Island _bareIsland; private static Island _namedIsland; private static string _islandName; private static Preparation _prep; private void Awake() { _instance = this; } private void Update() { //IL_0036: 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_005b: Unknown result type (might be due to invalid IL or missing references) Island current = RaidIsland.Current; if (!((Object)(object)current == (Object)null) && !((Object)(object)current == (Object)(object)_bareIsland)) { if ((Object)(object)current != (Object)(object)_namedIsland) { _namedIsland = current; Scene scene = ((Component)current).gameObject.scene; _islandName = ((Scene)(ref scene)).name; } if (HostSettings.IsGreeneryKilled(_islandName) && DecorationsSent(((Component)current).gameObject.scene)) { Hide(current); } } } internal static void Prepare() { Island current = RaidIsland.Current; if (!((Object)(object)current == (Object)null) && !((Object)(object)current == (Object)(object)_bareIsland) && !((Object)(object)_instance == (Object)null)) { Preparation preparation = PreparationFor(current); if (!preparation.Done && !preparation.Started) { preparation.Started = true; ((MonoBehaviour)_instance).StartCoroutine(Step(preparation)); } } } internal static void BlowAway() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Island current = RaidIsland.Current; if (!((Object)(object)current == (Object)null)) { Scene scene = ((Component)current).gameObject.scene; HostSettings.MarkGreeneryKilled(((Scene)(ref scene)).name); Hide(current); } } private static void Hide(Island island) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) _bareIsland = island; Preparation preparation = PreparationFor(island); while (!preparation.Done && preparation.Work.MoveNext()) { } int num = 0; foreach (GameObject @object in preparation.Objects) { if (!((Object)(object)@object == (Object)null) && @object.activeInHierarchy) { @object.SetActive(false); num++; } } for (int i = 0; i < preparation.Ground.Count; i++) { if ((Object)(object)preparation.Ground[i] != (Object)null) { preparation.Ground[i].sharedMaterials = preparation.GroundMaterials[i]; } } int num2 = ClearInstancedDecorations(((Component)island).gameObject.scene); ManualLogSource log = Plugin.Log; if (log != null) { string text = $"[FatManBomb] Blew away {num} greenery object(s), {num2} grass/plant type(s) and scorched "; object arg = preparation.Ground.Count; Scene scene = ((Component)island).gameObject.scene; log.LogInfo((object)(text + $"{arg} ground mesh(es) on '{((Scene)(ref scene)).name}'.")); } } private static Preparation PreparationFor(Island island) { if (_prep != null && (Object)(object)_prep.Island == (Object)(object)island) { return _prep; } if (_prep != null) { foreach (Material ownedMaterial in _prep.OwnedMaterials) { if ((Object)(object)ownedMaterial != (Object)null) { Object.Destroy((Object)(object)ownedMaterial); } } } _prep = new Preparation { Island = island }; _prep.Work = Gather(_prep); return _prep; } private static IEnumerator Step(Preparation prep) { while (!prep.Done && prep.Work.MoveNext()) { yield return null; } } private static IEnumerator Gather(Preparation prep) { Scene scene = ((Component)prep.Island).gameObject.scene; string[] matchNames = "PalmLeafs,Foliage,PineTreeLeafs,PineTreeSmall,Fern".Split(','); Dictionary scorchedBySource = new Dictionary(); int budget = 400; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); Transform[] array = componentsInChildren; foreach (Transform t in array) { int num = budget - 1; budget = num; if (num <= 0) { budget = 400; yield return null; } if ((Object)(object)t == (Object)null || !((Component)t).gameObject.activeInHierarchy) { continue; } if (NameMatches(((Object)t).name, matchNames)) { if ((Object)(object)((Component)t).GetComponentInParent() == (Object)null) { prep.Objects.Add(((Component)t).gameObject); } continue; } Renderer component = (Renderer)(object)((Component)t).GetComponent(); if (!((Object)(object)component == (Object)null) && IsGround(component)) { Material[] array2 = ScorchMaterials(component.sharedMaterials, scorchedBySource, prep); if (array2 != null) { prep.Ground.Add(component); prep.GroundMaterials.Add(array2); yield return null; } } } } prep.Done = true; } private static bool IsGround(Renderer r) { //IL_0052: 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) //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_0061: 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) bool flag = false; Material[] sharedMaterials = r.sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null && val.HasProperty(ColorsId) && (Object)(object)val.GetTexture(ColorsId) != (Object)null) { flag = true; break; } } if (!flag) { return false; } Bounds bounds = r.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!(size.x >= 30f) && !(size.z >= 30f)) { return HasSourceTwin(((Component)r).transform); } return true; } private static bool HasSourceTwin(Transform t) { Transform parent = t.parent; if ((Object)(object)parent != (Object)null) { return (Object)(object)parent.Find(((Object)t).name + "Source") != (Object)null; } return false; } private static Material[] ScorchMaterials(Material[] source, Dictionary cache, Preparation prep) { //IL_0053: 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_006f: Expected O, but got Unknown Material[] array = null; for (int i = 0; i < source.Length; i++) { Material val = source[i]; if ((Object)(object)val == (Object)null || !val.HasProperty(ColorsId)) { continue; } if (!cache.TryGetValue(val, out var value)) { value = null; Texture2D val2 = ScorchedPalette(val.GetTexture(ColorsId)); if ((Object)(object)val2 != (Object)null) { value = new Material(val) { name = ((Object)val).name + " (Scorched)" }; value.SetTexture(ColorsId, (Texture)(object)val2); prep.OwnedMaterials.Add(value); } cache[val] = value; } if (!((Object)(object)value == (Object)null)) { if (array == null) { array = (Material[])source.Clone(); } array[i] = value; } } return array; } private static Texture2D ScorchedPalette(Texture source) { //IL_004c: 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_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_0073: 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) //IL_0081: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { return null; } if (ScorchedPalettes.TryGetValue(source, out var value)) { return value; } int width = source.width; int height = source.height; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); RenderTexture active = RenderTexture.active; Graphics.Blit(source, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false, false) { name = ((Object)source).name + " (Scorched)", filterMode = source.filterMode, wrapMode = source.wrapMode }; val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0, false); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color[] pixels = val.GetPixels(); int num = 0; for (int i = 0; i < pixels.Length; i++) { if (Scorch(ref pixels[i])) { num++; } } val.SetPixels(pixels); val.Apply(false, true); ScorchedPalettes[source] = val; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[FatManBomb] Built a scorched copy of palette '{((Object)source).name}' ({num} green/sand texel(s) scorched)."); } return val; } private static bool Scorch(ref Color c) { //IL_0001: 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_009b: 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_0083: 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) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); Color val; if (num >= 0.17f && num <= 0.45f && num2 >= 0.2f) { val = Color.HSVToRGB(0.08f, Mathf.Min(num2, 0.55f), num3 * 0.8f); } else { if (!(num >= 0.06f) || !(num < 0.17f) || !(num2 >= 0.1f) || !(num2 <= 0.5f) || !(num3 >= 0.55f)) { return false; } val = Color.HSVToRGB(0.07f, num2 * 0.6f, num3 * 0.55f); } val.a = c.a; c = val; return true; } private static bool NameMatches(string name, string[] matchNames) { for (int i = 0; i < matchNames.Length; i++) { string text = matchNames[i].Trim(); if (text.Length > 0 && name.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static int ClearInstancedDecorations(Scene scene) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (DecorationManager item in DecorationManagers(scene)) { if (!(FiDecorationTypes?.GetValue(item) is Array array)) { continue; } foreach (object item2 in array) { if (FiInstanceName?.GetValue(item2) is string { Length: not 0 } text) { try { InstanceManager.ReplaceBatches(text, new List>(), (List>)null); num++; } catch (KeyNotFoundException) { } } } } return num; } private static bool DecorationsSent(Scene scene) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (FiBatchesSplit == null) { return true; } foreach (DecorationManager item in DecorationManagers(scene)) { if (!(bool)FiBatchesSplit.GetValue(item)) { return false; } } return true; } private static IEnumerable DecorationManagers(Scene scene) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (!((Object)(object)val == (Object)null)) { DecorationManager[] componentsInChildren = val.GetComponentsInChildren(); for (int j = 0; j < componentsInChildren.Length; j++) { yield return componentsInChildren[j]; } } } } } public static class OneShotSfx { public static void PlayAt(AudioClip clip, float volume, Vector3 position, float minDistance, float maxDistance) { //IL_0017: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (!((Object)(object)clip == (Object)null) && !(volume <= 0f)) { GameObject val = new GameObject("BoomLagoon_OneShotSfx3D"); val.transform.position = position; AudioSource obj = val.AddComponent(); obj.playOnAwake = false; obj.loop = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = minDistance; obj.maxDistance = maxDistance; obj.ignoreListenerPause = true; obj.bypassEffects = true; obj.bypassListenerEffects = true; obj.priority = 0; GameAudio.Route(obj); obj.PlayOneShot(clip, Mathf.Clamp01(volume)); Object.Destroy((Object)val, clip.length); } } } internal static class RaidIsland { private const string LagoonMapId = "tournament_lagoon"; public static Island Current => Island.CurIsland; public static bool IsLagoon { get { //IL_0017: 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) if ((Object)(object)Current != (Object)null) { Scene scene = ((Component)Current).gameObject.scene; return string.Equals(((Scene)(ref scene)).name, "TournamentLagoon", StringComparison.OrdinalIgnoreCase); } return false; } } public static Scene Scene { get { //IL_0021: 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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Current != (Object)null)) { return default(Scene); } return ((Component)Current).gameObject.scene; } } public static bool TryGetCenter(out Vector3 center) { //IL_0001: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) center = default(Vector3); Island current = Current; if ((Object)(object)current == (Object)null) { return false; } if (CustomIslands.TryGetIslandInfo(OnlineIslandManager.CurIsland, out var info)) { try { center = info.IslandPosition; return true; } catch (Exception) { } } center = ((Component)current).transform.position; return true; } public static bool Contains(Vector2 target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(target.x, 0f, target.y); if (TryGetCenter(out var center) && SceneUtil.WithinZone(center, pos)) { return true; } Island miniIsland = Island.MiniIsland; if ((Object)(object)miniIsland != (Object)null && miniIsland.HasAppliedMiniPosition) { return SceneUtil.WithinZone(Island.MiniPos, pos); } return false; } public static bool CanFly(AirRaidQueue.Entry raid) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!raid.Home) { return Contains(raid.Target); } return IsLagoon; } public static bool TryGetLagoonOrigin(out Vector3 origin) { //IL_0065: 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) foreach (CustomIslands.Entry item in CustomIslands.All) { if (!((Object)(object)item.Anchor == (Object)null) && string.Equals(item.Id, "tournament_lagoon", StringComparison.OrdinalIgnoreCase)) { origin = item.Anchor.position; return true; } } origin = default(Vector3); return false; } } public class RaidKit : MonoBehaviour { private const string BundleFolder = "RaidKit"; private const string BundleFile = "boomlagoon_raidkit"; private const string FadeMaterialName = "M_BomberFade"; private const float FadeSeconds = 5f; private const float AppearDelaySeconds = 5f; private const float CheckInterval = 0.25f; private static AssetBundle _bundle; private static GameObject _bomberPrefab; private static GameObject _cloudPrefab; private static GameObject _sirenPrefab; private static Material _fadeMaterial; private static bool _loading; private static bool _failed; private GameObject _holder; private BomberRaid _raid; private BomberFade _fade; private bool _leaving; private float _nextCheck; private string _planRaw; private BomberFlightPlan _plan; private Island _hostIsland; internal static Material FadeMaterial => _fadeMaterial; private void Update() { if (Time.unscaledTime < _nextCheck) { return; } _nextCheck = Time.unscaledTime + 0.25f; HostWatchIsland(); if ((Object)(object)_holder == (Object)null && (Object)(object)_raid != (Object)null) { Forget(); } if ((Object)(object)_holder != (Object)null && ((Object)(object)Server.Instance == (Object)null || RaidIsland.IsLagoon)) { Object.Destroy((Object)(object)_holder); Forget(); return; } bool flag = Wanted(); if (flag && (Object)(object)_holder == (Object)null) { if ((Object)(object)_bomberPrefab != (Object)null) { Spawn(); } else if (!_loading && !_failed) { ((MonoBehaviour)this).StartCoroutine(Load()); } } else if (flag && _leaving) { _leaving = false; _fade?.FadeIn(5f, 0f); } else if (!flag && (Object)(object)_holder != (Object)null && !_leaving && ((Object)(object)_raid == (Object)null || !_raid.Busy)) { _leaving = true; if ((Object)(object)_fade != (Object)null) { _fade.FadeOut(5f, Despawn); } else { Despawn(); } } } private void HostWatchIsland() { Island current = RaidIsland.Current; if ((Object)(object)current == (Object)(object)_hostIsland) { return; } _hostIsland = current; if (HostSettings.IsHost) { if (!string.IsNullOrEmpty(HostSettings.RaidPlan)) { HostSettings.SetRaidPlan(null); } AirRaidQueue.ReleaseActive("the players left its island"); } } private bool Wanted() { if ((Object)(object)Server.Instance == (Object)null || (Object)(object)RaidIsland.Current == (Object)null || RaidIsland.IsLagoon || !HostSettings.BomberEnabled) { return false; } BomberRaid instance = BomberRaid.Instance; if ((Object)(object)instance != (Object)null && !instance.IsKit) { return false; } if (HostSettings.IsHost && (AirRaidQueue.Owed || AirRaidQueue.AnyWaiting(RaidIsland.CanFly))) { return true; } BomberFlightPlan bomberFlightPlan = CurrentPlan(); if (bomberFlightPlan != null) { return !bomberFlightPlan.SettledHome(BomberRaid.NetTime()); } return false; } private BomberFlightPlan CurrentPlan() { string raidPlan = HostSettings.RaidPlan; if (raidPlan != _planRaw) { _planRaw = raidPlan; _plan = BomberFlightPlan.Parse(raidPlan); } return _plan; } private void Spawn() { //IL_000a: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0057: Expected O, but got Unknown //IL_005d: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (!RaidIsland.TryGetCenter(out var center)) { return; } Scene scene = RaidIsland.Scene; if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded) { return; } Vector3 val = center + SpawnDirection(center) * HostSettings.KitSpawnDistance; val.y = center.y; _holder = new GameObject("BoomLagoonRaidKit"); SceneManager.MoveGameObjectToScene(_holder, scene); _holder.transform.position = val; GameObject val2 = Object.Instantiate(_bomberPrefab, _holder.transform); ((Object)val2).name = "Bomber"; val2.transform.localPosition = Vector3.zero; GameObject val3 = (((Object)(object)_cloudPrefab != (Object)null) ? Object.Instantiate(_cloudPrefab, _holder.transform) : null); if ((Object)(object)val3 != (Object)null) { ((Object)val3).name = "MushroomCloud"; } GameObject val4 = (((Object)(object)_sirenPrefab != (Object)null) ? Object.Instantiate(_sirenPrefab, _holder.transform) : null); AudioSource val5 = (((Object)(object)val4 != (Object)null) ? val4.GetComponent() : null); if ((Object)(object)val5 != (Object)null) { GameAudio.Route(val5); } FatManBombManager.UseRaidKit((MonoBehaviour)(object)this, val3); Transform val6 = BomberManager.FindChild(val2.transform, "BombPlane"); Transform val7 = BomberManager.FindChild(val2.transform, "ABomb"); if ((Object)(object)val6 == (Object)null || (Object)(object)val7 == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[RaidKit] The kit's bomber is missing its plane or bomb; no air raid here."); } Object.Destroy((Object)(object)_holder); Forget(); _failed = true; return; } _fade = val2.AddComponent(); _fade.Init(_fadeMaterial, visible: false); _fade.FadeIn(5f, 5f); _leaving = false; _raid = val2.AddComponent(); _raid.Init(val2.GetComponent(), val6, val7, val5, kit: true, _holder.transform); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[RaidKit] Bomber brought in at {val}, {HostSettings.KitSpawnDistance:F0} m from the island's centre."); } } private static Vector3 SpawnDirection(Vector3 center) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_002d: Unknown result type (might be due to invalid IL or missing references) if (RaidIsland.TryGetLagoonOrigin(out var origin)) { Vector3 val = origin - center; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 1f) { return ((Vector3)(ref val)).normalized; } } return Vector3.right; } private void Despawn() { if ((Object)(object)_holder != (Object)null) { Object.Destroy((Object)(object)_holder); } Forget(); if (HostSettings.IsHost && !string.IsNullOrEmpty(HostSettings.RaidPlan)) { HostSettings.SetRaidPlan(null); } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[RaidKit] Bomber unloaded."); } } private void Forget() { _holder = null; _raid = null; _fade = null; _leaving = false; } internal static IEnumerator EnsureLoaded() { while (_loading) { yield return null; } if ((Object)(object)_bomberPrefab == (Object)null && !_failed) { yield return Load(); } } private static IEnumerator Load() { _loading = true; try { string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "."; string path2 = Path.Combine(Path.Combine(path, "RaidKit"), "boomlagoon_raidkit"); if (!File.Exists(path2)) { _failed = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[RaidKit] Raid kit bundle not found at " + path2 + "; air raids only fly over the lagoon.")); } yield break; } if ((Object)(object)_bundle == (Object)null) { AssetBundleCreateRequest open = AssetBundle.LoadFromFileAsync(path2); yield return open; _bundle = open.assetBundle; if ((Object)(object)_bundle == (Object)null) { _failed = true; ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[RaidKit] Couldn't open the raid kit bundle at " + path2 + ".")); } yield break; } } AssetBundleRequest assets = _bundle.LoadAllAssetsAsync(); yield return assets; Object[] allAssets = assets.allAssets; foreach (Object obj in allAssets) { Material val = (Material)(object)((obj is Material) ? obj : null); if (val != null && Is(((Object)val).name, "M_BomberFade")) { _fadeMaterial = val; } GameObject val2 = (GameObject)(object)((obj is GameObject) ? obj : null); if (val2 != null) { if (Is(((Object)val2).name, "Bomber")) { _bomberPrefab = val2; } else if (Is(((Object)val2).name, "MushroomCloud")) { _cloudPrefab = val2; } else if (Is(((Object)val2).name, "AirRaidSiren")) { _sirenPrefab = val2; } } } if ((Object)(object)_bomberPrefab == (Object)null) { _failed = true; ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"[RaidKit] The raid kit bundle has no Bomber prefab."); } yield break; } ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogInfo((object)("[RaidKit] Loaded the raid kit (cloud " + (((Object)(object)_cloudPrefab != (Object)null) ? "found" : "MISSING") + ", siren " + (((Object)(object)_sirenPrefab != (Object)null) ? "found" : "MISSING") + ", fade " + (((Object)(object)_fadeMaterial != (Object)null) ? "found" : "MISSING") + ").")); } } finally { _loading = false; } } private static bool Is(string name, string wanted) { return string.Equals(name, wanted, StringComparison.OrdinalIgnoreCase); } } [DisallowMultipleComponent] public class ScreenFlash : MonoBehaviour { private static ScreenFlash _instance; private float _alpha; private Color _color = Color.white; private Coroutine _flashCo; private Coroutine _ringCo; private AudioSource _toneSource; private AudioClip _toneClip; private float _toneClipFrequency = -1f; private float _ringPeak; private AudioSource _oneShotSource; private static ScreenFlash Instance { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("BoomLagoon_ScreenFlash") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent(); ((Behaviour)_instance).enabled = false; } return _instance; } } public static void Play(Color color, float flashDuration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Play(color, flashDuration, flashDuration, 0f, 0f, 0f, null); } public static void Play(Color color, float flashDuration, float ringDuration, float oneShotVolume, float toneVolume, float ringFrequency, AudioClip oneShotClip) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!(flashDuration <= 0f)) { ScreenFlash instance = Instance; instance._color = color; if (ringDuration < flashDuration) { ringDuration = flashDuration; } if ((Object)(object)oneShotClip != (Object)null && oneShotVolume > 0f) { instance.PlayOneShotClip(oneShotClip, oneShotVolume); } instance.BeginRing(toneVolume, ringFrequency); if (instance._flashCo != null) { ((MonoBehaviour)instance).StopCoroutine(instance._flashCo); } ((Behaviour)instance).enabled = true; instance._flashCo = ((MonoBehaviour)instance).StartCoroutine(instance.FadeInOut(flashDuration)); if (instance._ringCo != null) { ((MonoBehaviour)instance).StopCoroutine(instance._ringCo); } if (instance._ringPeak > 0f) { instance._ringCo = ((MonoBehaviour)instance).StartCoroutine(instance.RingEnvelope(ringDuration, flashDuration * 0.5f)); } } } private IEnumerator FadeInOut(float duration) { float half = Mathf.Max(0.0001f, duration * 0.5f); for (float t = 0f; t < half; t += Time.unscaledDeltaTime) { _alpha = Mathf.SmoothStep(0f, 1f, t / half); yield return null; } _alpha = 1f; for (float t = 0f; t < half; t += Time.unscaledDeltaTime) { _alpha = Mathf.SmoothStep(1f, 0f, t / half); yield return null; } _alpha = 0f; _flashCo = null; ((Behaviour)this).enabled = false; } private IEnumerator RingEnvelope(float ringDuration, float fadeIn) { fadeIn = Mathf.Max(0.0001f, fadeIn); float num = Mathf.Clamp(ringDuration * 0.5f, 0.75f, 4f); float sustainEnd = Mathf.Max(fadeIn, ringDuration - num); for (float t = 0f; t < ringDuration; t += Time.unscaledDeltaTime) { float num2 = ((t < fadeIn) ? Mathf.SmoothStep(0f, 1f, t / fadeIn) : ((!(t < sustainEnd)) ? Mathf.SmoothStep(1f, 0f, (t - sustainEnd) / Mathf.Max(0.0001f, ringDuration - sustainEnd)) : 1f)); if ((Object)(object)_toneSource != (Object)null) { _toneSource.volume = num2 * _ringPeak; } yield return null; } if ((Object)(object)_toneSource != (Object)null) { _toneSource.volume = 0f; } StopTone(); _ringCo = null; } private void BeginRing(float peakVolume, float frequency) { _ringPeak = Mathf.Clamp01(peakVolume); if (_ringPeak <= 0f) { StopTone(); return; } EnsureToneSource(frequency); if ((Object)(object)_toneSource == (Object)null) { _ringPeak = 0f; return; } _toneSource.volume = 0f; if (!_toneSource.isPlaying) { _toneSource.Play(); } } private void StopTone() { if ((Object)(object)_toneSource != (Object)null && _toneSource.isPlaying) { _toneSource.Stop(); } } private void PlayOneShotClip(AudioClip clip, float volume) { EnsureOneShotSource(); if (!((Object)(object)_oneShotSource == (Object)null)) { _oneShotSource.clip = clip; _oneShotSource.volume = Mathf.Clamp01(volume); _oneShotSource.Play(); } } private void EnsureOneShotSource() { if (!((Object)(object)_oneShotSource != (Object)null)) { _oneShotSource = ((Component)this).gameObject.AddComponent(); _oneShotSource.playOnAwake = false; _oneShotSource.loop = false; _oneShotSource.spatialBlend = 0f; _oneShotSource.ignoreListenerPause = true; _oneShotSource.bypassEffects = true; _oneShotSource.bypassListenerEffects = true; _oneShotSource.priority = 0; GameAudio.Route(_oneShotSource); } } private void EnsureToneSource(float frequency) { if ((Object)(object)_toneSource == (Object)null) { _toneSource = ((Component)this).gameObject.AddComponent(); _toneSource.playOnAwake = false; _toneSource.loop = true; _toneSource.spatialBlend = 0f; _toneSource.ignoreListenerPause = true; _toneSource.bypassEffects = true; _toneSource.bypassListenerEffects = true; _toneSource.priority = 0; _toneSource.volume = 0f; GameAudio.Route(_toneSource); } if ((Object)(object)_toneClip == (Object)null || !Mathf.Approximately(_toneClipFrequency, frequency)) { _toneClip = BuildRingingClip(frequency); _toneClipFrequency = frequency; _toneSource.clip = _toneClip; } } private static AudioClip BuildRingingClip(float frequency) { int num = 88200; float num2 = Mathf.Clamp(frequency, 100f, 16000f); float num3 = Mathf.Max(1f, Mathf.Round(num2 * 2f)); float num4 = num3 + Mathf.Round(4f); float num5 = num3 / 2f; float num6 = num4 / 2f; float[] array = new float[num]; for (int i = 0; i < num; i++) { double num7 = (double)i / 44100.0; double num8 = Math.Sin(Math.PI * 2.0 * (double)num5 * num7) * 0.49 + Math.Sin(Math.PI * 2.0 * (double)num6 * num7) * 0.11; array[i] = (float)num8; } AudioClip obj = AudioClip.Create("BoomLagoon_FlashbangRing", num, 1, 44100, false); obj.SetData(array, 0); return obj; } private void OnGUI() { //IL_000e: 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_0064: Unknown result type (might be due to invalid IL or missing references) if (!(_alpha <= 0f)) { Color color = GUI.color; GUI.depth = -10000; GUI.color = new Color(_color.r, _color.g, _color.b, _alpha); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } } } } namespace BoomLagoon.Diagnostics { internal sealed class PerfProbe { internal readonly string Name; private long _ticks; private int _calls; internal PerfProbe(string name) { Name = name; } internal void Record(long ticks) { _ticks += ticks; _calls++; } internal void Drain(out double milliseconds, out int calls) { milliseconds = (double)_ticks * 1000.0 / (double)Stopwatch.Frequency; calls = _calls; _ticks = 0L; _calls = 0; } } internal static class PerfProbes { private const string LoaderPluginType = "HTFMapLoader.Plugin"; private static readonly Dictionary ByMethod = new Dictionary(); private static readonly List Ordered = new List(); private static bool _installed; internal static IList All => Ordered; internal static void Install(Harmony harmony) { if (_installed) { return; } _installed = true; Type type = AccessTools.TypeByName("HTFMapLoader.Plugin"); if (type == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Perf] HTFMapLoader.Plugin not found; the map loader is unmeasured."); } } else { Add(harmony, "MapLoader.Update", AccessTools.Method(type, "Update", (Type[])null, (Type[])null)); Add(harmony, "MapLoader.UpdateRadar", AccessTools.Method(type, "UpdateRadar", (Type[])null, (Type[])null)); Add(harmony, "MapLoader.IsGameplayWorldReady", AccessTools.Method(type, "IsGameplayWorldReady", (Type[])null, (Type[])null)); } Add(harmony, "CustomIslandDots.Update", AccessTools.Method(typeof(CustomIslandDots), "Update", (Type[])null, (Type[])null)); Add(harmony, "ShopProgressionFilter.Update", AccessTools.Method(typeof(ShopProgressionFilter), "Update", (Type[])null, (Type[])null)); Add(harmony, "FatManBombTarget.Update", AccessTools.Method(typeof(FatManBombTarget), "Update", (Type[])null, (Type[])null)); Add(harmony, "BomberRaid.Update", AccessTools.Method(typeof(BomberRaid), "Update", (Type[])null, (Type[])null)); Add(harmony, "BomberRaid.FixedUpdate", AccessTools.Method(typeof(BomberRaid), "FixedUpdate", (Type[])null, (Type[])null)); Add(harmony, "BomberRaid.LateUpdate", AccessTools.Method(typeof(BomberRaid), "LateUpdate", (Type[])null, (Type[])null)); Add(harmony, "ScreenFlash.OnGUI", AccessTools.Method(typeof(ScreenFlash), "OnGUI", (Type[])null, (Type[])null)); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)string.Format("[Perf] {0} probe(s) installed: {1}", Ordered.Count, string.Join(", ", Names()))); } } private static string[] Names() { string[] array = new string[Ordered.Count]; for (int i = 0; i < Ordered.Count; i++) { array[i] = Ordered[i].Name; } return array; } private static void Add(Harmony harmony, string label, MethodBase target) { //IL_0050: 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_0078: Expected O, but got Unknown //IL_0078: Expected O, but got Unknown if (target == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Perf] Probe '" + label + "': method not found; skipped.")); } } else { if (ByMethod.ContainsKey(target)) { return; } try { harmony.Patch(target, new HarmonyMethod(AccessTools.Method(typeof(ProbePatch), "Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(ProbePatch), "Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[Perf] Probe '" + label + "' could not be patched: " + ex.Message)); } return; } PerfProbe perfProbe = new PerfProbe(label); ByMethod[target] = perfProbe; Ordered.Add(perfProbe); } } internal static void Record(MethodBase method, long ticks) { if (ByMethod.TryGetValue(method, out var value)) { value.Record(ticks); } } } internal static class ProbePatch { internal static void Prefix(out long __state) { __state = Stopwatch.GetTimestamp(); } internal static void Postfix(long __state, MethodBase __originalMethod) { if (__state != 0L) { PerfProbes.Record(__originalMethod, Stopwatch.GetTimestamp() - __state); } } } public class PerfTelemetry : MonoBehaviour { private static readonly string[] NonIslandScenes = new string[4] { "Game", "DontDestroyOnLoad", "Menu", "MainMenu" }; private const int MaxSamples = 16384; private readonly float[] _frameMs = new float[16384]; private int _sampled; private int _frames; private int _dropped; private float _windowStart; private float _sessionStart; private int _gc0At; private int _gc1At; private long _heapAt; private StreamWriter _csv; private readonly StringBuilder _line = new StringBuilder(256); private void Awake() { _sessionStart = Time.realtimeSinceStartup; _windowStart = _sessionStart; _gc0At = GC.CollectionCount(0); _gc1At = ((GC.MaxGeneration >= 1) ? GC.CollectionCount(1) : 0); _heapAt = GC.GetTotalMemory(forceFullCollection: false); LogSessionHeader(); OpenCsv(); } private void OnDestroy() { try { _csv?.Dispose(); } catch { } _csv = null; } private void Update() { float unscaledDeltaTime = Time.unscaledDeltaTime; _frames++; if (_sampled < 16384) { _frameMs[_sampled++] = unscaledDeltaTime * 1000f; } else { _dropped++; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (!(realtimeSinceStartup - _windowStart < Mathf.Max(1f, Config.Telemetry.SampleSeconds.Value))) { Report(realtimeSinceStartup - _windowStart, realtimeSinceStartup - _sessionStart); _windowStart = realtimeSinceStartup; _sampled = 0; _frames = 0; _dropped = 0; } } private void Report(float windowSeconds, float sessionSeconds) { if (_frames != 0) { Array.Sort(_frameMs, 0, _sampled); float p = Percentile(0.5f); float p2 = Percentile(0.95f); float p3 = Percentile(0.99f); float worst = ((_sampled > 0) ? _frameMs[_sampled - 1] : 0f); float avgMs = windowSeconds * 1000f / (float)_frames; float avgFps = (float)_frames / windowSeconds; float value = Config.Telemetry.HitchMilliseconds.Value; int num = 0; int num2 = _sampled - 1; while (num2 >= 0 && _frameMs[num2] > value) { num++; num2--; } int num3 = GC.CollectionCount(0); int num4 = ((GC.MaxGeneration >= 1) ? GC.CollectionCount(1) : 0); long totalMemory = GC.GetTotalMemory(forceFullCollection: false); int gc0Delta = num3 - _gc0At; int gc1Delta = num4 - _gc1At; double heapMb = (double)totalMemory / 1048576.0; double heapDeltaMb = (double)(totalMemory - _heapAt) / 1048576.0; _gc0At = num3; _gc1At = num4; _heapAt = totalMemory; string scene = CurrentIslandScene(); IList all = PerfProbes.All; double[] array = new double[all.Count]; for (int i = 0; i < all.Count; i++) { all[i].Drain(out var milliseconds, out var _); array[i] = milliseconds / (double)_frames; } LogRow(scene, windowSeconds, avgFps, p, p2, p3, worst, num, gc0Delta, heapMb, heapDeltaMb, all, array); WriteCsvRow(scene, sessionSeconds, avgFps, avgMs, p, p2, p3, worst, num, gc0Delta, gc1Delta, heapMb, heapDeltaMb, array); } } private float Percentile(float q) { if (_sampled == 0) { return 0f; } int num = Mathf.Clamp(Mathf.CeilToInt(q * (float)_sampled) - 1, 0, _sampled - 1); return _frameMs[num]; } private static string CurrentIslandScene() { //IL_000b: 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) for (int num = SceneManager.sceneCount - 1; num >= 0; num--) { Scene sceneAt = SceneManager.GetSceneAt(num); if (((Scene)(ref sceneAt)).IsValid() && ((Scene)(ref sceneAt)).isLoaded && Array.IndexOf(NonIslandScenes, ((Scene)(ref sceneAt)).name) < 0) { return ((Scene)(ref sceneAt)).name; } } return "none"; } private void LogRow(string scene, float windowSeconds, float avgFps, float p50, float p95, float p99, float worst, int hitches, int gc0Delta, double heapMb, double heapDeltaMb, IList probes, double[] probeMsPerFrame) { _line.Length = 0; _line.Append("[Perf] ").Append(scene).Append(' ') .Append(windowSeconds.ToString("F1")) .Append("s | ") .Append(avgFps.ToString("F1")) .Append(" fps avg | ms p50 ") .Append(p50.ToString("F1")) .Append(" p95 ") .Append(p95.ToString("F1")) .Append(" p99 ") .Append(p99.ToString("F1")) .Append(" max ") .Append(worst.ToString("F1")) .Append(" | ") .Append(hitches) .Append(" hitch") .Append(" | GC0 ") .Append(gc0Delta) .Append(" heap ") .Append(heapMb.ToString("F1")) .Append("MB (") .Append((heapDeltaMb >= 0.0) ? "+" : "") .Append(heapDeltaMb.ToString("F1")) .Append(')'); if (_dropped > 0) { _line.Append(" | ").Append(_dropped).Append(" frames unsampled"); } for (int i = 0; i < probes.Count; i++) { if (!(probeMsPerFrame[i] < 0.005)) { _line.Append(" | ").Append(probes[i].Name).Append(' ') .Append(probeMsPerFrame[i].ToString("F3")); } } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)_line.ToString()); } } private void LogSessionHeader() { //IL_003f: 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) ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Perf] Telemetry on. " + SystemInfo.processorType + " / " + SystemInfo.graphicsDeviceName + " (" + ((object)SystemInfo.graphicsDeviceType/*cast due to .constrained prefix*/).ToString() + "), " + SystemInfo.systemMemorySize + "MB RAM, " + SystemInfo.graphicsMemorySize + "MB VRAM.")); } ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Perf] " + Screen.width + "x" + Screen.height + " " + (Screen.fullScreen ? "fullscreen" : "windowed") + ", quality '" + QualityName() + "', vSyncCount " + QualitySettings.vSyncCount + ", targetFrameRate " + Application.targetFrameRate + ".")); } if (QualitySettings.vSyncCount != 0 || Application.targetFrameRate > 0) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"[Perf] The frame rate is capped (VSync or targetFrameRate). Frame times include the wait, so fps here is the cap, not a ceiling -- uncap both for a baseline that can show headroom. The probe ms/frame columns stay valid either way."); } } } private static string QualityName() { try { string[] names = QualitySettings.names; int qualityLevel = QualitySettings.GetQualityLevel(); return (qualityLevel >= 0 && qualityLevel < names.Length) ? names[qualityLevel] : qualityLevel.ToString(); } catch { return "?"; } } private void OpenCsv() { if (!Config.Telemetry.WriteCsv.Value) { return; } string text = TelemetryPaths.File("perf"); if (text == null) { return; } text += ".csv"; try { _csv = new StreamWriter(text, append: false) { AutoFlush = true }; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Perf] Can't write " + text + " (" + ex.Message + "); logging only.")); } _csv = null; return; } StringBuilder stringBuilder = new StringBuilder("iso_time,session_seconds,scene,avg_fps,avg_ms,p50_ms,p95_ms,p99_ms,worst_ms,hitches,gc0,gc1,heap_mb,heap_delta_mb"); foreach (PerfProbe item in PerfProbes.All) { stringBuilder.Append(',').Append(item.Name).Append("_ms_per_frame"); } _csv.WriteLine(stringBuilder.ToString()); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)("[Perf] Recording to " + text)); } } private void WriteCsvRow(string scene, float sessionSeconds, float avgFps, float avgMs, float p50, float p95, float p99, float worst, int hitches, int gc0Delta, int gc1Delta, double heapMb, double heapDeltaMb, double[] probeMsPerFrame) { if (_csv == null) { return; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; StringBuilder stringBuilder = new StringBuilder(256); stringBuilder.Append(DateTime.Now.ToString("s", invariantCulture)).Append(',').Append(sessionSeconds.ToString("F1", invariantCulture)) .Append(',') .Append(scene) .Append(',') .Append(avgFps.ToString("F2", invariantCulture)) .Append(',') .Append(avgMs.ToString("F3", invariantCulture)) .Append(',') .Append(p50.ToString("F3", invariantCulture)) .Append(',') .Append(p95.ToString("F3", invariantCulture)) .Append(',') .Append(p99.ToString("F3", invariantCulture)) .Append(',') .Append(worst.ToString("F3", invariantCulture)) .Append(',') .Append(hitches) .Append(',') .Append(gc0Delta) .Append(',') .Append(gc1Delta) .Append(',') .Append(heapMb.ToString("F2", invariantCulture)) .Append(',') .Append(heapDeltaMb.ToString("F2", invariantCulture)); for (int i = 0; i < probeMsPerFrame.Length; i++) { stringBuilder.Append(',').Append(probeMsPerFrame[i].ToString("F4", invariantCulture)); } try { _csv.WriteLine(stringBuilder.ToString()); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Perf] CSV write failed (" + ex.Message + "); stopping file output.")); } try { _csv.Dispose(); } catch { } _csv = null; } } } public class SceneCensus : MonoBehaviour { private readonly HashSet _censused = new HashSet(); private void OnEnable() { SceneManager.sceneLoaded += HandleSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= HandleSceneLoaded; } private void HandleSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (((Scene)(ref scene)).IsValid() && !_censused.Contains(((Scene)(ref scene)).name)) { ((MonoBehaviour)this).StartCoroutine(CensusWhenSettled(scene)); } } private IEnumerator CensusWhenSettled(Scene scene) { //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 null; while (IslandManager.IsLoading) { yield return null; } yield return (object)new WaitForSecondsRealtime(2f); if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded || (Object)(object)SceneUtil.FindIslandHolder(scene) == (Object)null || !_censused.Add(((Scene)(ref scene)).name)) { yield break; } try { Write(Census(scene)); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Perf] Census of '" + ((Scene)(ref scene)).name + "' failed: " + ex)); } } } private static string Census(Scene scene) { GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); int num = 0; int num2 = 0; List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List list6 = new List(); List list7 = new List(); List list8 = new List(); GameObject[] array = rootGameObjects; foreach (GameObject val in array) { if ((Object)(object)val == (Object)null) { continue; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform obj in componentsInChildren) { num++; if (((Component)obj).gameObject.activeInHierarchy) { num2++; } } list.AddRange(val.GetComponentsInChildren(true)); list2.AddRange(val.GetComponentsInChildren(true)); list3.AddRange(val.GetComponentsInChildren(true)); list4.AddRange(val.GetComponentsInChildren(true)); list5.AddRange(val.GetComponentsInChildren(true)); list6.AddRange(val.GetComponentsInChildren(true)); list7.AddRange(val.GetComponentsInChildren(true)); list8.AddRange(val.GetComponentsInChildren(true)); } StringBuilder stringBuilder = new StringBuilder(4096); stringBuilder.Append("## ").Append(((Scene)(ref scene)).name).Append(" -- ") .Append(DateTime.Now.ToString("s")) .AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("GameObjects: ").Append(num).Append(" (") .Append(num2) .Append(" active), roots ") .Append(rootGameObjects.Length) .AppendLine(); AppendRenderers(stringBuilder, list, list2); AppendScripts(stringBuilder, list3); AppendPhysics(stringBuilder, list4, list7); stringBuilder.Append("ParticleSystems: ").Append(list5.Count).Append(" (") .Append(CountPlaying(list5)) .Append(" playing), Lights: ") .Append(list6.Count) .Append(", AudioSources: ") .Append(list8.Count) .AppendLine(); stringBuilder.AppendLine(); return stringBuilder.ToString(); } private static void AppendRenderers(StringBuilder sb, List renderers, List meshFilters) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); Dictionary dictionary = new Dictionary(); foreach (Renderer renderer in renderers) { if ((Object)(object)renderer == (Object)null || !renderer.enabled || !((Component)renderer).gameObject.activeInHierarchy) { continue; } num++; if (renderer.isPartOfStaticBatch) { num2++; } if ((int)renderer.shadowCastingMode != 0) { num3++; } Material[] sharedMaterials = renderer.sharedMaterials; if (sharedMaterials == null) { continue; } num4 += sharedMaterials.Length; Material[] array = sharedMaterials; foreach (Material val in array) { if (!((Object)(object)val == (Object)null)) { hashSet.Add(val); if (val.enableInstancing) { num5++; } if ((Object)(object)val.shader != (Object)null) { hashSet2.Add(((Object)val.shader).name); } dictionary.TryGetValue(((Object)val).name, out var value); dictionary[((Object)val).name] = value + 1; } } } long num6 = 0L; foreach (MeshFilter meshFilter in meshFilters) { if (!((Object)(object)meshFilter == (Object)null) && !((Object)(object)meshFilter.sharedMesh == (Object)null) && ((Component)meshFilter).gameObject.activeInHierarchy) { Mesh sharedMesh = meshFilter.sharedMesh; for (int j = 0; j < sharedMesh.subMeshCount; j++) { num6 += (long)sharedMesh.GetIndexCount(j) / 3L; } } } sb.Append("Renderers: ").Append(renderers.Count).Append(" (") .Append(num) .Append(" enabled+active), ") .Append("statically batched ") .Append(num2) .Append('/') .Append(num) .Append(", shadow casters ") .Append(num3) .AppendLine(); sb.Append("Material slots (draw submissions before batching): ").Append(num4).Append(", distinct materials ") .Append(hashSet.Count) .Append(" (GPU-instanced slots ") .Append(num5) .Append(')') .AppendLine(); sb.Append("Shaders: ").Append(hashSet2.Count).Append(" -- ") .Append(string.Join(", ", Sorted(hashSet2))) .AppendLine(); sb.Append("Triangles (active meshes, submitted): ").Append(num6).AppendLine(); sb.Append("Top materials by renderer count: ").Append(TopPairs(dictionary, 8)).AppendLine(); } private static void AppendScripts(StringBuilder sb, List behaviours) { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; Dictionary dictionary = new Dictionary(); foreach (MonoBehaviour behaviour in behaviours) { if (!((Object)(object)behaviour == (Object)null) && ((Behaviour)behaviour).isActiveAndEnabled) { Type type = ((object)behaviour).GetType(); bool flag = false; if (HasMessage(type, "Update")) { num++; flag = true; } if (HasMessage(type, "LateUpdate")) { num2++; flag = true; } if (HasMessage(type, "FixedUpdate")) { num3++; flag = true; } if (HasMessage(type, "OnGUI")) { num4++; flag = true; } if (flag) { dictionary.TryGetValue(type.Name, out var value); dictionary[type.Name] = value + 1; } } } sb.Append("Active MonoBehaviours: ").Append(CountActive(behaviours)).Append('/') .Append(behaviours.Count) .Append(" -- with Update ") .Append(num) .Append(", LateUpdate ") .Append(num2) .Append(", FixedUpdate ") .Append(num3) .Append(", OnGUI ") .Append(num4) .AppendLine(); sb.Append("Top per-frame script types: ").Append(TopPairs(dictionary, 8)).AppendLine(); } private static void AppendPhysics(StringBuilder sb, List colliders, List rigidbodies) { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; foreach (Collider collider in colliders) { if ((Object)(object)collider == (Object)null || !((Component)collider).gameObject.activeInHierarchy) { continue; } if (collider.isTrigger) { num7++; } if (collider is BoxCollider) { num++; continue; } if (collider is SphereCollider) { num2++; continue; } if (collider is CapsuleCollider) { num3++; continue; } MeshCollider val = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val != null) { num4++; if (!val.convex) { num5++; } } else { num6++; } } int num8 = 0; foreach (Rigidbody rigidbody in rigidbodies) { if ((Object)(object)rigidbody != (Object)null && ((Component)rigidbody).gameObject.activeInHierarchy && !rigidbody.isKinematic) { num8++; } } sb.Append("Colliders (active): box ").Append(num).Append(", sphere ") .Append(num2) .Append(", capsule ") .Append(num3) .Append(", mesh ") .Append(num4) .Append(" (") .Append(num5) .Append(" non-convex), other ") .Append(num6) .Append("; triggers ") .Append(num7) .AppendLine(); sb.Append("Rigidbodies (active): ").Append(num8).Append(" simulated") .AppendLine(); } private static bool HasMessage(Type type, string name) { Type type2 = type; while (type2 != null && type2 != typeof(MonoBehaviour)) { if (type2.GetMethod(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null) { return true; } type2 = type2.BaseType; } return false; } private static int CountActive(List behaviours) { int num = 0; foreach (MonoBehaviour behaviour in behaviours) { if ((Object)(object)behaviour != (Object)null && ((Behaviour)behaviour).isActiveAndEnabled) { num++; } } return num; } private static int CountPlaying(List systems) { int num = 0; foreach (ParticleSystem system in systems) { if ((Object)(object)system != (Object)null && system.isPlaying) { num++; } } return num; } private static List Sorted(HashSet values) { List list = new List(values); list.Sort(StringComparer.Ordinal); return list; } private static string TopPairs(Dictionary counts, int take) { if (counts.Count == 0) { return "(none)"; } List> list = new List>(counts); list.Sort((KeyValuePair a, KeyValuePair b) => (b.Value == a.Value) ? string.CompareOrdinal(a.Key, b.Key) : b.Value.CompareTo(a.Value)); StringBuilder stringBuilder = new StringBuilder(); for (int num = 0; num < list.Count && num < take; num++) { if (num > 0) { stringBuilder.Append(", "); } stringBuilder.Append(list[num].Key).Append(" x").Append(list[num].Value); } if (list.Count > take) { stringBuilder.Append(", +").Append(list.Count - take).Append(" more"); } return stringBuilder.ToString(); } private static void Write(string report) { string[] array = report.Split('\n'); foreach (string text in array) { if (text.Trim().Length > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Perf] " + text.TrimEnd())); } } } string text2 = TelemetryPaths.File("census"); if (text2 == null) { return; } text2 += ".md"; try { File.AppendAllText(text2, report); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[Perf] Can't write " + text2 + " (" + ex.Message + ").")); } } } } internal static class TelemetryPaths { private static string _dir; private static bool _resolved; internal static readonly string RunStamp = DateTime.Now.ToString("yyyyMMdd-HHmmss"); internal static string Dir { get { if (_resolved) { return _dir; } _resolved = true; try { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrEmpty(directoryName)) { return null; } _dir = Path.Combine(directoryName, "Telemetry"); Directory.CreateDirectory(_dir); } catch (Exception ex) { _dir = null; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Perf] Can't create the Telemetry folder (" + ex.Message + "); logging only.")); } } return _dir; } } internal static string File(string name) { string dir = Dir; if (dir != null) { return Path.Combine(dir, name + "-" + RunStamp); } return null; } } } namespace BoomLagoon.Amenities { public class BakedPurchasableWiring : LagoonSceneComponent { private static readonly Dictionary Refs = new Dictionary { { "Pistol (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Pistol" } }, { "Smg (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Smg" } }, { "Sniperrifle (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Sniper Rifle" } }, { "AssaultRifle (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Assault Rifle" } }, { "Shotgun (Purchasable) ", new string[2] { "_itemToPurchase", "items/purchasable/Shotgun" } }, { "Dynamite (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Dynamite" } }, { "Knife (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Knife" } }, { "BrassKnuckles (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Brass Knuckles" } }, { "Cast Fishing Rod (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Fishing Rod" } }, { "CrabFishingRod (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Crab Fishing Rod" } }, { "Beer (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Beer" } }, { "Map (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Map" } }, { "Badball (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Badball" } }, { "Radio (Purchasable)", new string[2] { "_itemToPurchase", "items/purchasable/Radio" } }, { "Amateur Lure(Purchasable)", new string[2] { "_bait", "baits/island 2/Beginner Boss Lure" } }, { "Homemade Lure(Purchasable)", new string[2] { "_bait", "baits/island 2/Beginner Lure" } }, { "Standard Lure(Purchasable)", new string[2] { "_bait", "baits/island 3/Standard Boss Lure" } }, { "Soap(Purchasable)", new string[2] { "_bait", "baits/island 3/Standard Lure" } }, { "Quality Lure(Purchasable)", new string[2] { "_bait", "baits/island 4/Professional Lure" } }, { "Professional Lure(Purchasable)", new string[2] { "_bait", "baits/island 4/Professional Boss Lure" } }, { "Hot Dog (Purchasable)", new string[2] { "_bait", "baits/island 1/HotDog" } }, { "Rotten Shrimp Lure(Purchasable)", new string[2] { "_bait", "baits/island 5/Scientific Lure" } }, { "Scientific Lure(Purchasable)", new string[2] { "_bait", "baits/island 5/Scientific Boss Lure" } }, { "Laser Sight(Purchasable)", new string[2] { "_info", "attachments/Laser Sight" } }, { "Extended Mag(Purchasable)", new string[2] { "_info", "attachments/Extended Mag" } }, { "RedDotSight (Purchasable)", new string[2] { "_info", "attachments/Red Dot Sight" } }, { "IronSight (Purchasable)", new string[2] { "_info", "attachments/Iron Sight" } }, { "SniperScope (Purchasable)", new string[2] { "_info", "attachments/Sniper Scope" } }, { "Suppressor (Purchasable)", new string[2] { "_info", "attachments/Suppressor" } }, { "Compensator(Purchasable)", new string[2] { "_info", "attachments/Compensator" } } }; private const string ItemLabelsTable = "Item Labels"; private const long KeyBigMotor = 91764200919040L; private const long KeyDualMotors = 91838939222016L; private const long KeyBoatRadar = 14071937716224L; protected override void OnLagoonLoaded(Scene scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(Wire(scene)); } private static IEnumerator Wire(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return null; yield return null; GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { yield break; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; Purchasable[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Purchasable val2 in componentsInChildren) { num++; BakedInteractableRepair.RestoreInteractionLayer(((Component)val2).gameObject); try { if (BakedInteractableRepair.PruneOutlineList((Component)(object)val2)) { num4++; } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)("[BakedShop] outline repair '" + ((Object)((Component)val2).gameObject).name + "' failed: " + ex.Message)); } num3++; } try { if (WireLocalizedName(val2)) { num5++; } } catch (Exception ex2) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)("[BakedShop] localized-name '" + ((Object)((Component)val2).gameObject).name + "' failed: " + ex2.Message)); } num3++; } if (!Refs.TryGetValue(((Object)((Component)val2).gameObject).name, out var value)) { continue; } try { FieldInfo fieldInfo = FindField(((object)val2).GetType(), value[0]); if (fieldInfo == null) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)("[BakedShop] field '" + value[0] + "' not found on " + ((object)val2).GetType().Name + " (" + ((Object)((Component)val2).gameObject).name + ").")); } num3++; } else { if (fieldInfo.GetValue(val2) != null) { continue; } Object val3 = Resources.Load(value[1], fieldInfo.FieldType); if (val3 == (Object)null) { ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)("[BakedShop] Resources.Load('" + value[1] + "') as " + fieldInfo.FieldType.Name + " returned null for '" + ((Object)((Component)val2).gameObject).name + "'.")); } num3++; } else { fieldInfo.SetValue(val2, val3); num2++; } continue; } } catch (Exception ex3) { ManualLogSource log5 = Plugin.Log; if (log5 != null) { log5.LogError((object)("[BakedShop] wiring '" + ((Object)((Component)val2).gameObject).name + "' failed: " + ex3.Message)); } num3++; } } ManualLogSource log6 = Plugin.Log; if (log6 != null) { log6.LogInfo((object)$"[BakedShop] Purchasables seen={num}, asset-wired={num2}, outline-repaired={num4}, name-wired={num5}, failed={num3}."); } } private static FieldInfo FindField(Type t, string name) { while (t != null) { FieldInfo field = t.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { return field; } t = t.BaseType; } return null; } private static bool WireLocalizedName(Purchasable p) { string name = ((object)p).GetType().Name; string text; long num; if (name == "MotorPurchasable") { text = "_motorNameLocalized"; FieldInfo fieldInfo = FindField(((object)p).GetType(), "_motorIndex"); num = ((((!(fieldInfo != null)) ? 1 : Convert.ToByte(fieldInfo.GetValue(p))) >= 2) ? 91838939222016L : 91764200919040L); } else { if (!(name == "BoatRadarPurchasable")) { return false; } text = "_radarNameLocalized"; num = 14071937716224L; } FieldInfo fieldInfo2 = FindField(((object)p).GetType(), text); if (fieldInfo2 == null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[BakedShop] '" + text + "' not found on " + name + ".")); } return false; } object obj = fieldInfo2.GetValue(p); if (obj == null) { obj = Activator.CreateInstance(fieldInfo2.FieldType); fieldInfo2.SetValue(p, obj); } MethodInfo methodInfo = null; MethodInfo[] methods = fieldInfo2.FieldType.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo2 in methods) { if (methodInfo2.Name == "SetReference" && methodInfo2.GetParameters().Length == 2) { methodInfo = methodInfo2; break; } } if (methodInfo == null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[BakedShop] LocalizedString.SetReference(2) not found."); } return false; } ParameterInfo[] parameters = methodInfo.GetParameters(); object obj2 = ImplicitConvert(parameters[0].ParameterType, "Item Labels"); object obj3 = ImplicitConvert(parameters[1].ParameterType, num); if (obj2 == null || obj3 == null) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)("[BakedShop] could not build Table/Entry reference for '" + ((Object)((Component)p).gameObject).name + "'.")); } return false; } methodInfo.Invoke(obj, new object[2] { obj2, obj3 }); return true; } private static object ImplicitConvert(Type target, object arg) { MethodInfo[] methods = target.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "op_Implicit") && !(methodInfo.ReturnType != target)) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType.IsInstanceOfType(arg)) { return methodInfo.Invoke(null, new object[1] { arg }); } } } return null; } } public class SellerNpcSpawner : LagoonSceneComponent { private const string MarkerName = "GunShopSeller"; private const string ResourcePath = "npcs/island5/Military NPC 2"; private const byte NpcId = 201; private static readonly FieldInfo NpcIdField = typeof(NPC).GetField("_id", BindingFlags.Instance | BindingFlags.NonPublic); protected override void OnLagoonLoaded(Scene scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(Spawn(scene)); } private static IEnumerator Spawn(Scene scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return null; GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { yield break; } Transform val2 = FindChildRecursive(val.transform, "GunShopSeller"); if ((Object)(object)val2 == (Object)null || val2.childCount > 0) { yield break; } GameObject val3 = Resources.Load("npcs/island5/Military NPC 2"); if ((Object)(object)val3 == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Seller] Resources.Load('npcs/island5/Military NPC 2') returned null; no seller spawned."); } yield break; } GameObject val4 = new GameObject("BoomLagoon_SellerTemp"); val4.SetActive(false); GameObject val5 = Object.Instantiate(val3, val4.transform, false); NPC componentInChildren = val5.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && NpcIdField != null) { try { NpcIdField.SetValue(componentInChildren, (byte)201); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[Seller] could not re-stamp NPC id: " + ex.Message)); } } } else { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"[Seller] loaded prefab has no NPC component (or _id field missing)."); } } val5.transform.SetParent(val2, false); val5.transform.localPosition = Vector3.zero; val5.transform.localRotation = Quaternion.identity; val5.transform.localScale = Vector3.one; val5.SetActive(true); Object.Destroy((Object)(object)val4); ManualLogSource log4 = Plugin.Log; if (log4 != null) { log4.LogInfo((object)string.Format("[Seller] Spawned '{0}' on '{1}' (id {2}).", "npcs/island5/Military NPC 2", "GunShopSeller", (byte)201)); } } private static Transform FindChildRecursive(Transform parent, string name) { for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = FindChildRecursive(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } public class ShopProgressionFilter : LagoonSceneComponent { private const float PollInterval = 0.5f; private static readonly Dictionary FirstIsland = new Dictionary { { "Beer (Purchasable)", 1 }, { "BrassKnuckles (Purchasable)", 1 }, { "CrabFishingRod (Purchasable)", 1 }, { "Hot Dog (Purchasable)", 1 }, { "Knife (Purchasable)", 1 }, { "Map (Purchasable)", 1 }, { "Radio (Purchasable)", 1 }, { "Sharpness (Purchasable)", 1 }, { "Pistol (Purchasable)", 2 }, { "Shotgun (Purchasable) ", 2 }, { "Dynamite (Purchasable)", 2 }, { "Cast Fishing Rod (Purchasable)", 2 }, { "Amateur Lure(Purchasable)", 2 }, { "Homemade Lure(Purchasable)", 2 }, { "Laser Sight(Purchasable)", 2 }, { "Better Ammo(Purchasable)", 2 }, { "BigMotor (Purchasable)", 2 }, { "Smg (Purchasable)", 3 }, { "Badball (Purchasable)", 3 }, { "Standard Lure(Purchasable)", 3 }, { "Soap(Purchasable)", 3 }, { "RedDotSight (Purchasable)", 3 }, { "IronSight (Purchasable)", 3 }, { "Compensator(Purchasable)", 3 }, { "Extended Mag(Purchasable)", 3 }, { "Boat Radar (Purchasable)", 3 }, { "Sniperrifle (Purchasable)", 4 }, { "Quality Lure(Purchasable)", 4 }, { "Professional Lure(Purchasable)", 4 }, { "SniperScope (Purchasable)", 4 }, { "Suppressor (Purchasable)", 4 }, { "DualMotors (Purchasable)", 4 }, { "AssaultRifle (Purchasable)", 5 }, { "Rotten Shrimp Lure(Purchasable)", 5 }, { "Scientific Lure(Purchasable)", 5 }, { "Slot4 (Purchasable)", 5 } }; private readonly List> _gated = new List>(); private int _appliedLevel = -1; private float _nextPoll; protected override void OnLagoonLoaded(Scene scene) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) _gated.Clear(); _appliedLevel = -1; _nextPoll = 0f; GameObject val = SceneUtil.FindIslandHolder(scene); if ((Object)(object)val == (Object)null) { return; } Purchasable[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Purchasable val2 in componentsInChildren) { if (FirstIsland.TryGetValue(((Object)((Component)val2).gameObject).name, out var value)) { _gated.Add(new KeyValuePair(((Component)val2).gameObject, value)); } } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[ShopProgress] Gating {_gated.Count} shop item(s) on island progression."); } Apply(); } private void Update() { if (_gated.Count != 0 && !(Time.unscaledTime < _nextPoll)) { _nextPoll = Time.unscaledTime + 0.5f; Apply(); } } private void Apply() { int num = CurrentLevel(); if (num == _appliedLevel) { return; } int num2 = 0; for (int num3 = _gated.Count - 1; num3 >= 0; num3--) { GameObject key = _gated[num3].Key; if ((Object)(object)key == (Object)null) { _gated.RemoveAt(num3); } else { bool flag = _gated[num3].Value <= num; if (key.activeSelf != flag) { key.SetActive(flag); } if (flag) { num2++; } } } _appliedLevel = num; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)string.Format("[ShopProgress] Islands unlocked: {0} -> {1}/{2} gated shop item(s) available.", (num >= 255) ? "all" : num.ToString(), num2, _gated.Count)); } } private static int CurrentLevel() { if (!HostSettings.ShopRespectsProgression) { return 255; } if ((Object)(object)OnlineIslandManager.Instance == (Object)null) { return 2; } return OnlineIslandManager.MaxIslandUnlocked; } } }