Decompiled source of Care Packages v1.0.0
tony4twentys-Care Packages.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Audio; using UnityEngine.SceneManagement; using Zorro.Core; using Zorro.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyTitle("Care Packages")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Care Packages")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("27e252b7-3ebe-46f0-832a-22c6ff530b7d")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace Care_Packages { [BepInPlugin("tony4twentys.Care_Packages", "Care Packages", "1.0.0")] [BepInProcess("PEAK.exe")] public class CarePackagesPlugin : BaseUnityPlugin { public const string PluginGuid = "tony4twentys.Care_Packages"; public const string PluginName = "Care Packages"; public const string PluginVersion = "1.0.0"; internal const float HeliFlyHeight = 120f; internal const float HeliArriveSeconds = 20f; internal const float HeliExitSeconds = 20f; internal const float HeliTravelDistance = 300f; internal const float DropFallSeconds = 5f; private const string DefaultPrefabName = "LuggageEpic"; internal const string CursedPrefabName = "LuggageCursed"; private const int LuggageAmountCap = 100; private const float LuggageRingSpacing = 3.4f; internal ConfigEntry<bool> EnabledConfig; internal ConfigEntry<float> SpawnDelayConfig; internal ConfigEntry<float> VolumeConfig; internal ConfigEntry<bool> CinematicDropConfig; internal ConfigEntry<bool> LoggingConfig; internal ConfigEntry<bool> TrappedCarePackagesConfig; internal ConfigEntry<int> LuggageAmountMinConfig; internal ConfigEntry<int> LuggageAmountMaxConfig; private readonly List<LuggageChoice> _luggageChoices = new List<LuggageChoice>(); private readonly List<Vector3> _dropSlots = new List<Vector3>(32); private Harmony _harmony; private bool _loggedFlarePatchError; private readonly HashSet<int> _trackedFlareIds = new HashSet<int>(); internal static CarePackagesPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static bool LoggingOn => (Object)(object)Instance != (Object)null && Instance.LoggingConfig != null && Instance.LoggingConfig.Value; private void Awake() { //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "When enabled, lighting a flare has the host drop a real networked luggage crate after a delay."); LoggingConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Logging", false, "When true, writes Care Packages debug lines (flare tracking, feeler hits, spawns) to BepInEx LogOutput.log. Off by default."); CinematicDropConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CinematicDrop", true, "When true, lighting a flare flies in a helicopter and drops parachute crates. When false, luggage just appears on the ground at the flare — no helicopter, parachute, or sky raycast."); TrappedCarePackagesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TrappedCarePackages", false, "When true, Trapped Luggage may trap care-package crates. When false (default), those crates stay safe even if Trapped Luggage is installed."); SpawnDelayConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "SpawnDelaySeconds", 10f, "Seconds after a flare is lit before the host spawns the crate. Only used when CinematicDrop is off. Cinematic drops always wait 20 seconds for the helicopter."); VolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "Volume", 1f, "Helicopter loudness (0 mute, 1 full). Vanilla Master Volume still applies on top, so turning the game down also quiets the helicopter."); LuggageAmountMinConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageAmountMin", 1, "Minimum crates dropped (inclusive). Used for helicopter drops and flare-only spawns. Set both min and max to 1 for a single crate."); LuggageAmountMaxConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Luggage", "LuggageAmountMax", 3, "Maximum crates dropped (inclusive, capped at 100). Rolls a random count from min to max. Extra crates fill rings around the flare so they do not stack."); BindLuggage("LuggageSmall", enabled: false, 1f, "Small luggage crate."); BindLuggage("LuggageBig", enabled: false, 1f, "Large luggage crate."); BindLuggage("LuggageEpic", enabled: true, 1f, "Gold / epic luggage crate. On by default."); BindLuggage("LuggageAncient", enabled: false, 1f, "Ancient luggage crate."); BindLuggage("LuggageClown", enabled: false, 1f, "Clown / trick luggage crate."); HostNet.Ensure(); ((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged; _harmony = new Harmony("tony4twentys.Care_Packages"); PatchAllResilient(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Care Packages v1.0.0 loaded. Enabled=" + EnabledConfig.Value + " CinematicDrop=" + CinematicDropConfig.Value + " TrappedCarePackages=" + TrappedCarePackagesConfig.Value)); if (!EnabledConfig.Value) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CarePackages] General.Enabled is false — lighting a flare will do nothing."); } } private void OnSettingChanged(object sender, SettingChangedEventArgs args) { HostNet.ScheduleBroadcast(); } private void PatchAllResilient() { Type[] types = typeof(CarePackagesPlugin).Assembly.GetTypes(); foreach (Type type in types) { try { _harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[CarePackages] Harmony patch failed for " + type.Name + ": " + ex.Message)); } } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.SettingChanged -= OnSettingChanged; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _trackedFlareIds.Clear(); Instance = null; Log = null; } internal static void Verbose(string message) { if (LoggingOn && (Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } internal static bool IsSpawnHost() { try { return PhotonNetwork.IsMasterClient; } catch { return false; } } internal bool ShouldHandleFlares() { return EnabledConfig.Value; } public static bool AllowsTrappedCarePackages() { return (Object)(object)Instance != (Object)null && Instance.TrappedCarePackagesConfig != null && Instance.TrappedCarePackagesConfig.Value; } internal void ApplyHostSnapshot(bool enabled, bool cinematic, bool trappedCarePackages) { Verbose("[CarePackages] Host snapshot enabled=" + enabled + " cinematic=" + cinematic + " trapped=" + trappedCarePackages); } internal int RollLuggageCount() { int num = ((LuggageAmountMinConfig == null) ? 1 : LuggageAmountMinConfig.Value); int num2 = ((LuggageAmountMaxConfig == null) ? 1 : LuggageAmountMaxConfig.Value); if (num < 1) { num = 1; } if (num2 < 1) { num2 = 1; } if (num > 100) { num = 100; } if (num2 > 100) { num2 = 100; } if (num2 < num) { num2 = num; } if (num == num2) { return num; } return Random.Range(num, num2 + 1); } private void FillDropSlots(Vector3 center, int count) { //IL_001f: 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_0098: 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_00a9: 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) _dropSlots.Clear(); if (count <= 1) { _dropSlots.Add(center); return; } float num = Random.Range(0f, 360f); int num2 = count; int num3 = 1; while (num2 > 0 && num3 < 40) { int num4 = 6 * num3; int num5 = ((num2 < num4) ? num2 : num4); float num6 = (float)num3 * 3.4f; float num7 = 360f / (float)num5; float num8 = num + (float)(num3 - 1) * 22f; for (int i = 0; i < num5; i++) { _dropSlots.Add(center + Quaternion.Euler(0f, num8 + num7 * (float)i, 0f) * Vector3.forward * num6); } num2 -= num5; num3++; } } private void BindLuggage(string prefab, bool enabled, float chance, string description) { _luggageChoices.Add(new LuggageChoice { Prefab = prefab, Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Luggage", prefab, enabled, description + " Toggle on to include it in the drop pool."), Chance = ((BaseUnityPlugin)this).Config.Bind<float>("Luggage", prefab + "Chance", chance, "Relative weight when this crate is on. 0.1 and 0.9 with two types on is 10% / 90%. If this is the only type on, it always spawns.") }); } internal string PickLuggagePrefab() { float num = 0f; for (int i = 0; i < _luggageChoices.Count; i++) { LuggageChoice luggageChoice = _luggageChoices[i]; if (luggageChoice.Enabled.Value && luggageChoice.Chance.Value > 0f) { num += luggageChoice.Chance.Value; } } if (num <= 0f) { return "LuggageEpic"; } float num2 = Random.Range(0f, num); float num3 = 0f; string result = "LuggageEpic"; for (int j = 0; j < _luggageChoices.Count; j++) { LuggageChoice luggageChoice2 = _luggageChoices[j]; if (luggageChoice2.Enabled.Value && !(luggageChoice2.Chance.Value <= 0f)) { num3 += luggageChoice2.Chance.Value; result = luggageChoice2.Prefab; if (num2 <= num3) { break; } } } return result; } internal void HandleLitFlare(Flare flare) { //IL_0061: 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) if (!((Object)(object)flare == (Object)null) && ShouldHandleFlares() && IsSpawnHost()) { int flareId = GetFlareId(flare); if (flareId != int.MinValue && _trackedFlareIds.Add(flareId)) { Verbose("[CarePackages] Tracking lit flare id=" + flareId + " host=true pos=" + ((object)((Component)flare).transform.position/*cast due to .constrained prefix*/).ToString()); ((MonoBehaviour)this).StartCoroutine(RunFlareCycle(flare, flareId)); } } } internal void PollLitFlares() { Flare[] array = Object.FindObjectsByType<Flare>((FindObjectsSortMode)0); foreach (Flare val in array) { if (!((Object)(object)val == (Object)null) && IsFlareLit(val)) { HandleLitFlare(val); } } } private IEnumerator RunFlareCycle(Flare flare, int id) { Vector3 lastPos = (((Object)(object)flare != (Object)null) ? ((Component)flare).transform.position : Vector3.zero); if (!EnabledConfig.Value) { _trackedFlareIds.Remove(id); yield break; } bool cinematic = CinematicDropConfig.Value; float spawnAt = (cinematic ? 20f : Mathf.Max(0.5f, SpawnDelayConfig.Value)); float heliHeading = Random.Range(0f, 360f); double heliStart = PhotonNetwork.Time; if (cinematic) { DropVisuals.BroadcastHeliFlyby(lastPos, heliHeading, spawnAt, 20f, 300f, 120f, heliStart); } float start = Time.time; while (Time.time - start < spawnAt + 1f) { if (TryGetFlarePosition(id, flare, out var pos, out var live)) { lastPos = pos; flare = live; if ((Object)(object)live != (Object)null && !IsFlareLit(live) && Time.time - start > 1.5f) { Verbose("[CarePackages] Flare id=" + id + " went out, cancelling drop."); _trackedFlareIds.Remove(id); yield break; } } if (Time.time - start >= spawnAt) { break; } yield return (object)new WaitForSeconds(0.5f); live = null; } if (IsSpawnHost()) { if (cinematic) { yield return ((MonoBehaviour)this).StartCoroutine(CinematicDropAndSpawn(lastPos, id, heliHeading)); } else { SpawnNonCinematicPackages(lastPos, id); } } } private unsafe IEnumerator CinematicDropAndSpawn(Vector3 flarePosition, int flareId, float heliHeading) { //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) int count = RollLuggageCount(); FillDropSlots(flarePosition, count); Vector3[] slots = _dropSlots.ToArray(); float duration = 5f; float stagger = ((count <= 1) ? 0f : Mathf.Clamp(2.8f / (float)(count - 1), 0.05f, 0.4f)); Vector3 planned = DropVisuals.GetCrateDropStart(flarePosition, heliHeading, 120f); for (int i = 0; i < count; i++) { Vector3 landHint = ((i < slots.Length) ? slots[i] : flarePosition); Vector3 start = DropVisuals.GetLiveDropStart(planned, flarePosition, 48f); Vector3 end = FindGroundBelow(new Vector3(landHint.x, start.y, landHint.z), landHint); string prefab = PickLuggagePrefab(); float rotY = Random.Range(0f, 360f); double photonStart = PhotonNetwork.Time; Verbose("[CarePackages] Parcel drop flare id=" + flareId + " crate=" + (i + 1) + "/" + count + " prefab=" + prefab + " start=" + ((object)(*(Vector3*)(&start))/*cast due to .constrained prefix*/).ToString() + " land=" + ((object)(*(Vector3*)(&end))/*cast due to .constrained prefix*/).ToString()); DropVisuals.BroadcastCrateDrop(start, end, rotY, duration, photonStart, prefab); ((MonoBehaviour)this).StartCoroutine(SpawnAfterLand(end, flareId, prefab, photonStart + (double)duration)); if (i < count - 1) { yield return (object)new WaitForSeconds(stagger); } } } private void SpawnNonCinematicPackages(Vector3 flarePosition, int flareId) { //IL_0009: 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) int count = RollLuggageCount(); FillDropSlots(flarePosition, count); for (int i = 0; i < _dropSlots.Count; i++) { Verbose("[CarePackages] Flare spawn " + (i + 1) + "/" + count + " around flare id=" + flareId); SpawnCarePackage(FindGroundNearFlare(_dropSlots[i]), flareId, PickLuggagePrefab()); } } private IEnumerator SpawnAfterLand(Vector3 end, int flareId, string prefab, double landAt) { //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) while (PhotonNetwork.Time < landAt) { yield return null; } if (IsSpawnHost()) { SpawnCarePackage(end, flareId, prefab); } } private unsafe void SpawnCarePackage(Vector3 spawnPos, int flareId, string prefabName) { //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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.InRoom) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CarePackages] Not in a Photon room, skip spawn."); return; } if (string.IsNullOrEmpty(prefabName)) { prefabName = "LuggageEpic"; } Quaternion rot = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); Verbose("[CarePackages] Host spawning " + prefabName + " at " + ((object)(*(Vector3*)(&spawnPos))/*cast due to .constrained prefix*/).ToString() + " for flare id=" + flareId); GameObject val = SpawnLuggagePrefab(prefabName, spawnPos, rot); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("[CarePackages] Luggage spawn failed. Prefab '" + prefabName + "' was not in the Photon item pool.")); return; } Luggage component = val.GetComponent<Luggage>(); if ((Object)(object)component == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[CarePackages] Spawned '" + ((Object)val).name + "' but it has no Luggage component.")); return; } ConfigureSpawnedLuggage(component, spawnPos); MarkCarePackage(val); Verbose("[CarePackages] Spawned " + ((Object)val).name + " pool=" + ((object)((Spawner)component).GetSpawnPool()/*cast due to .constrained prefix*/).ToString() + " as a room object."); } private GameObject SpawnLuggagePrefab(string configured, Vector3 pos, Quaternion rot) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(configured)) { configured = "LuggageEpic"; } GameObject val = TryInstantiateItemRoom(configured, pos, rot); if ((Object)(object)val != (Object)null) { return val; } string[] array = new string[8] { configured, "0_Items/" + configured, "LuggageEpic", "0_Items/LuggageEpic", "LuggageBig", "0_Items/LuggageBig", "LuggageSmall", "0_Items/LuggageSmall" }; for (int i = 0; i < array.Length; i++) { val = TryInstantiateRoomObject(array[i], pos, rot); if ((Object)(object)val != (Object)null) { return val; } } return null; } private GameObject TryInstantiateItemRoom(string prefabName, Vector3 pos, Quaternion rot) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = PhotonNetwork.InstantiateItemRoom(prefabName, pos, rot, true); if ((Object)(object)val != (Object)null) { Verbose("[CarePackages] InstantiateItemRoom('" + prefabName + "') ok."); } return val; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[CarePackages] InstantiateItemRoom('" + prefabName + "') failed: " + ex.Message)); return null; } } private GameObject TryInstantiateRoomObject(string prefabName, Vector3 pos, Quaternion rot) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = PhotonNetwork.InstantiateRoomObject(prefabName, pos, rot, (byte)0, (object[])null); if ((Object)(object)val != (Object)null) { Verbose("[CarePackages] InstantiateRoomObject('" + prefabName + "') ok."); } return val; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[CarePackages] InstantiateRoomObject('" + prefabName + "') failed: " + ex.Message)); return null; } } private static void MarkCarePackage(GameObject go) { if (!((Object)(object)go == (Object)null)) { if ((Object)(object)go.GetComponent<CarePackageLuggage>() == (Object)null) { go.AddComponent<CarePackageLuggage>(); } if (((Object)go).name.IndexOf("CarePackage", StringComparison.OrdinalIgnoreCase) < 0) { ((Object)go).name = "CarePackage_" + ((Object)go).name; } } } private unsafe void ConfigureSpawnedLuggage(Luggage luggage, Vector3 spawnPos) { //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_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_0059: 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_005f: 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_0062: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) try { ((Spawner)luggage).spawnOnStart = false; ((Spawner)luggage)._hasTriedToSpawn = false; ((Spawner)luggage)._hasSuccessfullySpawned = false; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[CarePackages] Could not clear spawn-on-start flags: " + ex.Message)); } SpawnPool pool = (SpawnPool)0; try { pool = ((Spawner)luggage).GetSpawnPool(); } catch { } if (IsUsableLuggagePool(pool)) { return; } SpawnPool val = ResolveLootPool(spawnPos); if ((int)val == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CarePackages] No biome luggage pool found; crate will use whatever the prefab already has."); return; } try { ((Spawner)luggage).spawnMode = (SpawnMode)1; ((Spawner)luggage).spawnPool = val; Verbose("[CarePackages] Assigned loot pool " + ((object)(*(SpawnPool*)(&val))/*cast due to .constrained prefix*/).ToString()); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[CarePackages] Could not assign loot pool: " + ex2.Message)); } } private static SpawnPool ResolveLootPool(Vector3 spawnPos) { //IL_0002: 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: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_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_004e: 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_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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) SpawnPool val = (SpawnPool)0; float num = float.MaxValue; try { List<Luggage> aLL_LUGGAGE = Luggage.ALL_LUGGAGE; if (aLL_LUGGAGE != null) { for (int i = 0; i < aLL_LUGGAGE.Count; i++) { Luggage val2 = aLL_LUGGAGE[i]; if ((Object)(object)val2 == (Object)null) { continue; } SpawnPool spawnPool; try { spawnPool = ((Spawner)val2).GetSpawnPool(); } catch { continue; } if (IsUsableLuggagePool(spawnPool)) { Vector3 val3 = ((Component)val2).transform.position - spawnPos; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = spawnPool; } } } } } catch { } if ((int)val > 0) { return val; } return PoolForCurrentBiome(); } private static SpawnPool PoolForCurrentBiome() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_0026: 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_0028: 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_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_005b: Expected I4, but got Unknown //IL_0016: 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_006a: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_0082: 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_0092: 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) try { if ((Object)(object)Singleton<MapHandler>.Instance == (Object)null) { return (SpawnPool)1024; } BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome(); BiomeType val = currentBiome; BiomeType val2 = val; return (SpawnPool)((int)val2 switch { 0 => 1024, 1 => 2048, 2 => 4096, 3 => 8192, 6 => 16777216, 7 => 67108864, 8 => 268435456, 9 => 536870912, 5 => 16384, _ => 1024, }); } catch { return (SpawnPool)1024; } } private unsafe static bool IsUsableLuggagePool(SpawnPool pool) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 if ((int)pool == 0) { return false; } string text = ((object)(*(SpawnPool*)(&pool))/*cast due to .constrained prefix*/).ToString(); if (!text.StartsWith("Luggage", StringComparison.Ordinal)) { return false; } return (int)pool != 65536 && (int)pool != 1073741824; } private Vector3 FindGroundBelow(Vector3 origin, Vector3 flareFallback) { //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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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) RaycastHit[] array = Physics.RaycastAll(origin, Vector3.down, 400f, -5, (QueryTriggerInteraction)1); if (array != null && array.Length != 0) { Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); for (int num = 0; num < array.Length; num++) { if (DropVisuals.IsHeliObstacle(((RaycastHit)(ref array[num])).collider)) { Verbose("[CarePackages] Drop ground hit '" + ((Object)((RaycastHit)(ref array[num])).collider).name + "' path=" + DropVisuals.GetHitPath(((RaycastHit)(ref array[num])).collider) + " at " + ((object)((RaycastHit)(ref array[num])).point/*cast due to .constrained prefix*/).ToString()); return ((RaycastHit)(ref array[num])).point + Vector3.up * 0.15f; } } } ((BaseUnityPlugin)this).Logger.LogWarning((object)"[CarePackages] Drop raycast missed; using the flare."); return flareFallback + Vector3.up * 0.35f; } private static Vector3 FindGroundNearFlare(Vector3 flarePosition) { //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_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_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_008e: 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_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) Vector3 val = flarePosition + Vector3.up * 3f; RaycastHit[] array = Physics.RaycastAll(val, Vector3.down, 8f, -5, (QueryTriggerInteraction)1); if (array != null && array.Length != 0) { Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); for (int num = 0; num < array.Length; num++) { if (DropVisuals.IsHeliObstacle(((RaycastHit)(ref array[num])).collider)) { return ((RaycastHit)(ref array[num])).point + Vector3.up * 0.15f; } } } return flarePosition + Vector3.up * 0.35f; } private static int GetFlareId(Flare flare) { if ((Object)(object)flare == (Object)null) { return int.MinValue; } try { TrackableNetworkObject val = flare.trackable; if ((Object)(object)val == (Object)null) { val = ((Component)flare).GetComponent<TrackableNetworkObject>(); } if ((Object)(object)val != (Object)null) { return val.instanceID; } } catch { } PhotonView component = ((Component)flare).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null) { return component.ViewID; } return ((Object)flare).GetInstanceID(); } private static bool TryGetFlarePosition(int id, Flare known, out Vector3 position, out Flare live) { //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_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_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) live = known; if ((Object)(object)known != (Object)null) { position = ((Component)known).transform.position; return true; } TrackableNetworkObject[] array = Object.FindObjectsByType<TrackableNetworkObject>((FindObjectsSortMode)0); foreach (TrackableNetworkObject val in array) { if (!((Object)(object)val == (Object)null) && val.instanceID == id) { position = ((Component)val).transform.position; live = ((Component)val).GetComponent<Flare>(); return true; } } position = Vector3.zero; return false; } internal static bool IsFlareLit(Flare flare) { if ((Object)(object)flare == (Object)null) { return false; } try { if (!((ItemComponent)flare).HasData((DataEntryKey)3)) { return false; } return ((ItemComponent)flare).GetData<BoolItemData>((DataEntryKey)3)?.Value ?? false; } catch { return false; } } internal void LogFlarePatchErrorOnce(Exception ex) { if (!_loggedFlarePatchError) { _loggedFlarePatchError = true; ((BaseUnityPlugin)this).Logger.LogError((object)("[CarePackages] Flare patch failed (logged once): " + ex)); } } } [HarmonyPatch(typeof(Flare), "EnableFlareVisuals")] internal static class FlareEnableVisualsPatch { [HarmonyPostfix] private static void Postfix(Flare __instance) { try { if (!((Object)(object)CarePackagesPlugin.Instance == (Object)null) && !((Object)(object)__instance == (Object)null)) { CarePackagesPlugin.Instance.HandleLitFlare(__instance); } } catch (Exception ex) { CarePackagesPlugin.Instance?.LogFlarePatchErrorOnce(ex); } } } [HarmonyPatch(typeof(Action_Flare), "RunAction")] internal static class ActionFlareRunPatch { [HarmonyPostfix] private static void Postfix(Action_Flare __instance) { try { if (!((Object)(object)CarePackagesPlugin.Instance == (Object)null) && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.flare == (Object)null)) { CarePackagesPlugin.Instance.HandleLitFlare(__instance.flare); } } catch (Exception ex) { CarePackagesPlugin.Instance?.LogFlarePatchErrorOnce(ex); } } } public sealed class CarePackageLuggage : MonoBehaviour { } internal sealed class LuggageChoice { public string Prefab; public ConfigEntry<bool> Enabled; public ConfigEntry<float> Chance; } internal sealed class DropVisuals : MonoBehaviour { private Coroutine _heliRoutine; private GameObject _liveHeli; private AudioSource[] _heliAudio; private float _heliAudioVol; private readonly HashSet<string> _feelLog = new HashSet<string>(); private static readonly RaycastHit[] ProbeHits = (RaycastHit[])(object)new RaycastHit[24]; private static readonly Collider[] OverlapHits = (Collider[])(object)new Collider[24]; private static MasterVolumeSetting _masterVolume; private static AudioMixerGroup _masterMixer; private static GameObject _heliTemplate; private static Vector3 _ropeLocalOffset = new Vector3(0f, -3f, 0f); private static bool _ropeOffsetReady; private static bool _loggedMissingParachute; private static Material _parcelMat; private static Material _strapMat; internal static DropVisuals Instance { get; private set; } internal static void Ensure(GameObject host) { if ((Object)(object)host.GetComponent<DropVisuals>() == (Object)null) { host.AddComponent<DropVisuals>(); } } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } internal static void BroadcastHeliFlyby(Vector3 over, float headingY, float arriveSeconds, float exitSeconds, float travelDistance, float flyHeight, double photonStart) { //IL_0001: 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) HostNet.BroadcastHeli(over, headingY, arriveSeconds, exitSeconds, travelDistance, flyHeight, photonStart); if ((Object)(object)Instance != (Object)null) { Instance.PlayHeli(over, headingY, arriveSeconds, exitSeconds, travelDistance, flyHeight, photonStart); } } internal static void BroadcastCrateDrop(Vector3 start, Vector3 end, float rotY, float duration, double photonStart, string prefabName) { //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_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) HostNet.BroadcastCrate(start, end, rotY, duration, photonStart, prefabName); if ((Object)(object)Instance != (Object)null) { Instance.PlayCrate(start, end, rotY, duration, photonStart, prefabName); } } internal static Vector3 GetCrateDropStart(Vector3 over, float headingY, float flyHeight) { //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_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_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_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_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_0047: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) flyHeight = Mathf.Max(20f, flyHeight); Vector3 val = Quaternion.Euler(0f, headingY, 0f) * Vector3.forward; Quaternion val2 = Quaternion.LookRotation(val, Vector3.up); Vector3 val3 = over + Vector3.up * flyHeight; return val3 + val2 * GetRopeLocalOffset(); } internal static Vector3 GetLiveDropStart(Vector3 fallback) { //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_0008: 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_0010: Unknown result type (might be due to invalid IL or missing references) return GetLiveDropStart(fallback, fallback, 48f); } internal static Vector3 GetLiveDropStart(Vector3 fallback, Vector3 mark, float maxXZ) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: 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_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_007c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance == (Object)null || (Object)(object)Instance._liveHeli == (Object)null) { return fallback; } Vector3 val = Instance._liveHeli.transform.TransformPoint(GetRopeLocalOffset()); float num = val.x - mark.x; float num2 = val.z - mark.z; if (num * num + num2 * num2 > maxXZ * maxXZ) { return fallback; } return val; } internal void PlayHeli(Vector3 over, float headingY, float arriveSeconds, float exitSeconds, float travelDistance, float flyHeight, double photonStart) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (_heliRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_heliRoutine); } _heliRoutine = ((MonoBehaviour)this).StartCoroutine(RunHeli(over, headingY, arriveSeconds, exitSeconds, travelDistance, flyHeight, photonStart)); } internal void PlayCrate(Vector3 start, Vector3 end, float rotY, float duration, double photonStart, string prefabName) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(RunCrate(start, end, rotY, duration, photonStart, prefabName)); } private unsafe IEnumerator RunHeli(Vector3 over, float headingY, float arriveSeconds, float exitSeconds, float travelDistance, float flyHeight, double photonStart) { //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) arriveSeconds = Mathf.Max(2f, arriveSeconds); exitSeconds = Mathf.Max(4f, exitSeconds); travelDistance = Mathf.Max(80f, travelDistance); flyHeight = Mathf.Max(20f, flyHeight); Vector3 inbound = Quaternion.Euler(0f, headingY, 0f) * Vector3.forward; Vector3 cruise = over + Vector3.up * flyHeight; Vector3 from = LiftClear(cruise - inbound * travelDistance); Vector3 exitPoint = over + inbound * travelDistance; Quaternion face = Quaternion.LookRotation(inbound, Vector3.up); GameObject heli = null; float waited = 0f; while ((Object)(object)heli == (Object)null && waited <= 8f) { Transform source = FindHelicopterSource(); if ((Object)(object)source != (Object)null) { heli = CreateHelicopterClone(source, from, face, keepColliders: false); } if ((Object)(object)heli != (Object)null) { TryCacheHelicopter(); break; } heli = SpawnCachedHeli(from, face); if ((Object)(object)heli != (Object)null) { break; } yield return (object)new WaitForSeconds(0.5f); waited += 0.5f; } if ((Object)(object)heli == (Object)null) { ManualLogSource log = CarePackagesPlugin.Log; if (log != null) { log.LogWarning((object)"[CarePackages] Helicopter flyby skipped — PeakSequence/Helicopter not found in this scene yet."); } _heliRoutine = null; yield break; } ((Object)heli).name = "CP_DropHeli"; _liveHeli = heli; _feelLog.Clear(); PlayHeliAudio(heli); CarePackagesPlugin.Verbose("[CarePackages] Helicopter flyby start=" + ((object)(*(Vector3*)(&from))/*cast due to .constrained prefix*/).ToString() + " over=" + ((object)(*(Vector3*)(&cruise))/*cast due to .constrained prefix*/).ToString() + " end=" + ((object)(*(Vector3*)(&exitPoint))/*cast due to .constrained prefix*/).ToString()); float yaw = headingY; float pitch = 0f; float y = from.y; float yawVel = 0f; float pitchVel = 0f; float yVel = 0f; float nextFeel = 0f; float feelFwd = 80f; float feelUp = 80f; float feelLeft = 80f; float feelRight = 80f; float feelDown = 40f; float cruiseSpeed = travelDistance / arriveSeconds; while (true) { float t = (float)(PhotonNetwork.Time - photonStart); float dt = Time.deltaTime; if (dt <= 0f) { dt = 0.02f; } if (Time.unscaledTime >= nextFeel) { nextFeel = Time.unscaledTime + 0.18f; ProbeFeelers(heli.transform, 55f, 32f, out feelFwd, out feelUp, out feelLeft, out feelRight, out feelDown); } Vector3 target = ((t <= arriveSeconds) ? cruise : exitPoint); Vector3 pos = heli.transform.position; Vector3 toTarget = target - pos; toTarget.y = 0f; if (((Vector3)(ref toTarget)).sqrMagnitude < 0.01f) { toTarget = Quaternion.Euler(0f, yaw, 0f) * Vector3.forward; } Quaternion val = Quaternion.LookRotation(toTarget, Vector3.up); float wantYaw = ((Quaternion)(ref val)).eulerAngles.y; float desiredY = Mathf.Max(cruise.y, over.y + flyHeight); float speedMul = 1f; if (feelDown < 26f) { desiredY = Mathf.Max(desiredY, pos.y + (26f - feelDown) + 10f); } if (feelFwd < 50f) { speedMul = Mathf.Lerp(0.4f, 1f, feelFwd / 50f); if (feelUp > feelFwd + 6f) { desiredY = Mathf.Max(desiredY, pos.y + 22f); } else { float turn = ((feelRight >= feelLeft) ? 32f : (-32f)); wantYaw += turn; desiredY = Mathf.Max(desiredY, pos.y + 12f); } } desiredY = Mathf.Min(desiredY, over.y + flyHeight + 160f); yaw = Mathf.SmoothDampAngle(yaw, wantYaw, ref yawVel, 0.75f, 55f, dt); float climb = desiredY - y; float wantPitch = Mathf.Clamp((0f - climb) * 0.28f, -16f, 10f); pitch = Mathf.SmoothDamp(pitch, wantPitch, ref pitchVel, 0.65f, 25f, dt); y = Mathf.SmoothDamp(y, desiredY, ref yVel, 0.9f, 28f, dt); Vector3 flatFwd = Quaternion.Euler(0f, yaw, 0f) * Vector3.forward; pos += flatFwd * (cruiseSpeed * speedMul * dt); pos.y = y; heli.transform.SetPositionAndRotation(pos, Quaternion.Euler(pitch, yaw, 0f)); TickHeliAudio(pos, over, t, arriveSeconds, exitSeconds, dt); if (t >= arriveSeconds + exitSeconds) { break; } yield return null; } if ((Object)(object)_liveHeli == (Object)(object)heli) { _liveHeli = null; } _heliAudio = null; Object.Destroy((Object)(object)heli); _heliRoutine = null; } private IEnumerator RunCrate(Vector3 start, Vector3 end, float rotY, float duration, double photonStart, string prefabName) { //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) //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) duration = Mathf.Max(0.35f, duration); GameObject crate = CreateFallingLuggage(prefabName, start, Quaternion.Euler(0f, rotY, 0f)); GameObject chute = AttachParachuteVisual(crate); while (true) { float u = ((duration <= 0f) ? 1f : Mathf.Clamp01((float)((PhotonNetwork.Time - photonStart) / (double)duration))); if ((Object)(object)crate != (Object)null) { float settle = Mathf.SmoothStep(0f, 1f, u); crate.transform.position = Vector3.Lerp(start, end, settle); crate.transform.rotation = Quaternion.Euler(4f, rotY + settle * 16f, -3f); } if (u >= 1f) { break; } yield return null; } if ((Object)(object)chute != (Object)null) { Object.Destroy((Object)(object)chute); } if ((Object)(object)crate != (Object)null) { Object.Destroy((Object)(object)crate); } } private static GameObject CreateFallingLuggage(string prefabName, Vector3 pos, Quaternion rot) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = LoadLuggagePrefab(prefabName); if ((Object)(object)val == (Object)null) { ManualLogSource log = CarePackagesPlugin.Log; if (log != null) { log.LogWarning((object)("[CarePackages] Could not load luggage prefab '" + prefabName + "' for the falling visual.")); } return CreateParcelVisual(pos, rot); } bool activeSelf = val.activeSelf; val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(val, pos, rot); val.SetActive(activeSelf); ((Object)val2).name = "CP_FallingLuggage"; StripNetworkAndGameplay(val2); val2.SetActive(true); return val2; } private static GameObject LoadLuggagePrefab(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { prefabName = "LuggageEpic"; } string text = "0_Items/" + prefabName; GameObject val = Resources.Load<GameObject>(text); if ((Object)(object)val != (Object)null) { return val; } val = Resources.Load<GameObject>(prefabName); if ((Object)(object)val != (Object)null) { return val; } try { IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool; DefaultPool val2 = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null); if (val2 != null && val2.ResourceCache != null) { if (val2.ResourceCache.TryGetValue(text, out var value) && (Object)(object)value != (Object)null) { return value; } if (val2.ResourceCache.TryGetValue(prefabName, out value) && (Object)(object)value != (Object)null) { return value; } } } catch { } return null; } private static void StripNetworkAndGameplay(GameObject visual) { if ((Object)(object)visual == (Object)null) { return; } PhotonView[] componentsInChildren = visual.GetComponentsInChildren<PhotonView>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } } Luggage component = visual.GetComponent<Luggage>(); if ((Object)(object)component != (Object)null) { try { ((Spawner)component).spawnOnStart = false; ((Spawner)component)._hasTriedToSpawn = true; ((Spawner)component)._hasSuccessfullySpawned = true; } catch { } ((Behaviour)component).enabled = false; } MonoBehaviour[] componentsInChildren2 = visual.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren2) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; if (name == "Luggage" || name.IndexOf("Photon", StringComparison.Ordinal) >= 0) { ((Behaviour)val).enabled = false; } } } Collider[] componentsInChildren3 = visual.GetComponentsInChildren<Collider>(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if ((Object)(object)componentsInChildren3[k] != (Object)null) { componentsInChildren3[k].enabled = false; } } Rigidbody[] componentsInChildren4 = visual.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val2 in componentsInChildren4) { if (!((Object)(object)val2 == (Object)null)) { val2.isKinematic = true; val2.useGravity = false; val2.detectCollisions = false; } } } private static GameObject CreateParcelVisual(Vector3 pos, Quaternion rot) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: 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_0025: 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_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CP_CareParcel"); val.transform.SetPositionAndRotation(pos, rot); GameObject val2 = MakeBox("Box", val.transform, Vector3.zero, new Vector3(0.95f, 0.62f, 0.72f), ParcelMat()); GameObject val3 = MakeBox("Lid", val.transform, new Vector3(0f, 0.36f, 0f), new Vector3(0.98f, 0.08f, 0.75f), ParcelMat()); MakeBox("StrapA", val.transform, new Vector3(0f, 0.02f, 0f), new Vector3(0.12f, 0.66f, 0.76f), StrapMat()); MakeBox("StrapB", val.transform, new Vector3(0f, 0.02f, 0f), new Vector3(0.98f, 0.66f, 0.12f), StrapMat()); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { Object.Destroy((Object)(object)val); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val4).name = "CP_CareParcel"; val4.transform.SetPositionAndRotation(pos, rot); val4.transform.localScale = new Vector3(0.9f, 0.55f, 0.7f); Collider component = val4.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } return val4; } return val; } private static GameObject MakeBox(string name, Transform parent, Vector3 localPos, Vector3 scale, Material mat) { //IL_0024: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = name; val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.transform.localRotation = Quaternion.identity; val.transform.localScale = scale; Collider component = val.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val.GetComponent<MeshRenderer>(); if ((Object)(object)component2 != (Object)null && (Object)(object)mat != (Object)null) { ((Renderer)component2).sharedMaterial = mat; } return val; } private static Material ParcelMat() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_parcelMat == (Object)null) { _parcelMat = MakeColorMat(new Color(0.72f, 0.42f, 0.14f)); } return _parcelMat; } private static Material StrapMat() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_strapMat == (Object)null) { _strapMat = MakeColorMat(new Color(0.18f, 0.16f, 0.12f)); } return _strapMat; } private static Material MakeColorMat(Color color) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0080: 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) Shader val = Shader.Find("Universal Render Pipeline/Lit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Standard"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Sprites/Default"); } if ((Object)(object)val == (Object)null) { return null; } Material val2 = new Material(val); if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", color); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", color); } return val2; } private static GameObject CreateHelicopterClone(Transform source, Vector3 pos, Quaternion rot, bool keepColliders) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: 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) GameObject val = new GameObject("CP_Heli"); val.transform.SetPositionAndRotation(pos, rot); if (!CopyRenderers(((Component)source).gameObject, source, val.transform)) { Object.Destroy((Object)(object)val); return null; } if (keepColliders) { CopyColliders(((Component)source).gameObject, source, val.transform); } CopyAudioSources(((Component)source).gameObject, source, val.transform); if (val.GetComponentsInChildren<AudioSource>(true).Length == 0) { CopyNearbyHeliAudio(source, val.transform); } Rigidbody val2 = val.GetComponent<Rigidbody>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<Rigidbody>(); } val2.isKinematic = true; val2.useGravity = false; return val; } internal static void TryCacheHelicopter() { //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) if ((Object)(object)_heliTemplate != (Object)null) { return; } Transform val = FindHelicopterSource(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = CreateHelicopterClone(val, Vector3.zero, Quaternion.identity, keepColliders: false); if (!((Object)(object)val2 == (Object)null)) { ((Object)val2).name = "CP_HeliTemplate"; val2.SetActive(false); if ((Object)(object)Instance != (Object)null) { val2.transform.SetParent(((Component)Instance).transform, false); } else { Object.DontDestroyOnLoad((Object)(object)val2); } _heliTemplate = val2; CacheRopeOffset(val); CarePackagesPlugin.Verbose("[CarePackages] Cached helicopter template from " + GetPath(val)); } } internal static Vector3 GetRopeLocalOffset() { //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_0020: Unknown result type (might be due to invalid IL or missing references) if (!_ropeOffsetReady) { CacheRopeOffset(FindHelicopterSource()); } return _ropeLocalOffset; } private static void CacheRopeOffset(Transform heli) { //IL_0021: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) Transform val = FindRopeSpawnPoint(); if ((Object)(object)heli != (Object)null && (Object)(object)val != (Object)null) { _ropeLocalOffset = heli.InverseTransformPoint(val.position); _ropeOffsetReady = true; CarePackagesPlugin.Verbose("[CarePackages] Crate drop uses PeakSequence rope spawn (no rope spawned). localOffset=" + ((object)Unsafe.As<Vector3, Vector3>(ref _ropeLocalOffset)/*cast due to .constrained prefix*/).ToString()); return; } if ((Object)(object)heli != (Object)null) { Renderer[] componentsInChildren = ((Component)heli).GetComponentsInChildren<Renderer>(true); if (componentsInChildren != null && componentsInChildren.Length != 0 && (Object)(object)componentsInChildren[0] != (Object)null) { Bounds bounds = componentsInChildren[0].bounds; for (int i = 1; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } } _ropeLocalOffset = heli.InverseTransformPoint(new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z)); _ropeOffsetReady = true; CarePackagesPlugin.Verbose("[CarePackages] No ropeSpawnPoint; using heli underside " + ((object)Unsafe.As<Vector3, Vector3>(ref _ropeLocalOffset)/*cast due to .constrained prefix*/).ToString()); return; } } _ropeLocalOffset = new Vector3(0f, -3f, 0f); _ropeOffsetReady = (Object)(object)heli != (Object)null; } private static Transform FindRopeSpawnPoint() { try { if ((Object)(object)Singleton<PeakHandler>.Instance != (Object)null && (Object)(object)Singleton<PeakHandler>.Instance.peakSequence != (Object)null) { PeakSequence component = Singleton<PeakHandler>.Instance.peakSequence.GetComponent<PeakSequence>(); if ((Object)(object)component != (Object)null && (Object)(object)component.ropeSpawnPoint != (Object)null) { return component.ropeSpawnPoint; } } } catch { } try { if ((Object)(object)Singleton<PeakHandler>.Instance != (Object)null && (Object)(object)Singleton<PeakHandler>.Instance.peakSequence != (Object)null) { Transform val = FindNamedChild(Singleton<PeakHandler>.Instance.peakSequence.transform, "ropespawn"); if ((Object)(object)val != (Object)null) { return val; } } } catch { } return null; } private static GameObject SpawnCachedHeli(Vector3 pos, Quaternion rot) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) TryCacheHelicopter(); if ((Object)(object)_heliTemplate == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(_heliTemplate, pos, rot); val.SetActive(true); ((Object)val).name = "CP_DropHeli"; return val; } internal static Transform FindHelicopterSource() { Transform best = null; int bestScore = int.MinValue; try { if ((Object)(object)Singleton<PeakHandler>.Instance != (Object)null && (Object)(object)Singleton<PeakHandler>.Instance.peakSequence != (Object)null) { Transform transform = Singleton<PeakHandler>.Instance.peakSequence.transform; Consider(FindNamedChild(transform, "helicopter"), ref best, ref bestScore); if ((Object)(object)best == (Object)null) { Consider(FindNamedChild(transform, "heli"), ref best, ref bestScore); } } } catch { } Transform[] array = Object.FindObjectsByType<Transform>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (Transform val in array) { if (!((Object)(object)val == (Object)null)) { string name = ((Object)val).name; if (!name.StartsWith("CP_", StringComparison.Ordinal) && (name.IndexOf("Helicopter", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Heli", StringComparison.OrdinalIgnoreCase) >= 0)) { Consider(val, ref best, ref bestScore); } } } return best; } private static void Consider(Transform t, ref Transform best, ref int bestScore) { //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) if ((Object)(object)t == (Object)null || ((Object)t).name.StartsWith("CP_", StringComparison.Ordinal) || IsKilnCutsceneHeli(t)) { return; } int num = CountRenderers(((Component)t).gameObject); if (num > 0) { int num2 = num * 10; Scene scene = ((Component)t).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { num2 += 5; } string path = GetPath(t); if (path.IndexOf("PeakSequence", StringComparison.OrdinalIgnoreCase) >= 0) { num2 += 100; } if (string.Equals(((Object)t).name, "Helicopter", StringComparison.OrdinalIgnoreCase)) { num2 += 50; } if (num2 > bestScore) { bestScore = num2; best = t; } } } private static bool IsKilnCutsceneHeli(Transform t) { if (string.Equals(((Object)t).name, "Helicopter_End", StringComparison.OrdinalIgnoreCase)) { return true; } string path = GetPath(t); return path.IndexOf("Helicopter_End", StringComparison.OrdinalIgnoreCase) >= 0 || path.IndexOf("CutsceneEndingSpot", StringComparison.OrdinalIgnoreCase) >= 0 || path.IndexOf("Cutscene Ending", StringComparison.OrdinalIgnoreCase) >= 0; } private static GameObject AttachParachuteVisual(GameObject crate) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)crate == (Object)null) { return null; } Transform val = FindParachuteSource(); if ((Object)(object)val == (Object)null) { if (!_loggedMissingParachute) { _loggedMissingParachute = true; CarePackagesPlugin.Verbose("[CarePackages] No auto-parachute mesh on a scout yet; crate falls without a chute visual."); } return null; } bool activeSelf = ((Component)val).gameObject.activeSelf; ((Component)val).gameObject.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject); ((Component)val).gameObject.SetActive(activeSelf); ((Object)val2).name = "CP_Parachute"; StripNetworkAndGameplay(val2); Parachute component = val2.GetComponent<Parachute>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } val2.transform.SetParent(crate.transform, false); val2.transform.localPosition = new Vector3(0f, 0.85f, 0f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; val2.SetActive(true); Animator component2 = val2.GetComponent<Animator>(); if ((Object)(object)component2 != (Object)null) { component2.Play("Open", 0, 0f); } return val2; } private static Transform FindParachuteSource() { Character[] array = Object.FindObjectsByType<Character>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (Character val in array) { if (!((Object)(object)val == (Object)null) && val.refs != null && !((Object)(object)val.refs.parachute == (Object)null)) { return ((Component)val.refs.parachute).transform; } } return null; } private static void PlayHeliAudio(GameObject heli) { if ((Object)(object)heli == (Object)null || (Object)(object)Instance == (Object)null) { return; } AudioSource[] componentsInChildren = heli.GetComponentsInChildren<AudioSource>(true); int num = 0; foreach (AudioSource val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.clip == (Object)null)) { ConfigureFlybySource(val, val.clip, val.pitch, 0f); val.volume = 0f; val.Play(); num++; CarePackagesPlugin.Verbose("[CarePackages] Armed heli clip '" + ((Object)val.clip).name + "' len=" + val.clip.length.ToString("0.00") + "s"); } } Instance._heliAudio = componentsInChildren; Instance._heliAudioVol = 0f; if (num == 0) { ManualLogSource log = CarePackagesPlugin.Log; if (log != null) { log.LogWarning((object)"[CarePackages] Helicopter clone has no audio clips to play."); } } } private void TickHeliAudio(Vector3 pos, Vector3 over, float t, float arriveSeconds, float exitSeconds, float dt) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (_heliAudio == null) { return; } float num = pos.x - over.x; float num2 = pos.z - over.z; float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = ((num3 >= 220f) ? 0f : Mathf.InverseLerp(220f, 40f, num3)); float num5 = arriveSeconds + Mathf.Max(0.5f, exitSeconds - 4f); if (t >= num5) { num4 = Mathf.Min(num4, 1f - Mathf.InverseLerp(num5, arriveSeconds + exitSeconds, t)); } num4 *= FlybyVolume(); _heliAudioVol = Mathf.MoveTowards(_heliAudioVol, num4, dt / 2.4f); EnsureMasterAudio(); for (int i = 0; i < _heliAudio.Length; i++) { AudioSource val = _heliAudio[i]; if (!((Object)(object)val == (Object)null)) { if ((Object)(object)_masterMixer != (Object)null && (Object)(object)val.outputAudioMixerGroup == (Object)null) { val.outputAudioMixerGroup = _masterMixer; } val.volume = _heliAudioVol; } } } private void ProbeFeelers(Transform heli, float look, float downLook, out float forward, out float up, out float left, out float right, out float down) { //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_0011: 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) //IL_001b: 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_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) //IL_005b: 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_0082: 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_008e: 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_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_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00c4: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0102: 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) Vector3 origin = heli.position + Vector3.up * 1.5f; Vector3 forward2 = heli.forward; forward2.y = 0f; if (((Vector3)(ref forward2)).sqrMagnitude < 0.01f) { forward2 = heli.forward; } ((Vector3)(ref forward2)).Normalize(); Vector3 val = Vector3.Cross(Vector3.up, forward2); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = heli.right; } ((Vector3)(ref val)).Normalize(); forward = ProbeRay(origin, forward2, look); Vector3 val2 = forward2 + Vector3.up * 0.5f; up = ProbeRay(origin, ((Vector3)(ref val2)).normalized, look); val2 = forward2 - val * 0.6f; left = ProbeRay(origin, ((Vector3)(ref val2)).normalized, look); val2 = forward2 + val * 0.6f; right = ProbeRay(origin, ((Vector3)(ref val2)).normalized, look); down = ProbeRay(origin, Vector3.down, downLook); } private float ProbeRay(Vector3 origin, Vector3 dir, float dist) { //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_0021: 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) int num = Physics.RaycastNonAlloc(origin, dir, ProbeHits, dist, -5, (QueryTriggerInteraction)1); float num2 = dist; Collider val = null; for (int i = 0; i < num; i++) { RaycastHit val2 = ProbeHits[i]; if (IsHeliObstacle(((RaycastHit)(ref val2)).collider) && !(((RaycastHit)(ref val2)).distance >= num2)) { num2 = ((RaycastHit)(ref val2)).distance; val = ((RaycastHit)(ref val2)).collider; } } if ((Object)(object)val != (Object)null && CarePackagesPlugin.LoggingOn) { string hitPath = GetHitPath(val); if (_feelLog.Add(hitPath)) { CarePackagesPlugin.Verbose("[CarePackages] Heli feeler hit " + hitPath + " at " + num2.ToString("0.0") + "m"); } } return num2; } internal static bool IsHeliObstacle(Collider col) { if ((Object)(object)col == (Object)null) { return false; } try { if ((Object)(object)((Component)col).GetComponentInParent<Character>() != (Object)null) { return false; } } catch { } Transform val = ((Component)col).transform; while ((Object)(object)val != (Object)null) { string text = ((Object)val).name ?? string.Empty; if (text.StartsWith("CP_", StringComparison.Ordinal)) { return false; } if (IsIgnoredHeliName(text)) { return false; } val = val.parent; } return true; } private static bool IsIgnoredHeliName(string name) { return name.IndexOf("Fogwall", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("FogWall", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("FogOrigin", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("FogSphere", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("EdgeWall", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RigCollider", StringComparison.OrdinalIgnoreCase) >= 0; } internal static string GetHitPath(Collider col) { if ((Object)(object)col == (Object)null) { return "(null)"; } return GetPath(((Component)col).transform); } private static Vector3 LiftClear(Vector3 pos) { //IL_0006: 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_0082: 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_0061: 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_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) for (int i = 0; i < 12; i++) { int num = Physics.OverlapSphereNonAlloc(pos, 3f, OverlapHits, -5, (QueryTriggerInteraction)1); bool flag = false; for (int j = 0; j < num; j++) { if (IsHeliObstacle(OverlapHits[j])) { flag = true; break; } } if (!flag) { return pos; } pos += Vector3.up * 22f; } return pos; } private static void EnsureMasterAudio() { if ((Object)(object)_masterMixer != (Object)null && _masterVolume != null) { return; } try { if ((Object)(object)GameHandler.Instance == (Object)null || GameHandler.Instance.SettingsHandler == null) { return; } _masterVolume = GameHandler.Instance.SettingsHandler.GetSetting<MasterVolumeSetting>(); if (_masterVolume == null || (Object)(object)((VolumeSetting)_masterVolume).mixerGroup == (Object)null) { return; } AudioMixer audioMixer = ((VolumeSetting)_masterVolume).mixerGroup.audioMixer; if ((Object)(object)audioMixer != (Object)null) { AudioMixerGroup[] array = audioMixer.FindMatchingGroups("Master"); if (array != null && array.Length != 0 && (Object)(object)array[0] != (Object)null) { _masterMixer = array[0]; } } if ((Object)(object)_masterMixer == (Object)null) { _masterMixer = ((VolumeSetting)_masterVolume).mixerGroup; } } catch { } } private static float FlybyVolume() { float num = 1f; if ((Object)(object)CarePackagesPlugin.Instance != (Object)null && CarePackagesPlugin.Instance.VolumeConfig != null) { num = Mathf.Clamp01(CarePackagesPlugin.Instance.VolumeConfig.Value); } EnsureMasterAudio(); if ((Object)(object)_masterMixer != (Object)null) { return num; } if (_masterVolume != null) { return num * Mathf.Clamp01(((FloatSetting)_masterVolume).Value); } return num; } private static void ConfigureFlybySource(AudioSource copy, AudioClip clip, float pitch, float volume) { copy.clip = clip; copy.loop = true; copy.playOnAwake = false; copy.spatialBlend = 0.28f; copy.dopplerLevel = 0f; copy.pitch = pitch; copy.minDistance = 420f; copy.maxDistance = 2500f; copy.rolloffMode = (AudioRolloffMode)1; copy.volume = volume; copy.ignoreListenerPause = true; EnsureMasterAudio(); if ((Object)(object)_masterMixer != (Object)null) { copy.outputAudioMixerGroup = _masterMixer; } } private static void CopyAudioSources(GameObject source, Transform sourceRoot, Transform destRoot) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown AudioSource[] componentsInChildren = source.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.clip == (Object)null)) { GameObject val2 = new GameObject(((Object)val).name + "_Audio"); val2.transform.SetParent(destRoot, false); SetLocalFromWorld(sourceRoot, ((Component)val).transform, val2.transform); ConfigureFlybySource(val2.AddComponent<AudioSource>(), val.clip, val.pitch, FlybyVolume()); } } } private static void CopyNearbyHeliAudio(Transform heli, Transform destRoot) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Transform val = heli; try { if ((Object)(object)Singleton<PeakHandler>.Instance != (Object)null && (Object)(object)Singleton<PeakHandler>.Instance.peakSequence != (Object)null) { val = Singleton<PeakHandler>.Instance.peakSequence.transform; } else if ((Object)(object)heli.parent != (Object)null) { val = heli.parent; } } catch { } AudioSource[] componentsInChildren = ((Component)val).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.clip == (Object)null) && IsHeliAudio(val2)) { GameObject val3 = new GameObject(((Object)val2).name + "_Audio"); val3.transform.SetParent(destRoot, false); val3.transform.localPosition = Vector3.zero; AudioSource copy = val3.AddComponent<AudioSource>(); ConfigureFlybySource(copy, val2.clip, val2.pitch, FlybyVolume()); } } } private static bool IsHeliAudio(AudioSource src) { Transform val = ((Component)src).transform; while ((Object)(object)val != (Object)null) { string text = ((Object)val).name ?? string.Empty; if (text.IndexOf("heli", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("chopper", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("rotor", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("SFX", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } private static string GetPath(Transform t) { string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private static int CountRenderers(GameObject go) { int num = 0; if (go.GetComponentsInChildren<MeshRenderer>(true) != null) { num += go.GetComponentsInChildren<MeshRenderer>(true).Length; } if (go.GetComponentsInChildren<SkinnedMeshRenderer>(true) != null) { num += go.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length; } return num; } private static Transform FindNamedChild(Transform root, string needle) { if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(needle)) { return null; } if (((Object)root).name.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0 && !IsKilnCutsceneHeli(root)) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindNamedChild(root.GetChild(i), needle); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static bool CopyRenderers(GameObject source, Transform sourceRoot, Transform destRoot) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown if ((Object)(object)source == (Object)null || (Object)(object)sourceRoot == (Object)null || (Object)(object)destRoot == (Object)null) { return false; } bool result = false; MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null)) { GameObject val2 = new GameObject(((Object)val).name); val2.transform.SetParent(destRoot, false); SetLocalFromWorld(sourceRoot, ((Component)val).transform, val2.transform); val2.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; MeshRenderer val3 = val2.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterials = ((Renderer)val).sharedMaterials; result = true; } } } SkinnedMeshRenderer[] componentsInChildren2 = source.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val4 in componentsInChildren2) { if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4.sharedMesh == (Object)null)) { GameObject val5 = new GameObject(((Object)val4).name); val5.transform.SetParent(destRoot, false); SetLocalFromWorld(sourceRoot, ((Component)val4).transform, val5.transform); val5.AddComponent<MeshFilter>().sharedMesh = val4.sharedMesh; MeshRenderer val6 = val5.AddComponent<MeshRenderer>(); ((Renderer)val6).sharedMaterials = ((Renderer)val4).sharedMaterials; result = true; } } return result; } private static void CopyColliders(GameObject source, Transform sourceRoot, Transform destRoot) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_00cc: 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) Collider[] componentsInChildren = source.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } GameObject val2 = new GameObject(((Object)val).name + "_Col"); val2.transform.SetParent(destRoot, false); SetLocalFromWorld(sourceRoot, ((Component)val).transform, val2.transform); BoxCollider val3 = (BoxCollider)(object)((val is BoxCollider) ? val : null); if ((Object)(object)val3 != (Object)null) { BoxCollider val4 = val2.AddComponent<BoxCollider>(); val4.center = val3.center; val4.size = val3.size; ((Collider)val4).isTrigger = true; continue; } SphereCollider val5 = (SphereCollider)(object)((val is SphereCollider) ? val : null); if ((Object)(object)val5 != (Object)null) { SphereCollider val6 = val2.AddComponent<SphereCollider>(); val6.center = val5.center; val6.radius = val5.radius; ((Collider)val6).isTrigger = true; continue; } CapsuleCollider val7 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null); if ((Object)(object)val7 != (Object)null) { CapsuleCollider val8 = val2.AddComponent<CapsuleCollider>(); val8.center = val7.center; val8.radius = val7.radius; val8.height = val7.height; val8.direction = val7.direction; ((Collider)val8).isTrigger = true; continue; } MeshCollider val9 = (MeshCollider)(object)((val is MeshCollider) ? val : null); if ((Object)(object)val9 != (Object)null && (Object)(object)val9.sharedMesh != (Object)null) { MeshCollider val10 = val2.AddComponent<MeshCollider>(); val10.sharedMesh = val9.sharedMesh; val10.convex = true; ((Collider)val10).isTrigger = true; } } } private static void SetLocalFromWorld(Transform root, Transform world, Transform dest) { //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_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) //IL_0021: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0051: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) dest.localPosition = root.InverseTransformPoint(world.position); dest.localRotation = Quaternion.Inverse(root.rotation) * world.rotation; Vector3 lossyScale = root.lossyScale; Vector3 lossyScale2 = world.lossyScale; dest.localScale = new Vector3(SafeDiv(lossyScale2.x, lossyScale.x), SafeDiv(lossyScale2.y, lossyScale.y), SafeDiv(lossyScale2.z, lossyScale.z)); } private static float SafeDiv(float a, float b) { if (Mathf.Abs(b) < 0.0001f) { return 1f; } return a / b; } } internal sealed class HostNet : MonoBehaviour, IOnEventCallback, IInRoomCallbacks, IMatchmakingCallbacks { internal const byte EventCode = 183; internal const int ProtocolVersion = 6; private const byte SubConfig = 1; private const byte SubConfigRequest = 2; private const byte SubHeli = 3; private const byte SubCrate = 4; private const float HostSyncTimeoutSeconds = 12f; private const float HostSyncRetrySeconds = 2f; internal static bool HostModConfirmed; internal static bool VanillaHostMode; private Coroutine _debounce; private Coroutine _hostSyncWatch; private float _nextPoll; private bool _loggedJoinState; internal static HostNet Instance { get; private set; } internal static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { return; } GameObject val = new GameObject("CarePackages_Net"); Object.DontDestroyOnLoad((Object)(object)val); Instance = val.AddComponent<HostNet>(); DropVisuals.Ensure(val); try { if (PhotonNetwork.InRoom) { Instance.HandleJoinedRoom(); } } catch { } } private void Awake() { Instance = this; } private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; PhotonNetwork.RemoveCallbackTarget((object)this); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { DropVisuals.TryCacheHelicopter(); } private void Update() { if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { CarePackagesPlugin instance = CarePackagesPlugin.Instance; if (!((Object)(object)instance == (Object)null) && instance.ShouldHandleFlares() && !(Time.unscaledTime < _nextPoll)) { _nextPoll = Time.unscaledTime + 0.5f; instance.PollLitFlares(); } } } public void OnJoinedRoom() { HandleJoinedRoom(); } public void OnLeftRoom() { StopHostSyncWatch(); HostModConfirmed = false; VanillaHostMode = false; _loggedJoinState = false; } public void OnCreatedRoom() { } public void OnCreateRoomFailed(short returnCode, string message) { } public void OnFriendListUpdate(List<FriendInfo> friendList) { } public void OnJoinRandomFailed(short returnCode, string message) { } public void OnJoinRoomFailed(short returnCode, string message) { } public void OnMasterClientSwitched(Player newMasterClient) { if (PhotonNetwork.IsMasterClient) { HostModConfirmed = true; VanillaHostMode = false; BroadcastNow(); StopHostSyncWatch(); } else { HostModConfirmed = false; VanillaHostMode = false; RequestHostSync(); RestartHostSyncWatch(); } } public void OnPlayerEnteredRoom(Player newPlayer) { if (PhotonNetwork.IsMasterClient) { ((MonoBehaviour)this).StartCoroutine(BroadcastAfterDelay(0.5f)); } } public void OnPlayerLeftRoom(Player otherPlayer) { } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } private void HandleJoinedRoom() { _loggedJoinState = false; if (PhotonNetwork.IsMasterClient) { HostModConfirmed = true; VanillaHostMode = false; LogJoinState(); BroadcastNow(); StopHostSyncWatch(); } else { HostModConfirmed = false; VanillaHostMode = false; LogJoinState(); RequestHostSync(); RestartHostSyncWatch(); } } public void OnEvent(EventData e) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (e == null || e.Code != 183 || !(e.CustomData is object[] array) || array.Length < 2) { return; } int num; byte b; try { num = Convert.ToInt32(array[0]); b = Convert.ToByte(array[1]); } catch { return; } if (num != 6) { return; } if (b == 2 && PhotonNetwork.IsMasterClient) { BroadcastNow(); return; } switch (b) { case 1: ApplyHostConfig(array); return; case 3: if (array.Length >= 11) { OnHostSyncReceived(); DropVisuals.Instance?.PlayHeli(new Vector3(ToFloat(array[2]), ToFloat(array[3]), ToFloat(array[4])), ToFloat(array[5]), ToFloat(array[6]), ToFloat(array[7]), ToFloat(array[8]), ToFloat(array[9]), ToDouble(array[10])); return; } break; } if (b == 4 && array.Length >= 12) { OnHostSyncReceived(); string prefabName = array[11] as string; DropVisuals.Instance?.PlayCrate(new Vector3(ToFloat(array[2]), ToFloat(array[3]), ToFloat(array[4])), new Vector3(ToFloat(array[5]), ToFloat(array[6]), ToFloat(array[7])), ToFloat(array[8]), ToFloat(array[9]), ToDouble(array[10]), prefabName); } } internal static void ScheduleBroadcast() { if (!((Object)(object)Instance == (Object)null) && PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { if (Instance._debounce != null) { ((MonoBehaviour)Instance).StopCoroutine(Instance._debounce); } Instance._debounce = ((MonoBehaviour)Instance).StartCoroutine(Instance.DebounceBroadcast()); } } internal static void BroadcastHeli(Vector3 over, float headingY, float arriveSeconds, float exitSeconds, float travelDistance, float flyHeight, double photonStart) { //IL_001c: 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_0038: Unknown result type (might be due to invalid IL or missing references) RaiseOthers(new object[11] { 6, (byte)3, over.x, over.y, over.z, headingY, arriveSeconds, exitSeconds, travelDistance, flyHeight, photonStart }); } internal static void BroadcastCrate(Vector3 start, Vector3 end, float rotY, float duration, double photonStart, string prefabName) { //IL_002e: 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_004a: 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_0066: 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 (string.IsNullOrEmpty(prefabName)) { prefabName = "LuggageEpic"; } RaiseOthers(new object[12] { 6, (byte)4, start.x, start.y, start.z, end.x, end.y, end.z, rotY, duration, photonStart, prefabName }); } private static void RequestHostSync() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)