using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Mirror;
using ModSettingsMenu.Api;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BigFirework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fad2a176aff3f875ce909a8cdd667457731efaa1")]
[assembly: AssemblyProduct("Big Firework")]
[assembly: AssemblyTitle("BigFirework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BigFireworks
{
internal enum LauncherTrigger
{
Off,
Accompany,
Replace
}
internal enum LauncherShow
{
FlareVolley,
RocketSalvo,
GrandFinale
}
internal enum PadAnchor
{
Pressed,
All
}
public class LauncherDirector : MonoBehaviour
{
internal static ConfigEntry<LauncherTrigger> Trigger;
internal static ConfigEntry<LauncherShow> Mode;
internal static ConfigEntry<PadAnchor> PadFrom;
internal static ConfigEntry<float> SalvoDelay;
internal static LauncherDirector Instance;
private readonly List<PeckSwitch> _launcherSwitches = new List<PeckSwitch>();
private bool _running;
private Vector3 _pad;
private bool _wantPad;
private bool _wantSalvo;
private readonly List<PeckEffectParticleNetworked> _queue = new List<PeckEffectParticleNetworked>();
private int _fired;
private int _sentTotal;
private float _nextBeat;
private readonly List<PeckSwitch> _salvo = new List<PeckSwitch>();
private int _salvoFired;
private float _nextSalvo;
private readonly List<Vector3> _pads = new List<Vector3>();
private float _deadline;
private float _diagNext;
internal static void Bind(ConfigEntry<LauncherTrigger> trigger, ConfigEntry<LauncherShow> mode, ConfigEntry<PadAnchor> padFrom, ConfigEntry<float> salvoDelay)
{
Trigger = trigger;
Mode = mode;
PadFrom = padFrom;
SalvoDelay = salvoDelay;
}
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
private void OnDisable()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (_running)
{
_running = false;
SkyDirector.Instance?.ReleaseNight();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Launcher show stopped on disable (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bursts sent).");
}
log.LogInfo(val);
}
_queue.Clear();
_salvo.Clear();
}
internal static bool OnPressPrefix(PeckSwitch sw, PeckContext ctx)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
try
{
if (!NetworkServer.active)
{
return true;
}
if (Show.Enabled == null || !Show.Enabled.Value)
{
return true;
}
if (Trigger == null || Trigger.Value != LauncherTrigger.Replace)
{
return true;
}
if (!IsLauncherSwitch(sw))
{
return true;
}
if (!IsLocalPresser(ctx))
{
return true;
}
LauncherDirector instance = Instance;
if ((Object)(object)instance == (Object)null)
{
return true;
}
instance.TriggerFromPress(sw);
return false;
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Launcher hook failed (original kept): ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
return true;
}
}
internal static void OnPressPostfix(PeckSwitch sw, PeckContext ctx)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
try
{
if (NetworkServer.active && Show.Enabled != null && Show.Enabled.Value && Trigger != null && Trigger.Value == LauncherTrigger.Accompany && IsLauncherSwitch(sw) && IsLocalPresser(ctx))
{
Instance?.TriggerFromPress(sw);
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Launcher hook failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
private static bool IsLauncherSwitch(PeckSwitch sw)
{
try
{
Transform val = ((sw != null) ? ((Component)sw).transform : null);
int num = 0;
while (num < 6 && (Object)(object)val != (Object)null)
{
if ((((Object)val).name ?? "").Contains("FireworkLauncher"))
{
return true;
}
num++;
val = val.parent;
}
}
catch
{
}
return false;
}
private static bool IsLocalPresser(PeckContext ctx)
{
try
{
PlayerCharacter playerCharacter = ctx.GetPlayerCharacter();
if ((Object)(object)playerCharacter == (Object)null)
{
return false;
}
PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
if ((Object)(object)localPlayerCharacter != (Object)null && (Object)(object)playerCharacter == (Object)(object)localPlayerCharacter)
{
return true;
}
PlayerNetworking playerNetworking = playerCharacter.playerNetworking;
if ((Object)(object)playerNetworking == (Object)null)
{
return false;
}
return ((NetworkBehaviour)playerNetworking).isLocalPlayer;
}
catch
{
return false;
}
}
internal void TriggerFromPress(PeckSwitch sw)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: 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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Expected O, but got Unknown
bool flag = default(bool);
try
{
if (_running)
{
StopShow("restarted");
}
RefreshLaunchers();
try
{
_pad = ((Component)sw).transform.position;
}
catch
{
_pad = Vector3.zero;
}
LauncherShow value = Mode.Value;
_wantPad = value == LauncherShow.FlareVolley || value == LauncherShow.GrandFinale;
_wantSalvo = value == LauncherShow.RocketSalvo || value == LauncherShow.GrandFinale;
_queue.Clear();
_queue.AddRange(Show.BuildColorQueue(Show.ScanFlareEmitters(out var _)));
_salvo.Clear();
_salvoFired = 0;
if (_wantSalvo)
{
BuildSalvo(sw);
}
_pads.Clear();
_pads.Add(_pad);
foreach (PeckSwitch launcherSwitch in _launcherSwitches)
{
try
{
if (!((Object)(object)launcherSwitch == (Object)null))
{
Vector3 position = ((Component)launcherSwitch).transform.position;
Vector3 val = position - _pad;
if (((Vector3)(ref val)).sqrMagnitude > 1f)
{
_pads.Add(position);
}
}
}
catch
{
}
}
if (_queue.Count == 0 && _salvo.Count == 0)
{
Plugin.Log.LogWarning((object)"Launcher show ignored (no colors, no salvo).");
return;
}
_running = true;
_fired = 0;
_sentTotal = 0;
_nextBeat = Time.time;
_nextSalvo = Time.time + 0.5f;
_diagNext = Time.time + 1f;
_deadline = Time.time + 25f;
SkyDirector.Instance?.RequestNight();
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Launcher show: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<LauncherShow>(value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(_pad.x, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(",");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(_pad.y, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(",");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(_pad.z, "0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") pad=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_queue.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" salvo=");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_salvo.Count);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
}
log.LogInfo(val2);
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Launcher show failed to start: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
log2.LogError(val3);
_running = false;
}
}
private void StopShow(string reason)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
if (_running)
{
_running = false;
SkyDirector.Instance?.ReleaseNight();
}
_queue.Clear();
_salvo.Clear();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Launcher show over (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bursts sent).");
}
log.LogInfo(val);
}
private void RefreshLaunchers()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
if (_launcherSwitches.Count > 0)
{
bool flag = true;
for (int i = 0; i < _launcherSwitches.Count; i++)
{
PeckSwitch val = _launcherSwitches[i];
if ((Object)(object)val == (Object)null)
{
flag = false;
break;
}
try
{
if (((Il2CppObjectBase)val).WasCollected)
{
flag = false;
break;
}
}
catch
{
flag = false;
break;
}
}
if (flag)
{
return;
}
}
_launcherSwitches.Clear();
try
{
foreach (PeckSwitch item in Object.FindObjectsOfType<PeckSwitch>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
try
{
if (((Il2CppObjectBase)item).WasCollected)
{
continue;
}
}
catch
{
continue;
}
if (IsLauncherSwitch(item))
{
_launcherSwitches.Add(item);
}
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag2 = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Launcher scan failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
}
private void BuildSalvo(PeckSwitch pressed)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
bool flag = default(bool);
try
{
try
{
_salvo.Add(pressed);
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Salvo pressed add failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
List<PeckSwitch> list = new List<PeckSwitch>();
foreach (PeckSwitch launcherSwitch in _launcherSwitches)
{
if ((Object)(object)launcherSwitch == (Object)null)
{
continue;
}
try
{
if (((Il2CppObjectBase)launcherSwitch).WasCollected)
{
continue;
}
}
catch
{
continue;
}
try
{
if ((Object)(object)launcherSwitch == (Object)(object)pressed)
{
continue;
}
}
catch
{
continue;
}
list.Add(launcherSwitch);
}
list.Sort((PeckSwitch a, PeckSwitch b) => SalvoDist2(a).CompareTo(SalvoDist2(b)));
_salvo.AddRange(list);
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Salvo build failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
}
log2.LogWarning(val);
}
}
private float SalvoDist2(PeckSwitch sw)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
try
{
Vector3 val = ((Component)sw).transform.position - _pad;
return ((Vector3)(ref val)).sqrMagnitude;
}
catch
{
return float.MaxValue;
}
}
private void Update()
{
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Expected O, but got Unknown
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Expected O, but got Unknown
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
bool flag = default(bool);
try
{
if (!_running)
{
return;
}
if (!Show.Enabled.Value)
{
StopShow("disabled");
return;
}
if (Time.time > _deadline)
{
StopShow("timeout");
return;
}
if (Show.Diagnostics.Value && Time.time >= _diagNext)
{
_diagNext = Time.time + 1f;
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Launcher show: fired=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_fired);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_queue.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" sent=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" salvo=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_salvoFired);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_salvo.Count);
}
log.LogInfo(val);
}
if (_salvoFired < _salvo.Count && Time.time >= _nextSalvo)
{
_nextSalvo = Time.time + SalvoDelay.Value;
PeckSwitch val2 = _salvo[_salvoFired++];
try
{
val2.Peck();
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Salvo peck failed: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
log2.LogWarning(val3);
}
}
if (Time.time >= _nextBeat)
{
_nextBeat = Time.time + Show.Interval.Value;
int num = _fired++;
if (_wantPad && num < _queue.Count)
{
FirePad(num);
}
if (_fired >= _queue.Count && _salvoFired >= _salvo.Count)
{
StopShow("complete");
}
}
}
catch (Exception ex2)
{
ManualLogSource log3 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Launcher show failed: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex2);
}
log3.LogError(val4);
if (_running)
{
SkyDirector.Instance?.ReleaseNight();
}
_running = false;
}
}
private void FirePad(int beat)
{
//IL_0037: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (beat < _queue.Count)
{
Vector3 val = ((PadFrom.Value == PadAnchor.All && _pads.Count > 0) ? _pads[beat % _pads.Count] : _pad);
Vector3 pos = val + new Vector3(Random.Range(-0.75f, 0.75f), Show.LaunchHeight.Value, Random.Range(-0.75f, 0.75f));
FireWith(_queue[beat], pos, beat);
}
}
private void FireWith(PeckEffectParticleNetworked e, Vector3 pos, int n)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_002e: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = Show.Aim(-90f, Show.SpreadAngle.Value);
try
{
if ((Object)(object)e == (Object)null)
{
throw new NullReferenceException("emitter gone");
}
e.RpcFire(pos, val);
Show.ScheduleAirBang(pos, val, e);
_sentTotal++;
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(20, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Show burst ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(n);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
}
}
[HarmonyPatch(typeof(PeckSwitch), "Peck", new Type[] { typeof(PeckContext) })]
internal static class LauncherPressPatch
{
[HarmonyPrefix]
private static bool Prefix(PeckSwitch __instance, PeckContext peckContext)
{
return LauncherDirector.OnPressPrefix(__instance, peckContext);
}
[HarmonyPostfix]
private static void Postfix(PeckSwitch __instance, PeckContext peckContext)
{
LauncherDirector.OnPressPostfix(__instance, peckContext);
}
}
[BepInPlugin("walker.bigfireworks", "Big Firework", "1.0.0")]
[BepInDependency("IceBoxStudio.BigWalk.ModSettingsMenu", ">=1.1.0")]
public class Plugin : BasePlugin
{
public const string PLUGIN_GUID = "walker.bigfireworks";
public const string PLUGIN_NAME = "Big Firework";
public const string PLUGIN_VERSION = "1.0.0";
internal static ManualLogSource Log;
public override void Load()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Expected O, but got Unknown
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Expected O, but got Unknown
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Expected O, but got Unknown
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Expected O, but got Unknown
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Expected O, but got Unknown
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Expected O, but got Unknown
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Expected O, but got Unknown
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Expected O, but got Unknown
//IL_0510: Unknown result type (might be due to invalid IL or missing references)
//IL_051a: Expected O, but got Unknown
//IL_056d: Unknown result type (might be due to invalid IL or missing references)
//IL_0577: Expected O, but got Unknown
//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
//IL_05d4: Expected O, but got Unknown
//IL_0611: Unknown result type (might be due to invalid IL or missing references)
//IL_061b: Expected O, but got Unknown
//IL_0669: Unknown result type (might be due to invalid IL or missing references)
//IL_0673: Expected O, but got Unknown
//IL_06b0: Unknown result type (might be due to invalid IL or missing references)
//IL_06ba: Expected O, but got Unknown
//IL_070b: Unknown result type (might be due to invalid IL or missing references)
//IL_0715: Expected O, but got Unknown
//IL_0752: Unknown result type (might be due to invalid IL or missing references)
//IL_075c: Expected O, but got Unknown
//IL_0799: Unknown result type (might be due to invalid IL or missing references)
//IL_07a3: Expected O, but got Unknown
//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0800: Expected O, but got Unknown
//IL_087d: Unknown result type (might be due to invalid IL or missing references)
//IL_0887: Expected O, but got Unknown
//IL_0895: Unknown result type (might be due to invalid IL or missing references)
//IL_089a: Unknown result type (might be due to invalid IL or missing references)
//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08c3: Expected O, but got Unknown
//IL_091c: Unknown result type (might be due to invalid IL or missing references)
//IL_0933: Unknown result type (might be due to invalid IL or missing references)
//IL_093a: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ConfigEntry<bool> enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Master switch. Starts a volley only while this is on.", (AcceptableValueBase)null, new object[2]
{
ModSettingsTags.Section("General", (int?)10),
ModSettingsTags.Entry((int?)10, (double?)null)
}));
ConfigEntry<int> green = BindMigrated("Colors etc.", "Green", "Colors", "Green", 2, new ConfigDescription("Green flare bursts per volley.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[2]
{
ModSettingsTags.Section("Colors etc.", (int?)20),
ModSettingsTags.Entry((int?)10, (double?)null)
}));
ConfigEntry<int> yellow = BindMigrated("Colors etc.", "Yellow", "Colors", "Yellow", 2, new ConfigDescription("Yellow flare bursts per volley.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { ModSettingsTags.Entry((int?)20, (double?)null) }));
ConfigEntry<int> blue = BindMigrated("Colors etc.", "Blue", "Colors", "Blue", 2, new ConfigDescription("Blue flare bursts per volley.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { ModSettingsTags.Entry((int?)30, (double?)null) }));
ConfigEntry<int> red = BindMigrated("Colors etc.", "Red", "Colors", "Red", 2, new ConfigDescription("Red flare bursts per volley (untinted flare gun).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { ModSettingsTags.Entry((int?)40, (double?)null) }));
ConfigEntry<int> teal = BindMigrated("Colors etc.", "Teal", "Colors", "Teal", 2, new ConfigDescription("Teal bursts per volley (fixed flare-run).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { ModSettingsTags.Entry((int?)50, (double?)null) }));
ConfigEntry<float> launchHeight = BindMigratedMulti("Colors etc.", "LaunchHeight", new(string, string)[2]
{
("Colors", "LaunchHeight"),
("Show", "LaunchHeight")
}, 2f, new ConfigDescription("Spawn height above the anchor, in meters (Sky style only).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), new object[1] { ModSettingsTags.Entry((int?)60, (double?)1.0) }));
ConfigEntry<float> spreadAngle = BindMigratedMulti("Colors etc.", "SpreadAngle", new(string, string)[2]
{
("Colors", "SpreadAngle"),
("Show", "SpreadAngle")
}, 8f, new ConfigDescription("Uniform cone around the aim, in degrees (Sky style only; Fountain always sprays wide).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 45f), new object[1] { ModSettingsTags.Entry((int?)70, (double?)1.0) }));
ConfigEntry<float> interval = BindMigratedMulti("Colors etc.", "Interval", new(string, string)[2]
{
("Colors", "Interval"),
("Show", "Interval")
}, 0.8f, new ConfigDescription("Seconds between bursts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), new object[1] { ModSettingsTags.Entry((int?)80, (double?)0.05) }));
ConfigEntry<ShowTarget> target = BindMigrated("Player Show", "Target", "Show", "Target", ShowTarget.Self, new ConfigDescription("Self: every burst launches from you. Everyone: bursts round-robin across all players, one anchor per beat.", (AcceptableValueBase)null, new object[2]
{
ModSettingsTags.Section("Player Show", (int?)30),
ModSettingsTags.Entry((int?)10, (double?)null)
}));
ConfigEntry<bool> follow = ((BasePlugin)this).Config.Bind<bool>("Player Show", "Follow", true, new ConfigDescription("Follow the host as they move around during the show (Self target only).", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)15, (double?)null) }));
ConfigEntry<ShowStyle> style = BindMigrated("Player Show", "Style", "Show", "Style", ShowStyle.Sky, new ConfigDescription("Sky: bursts spawn at LaunchHeight. Fountain: bursts spray from the anchor's feet with a wide cone.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)20, (double?)null) }));
ConfigEntry<bool> flareSounds = ((BasePlugin)this).Config.Bind<bool>("Player Show", "FlareSounds", true, new ConfigDescription("Play authentic flare explosion bang sounds when fireworks burst in the air.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)25, (double?)null) }));
ConfigEntry<bool> fastNight = BindMigratedMulti("Player Show", "Fast Night", new(string, string)[2]
{
("Player Show", "FastForwardNight"),
("Show", "FastForwardNight")
}, defaultValue: true, new ConfigDescription("Fast-forward time to night when the show starts (sun sets fast, stars spin in).", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)30, (double?)null) }));
ConfigEntry<float> targetNightHour = BindMigrated("Player Show", "NightHour", "Show", "NightHour", 0f, new ConfigDescription("Target night hour (0 = midnight, 21 = dusk, 22 = nightfall).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 23.9f), new object[1] { ModSettingsTags.Entry((int?)40, (double?)0.5) }));
ConfigEntry<float> transitionSpeed = BindMigrated("Player Show", "TransitionSpeed", "Show", "TransitionSpeed", 2.5f, new ConfigDescription("Seconds to fast-forward from daytime into night.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), new object[1] { ModSettingsTags.Entry((int?)50, (double?)0.25) }));
ConfigEntry<bool> restoreDaylight = BindMigrated("Player Show", "RestoreDaylight", "Show", "RestoreDaylight", defaultValue: true, new ConfigDescription("Smoothly fast-forward to sunrise / restore daytime when the show completes.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)60, (double?)null) }));
ConfigEntry<float> restoreDelay = ((BasePlugin)this).Config.Bind<float>("Player Show", "RestoreDelay", 5f, new ConfigDescription("Seconds to wait after the show completes before daylight restores.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), new object[1] { ModSettingsTags.Entry((int?)70, (double?)0.5) }));
ConfigEntry<bool> diagnostics = BindMigrated("Player Show", "Diagnostics", "Show", "Diagnostics", defaultValue: false, new ConfigDescription("Log server/emitter/burst counts once a second during a volley.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)80, (double?)null) }));
ConfigEntry<LauncherTrigger> trigger = BindMigrated("Firework Launcher", "Trigger", "Launcher", "Trigger", LauncherTrigger.Off, new ConfigDescription("What happens when YOU press a FireworkLauncher button (host only). Off: vanilla rocket. Accompany: rocket plus the selected show. Replace: show instead of the rocket (normal press suppressed).", (AcceptableValueBase)null, new object[2]
{
ModSettingsTags.Section("Firework Launcher", (int?)40),
ModSettingsTags.Entry((int?)10, (double?)null)
}));
ConfigEntry<LauncherShow> mode = BindMigrated("Firework Launcher", "Show", "Launcher", "Show", LauncherShow.GrandFinale, new ConfigDescription("FlareVolley: flare show at the launcher. RocketSalvo: chain-fire other launchers for real. GrandFinale: both.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)20, (double?)null) }));
ConfigEntry<PadAnchor> padFrom = BindMigrated("Firework Launcher", "PadFrom", "Launcher", "PadFrom", PadAnchor.Pressed, new ConfigDescription("Pad bursts launch from: the pressed launcher, or round-robin across all launchers.", (AcceptableValueBase)null, new object[1] { ModSettingsTags.Entry((int?)30, (double?)null) }));
ConfigEntry<float> salvoDelay = BindMigrated("Firework Launcher", "SalvoDelay", "Launcher", "SalvoDelay", 0.7f, new ConfigDescription("Seconds between salvo launches.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 2f), new object[1] { ModSettingsTags.Entry((int?)40, (double?)0.05) }));
ConfigEntry<KeyCode> toggleKey = BindMigratedMulti<KeyCode>("Input", "Player Show", new(string, string)[2]
{
("Input", "ToggleKey"),
("Input", "Player Show")
}, (KeyCode)291, new ConfigDescription("Start a player firework show (host only).", (AcceptableValueBase)null, new object[2]
{
ModSettingsTags.Section("Input", (int?)100),
ModSettingsTags.Entry((int?)10, (double?)null)
}));
CleanupUnusedConfigs();
ModSettingsRegistry.Register("walker.bigfireworks", new ModSettingsModOptions
{
Name = "Big Firework",
Description = "Synced sky firework show for the whole lobby (host).\n\nSpecial thanks to M4TR!X GG for the thumbnail and to Dexter for testing.",
Version = "1.0.0"
});
Show.Bind(enabled, green, yellow, blue, red, teal, target, follow, style, flareSounds, launchHeight, spreadAngle, interval, diagnostics, toggleKey);
LauncherDirector.Bind(trigger, mode, padFrom, salvoDelay);
SkyDirector.Bind(fastNight, targetNightHour, transitionSpeed, restoreDaylight, restoreDelay);
((BasePlugin)this).AddComponent<Show>();
((BasePlugin)this).AddComponent<LauncherDirector>();
((BasePlugin)this).AddComponent<SkyDirector>();
new Harmony("walker.bigfireworks").PatchAll();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Big Firework v");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded.");
}
log.LogInfo(val);
}
private ConfigEntry<T> BindMigrated<T>(string section, string key, string oldSection, string oldKey, T defaultValue, ConfigDescription desc)
{
return BindMigratedMulti(section, key, new(string, string)[1] { (oldSection, oldKey) }, defaultValue, desc);
}
private ConfigEntry<T> BindMigratedMulti<T>(string section, string key, (string sec, string k)[] oldLocations, T defaultValue, ConfigDescription desc)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
ConfigDefinition val = new ConfigDefinition(section, key);
if (((BasePlugin)this).Config.ContainsKey(val))
{
try
{
ConfigEntryBase val2 = ((BasePlugin)this).Config[val];
if (((val2 != null) ? val2.BoxedValue : null) is T val3)
{
defaultValue = val3;
}
}
catch
{
}
}
else if (oldLocations != null)
{
for (int i = 0; i < oldLocations.Length; i++)
{
(string sec, string k) tuple = oldLocations[i];
string item = tuple.sec;
string item2 = tuple.k;
ConfigDefinition val4 = new ConfigDefinition(item, item2);
if (!((BasePlugin)this).Config.ContainsKey(val4))
{
continue;
}
try
{
ConfigEntryBase val5 = ((BasePlugin)this).Config[val4];
if (((val5 != null) ? val5.BoxedValue : null) is T val6)
{
defaultValue = val6;
}
((BasePlugin)this).Config.Remove(val4);
}
catch
{
continue;
}
break;
}
}
return ((BasePlugin)this).Config.Bind<T>(section, key, defaultValue, desc);
}
private void CleanupUnusedConfigs()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Expected O, but got Unknown
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Expected O, but got Unknown
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Expected O, but got Unknown
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Expected O, but got Unknown
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Expected O, but got Unknown
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Expected O, but got Unknown
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Expected O, but got Unknown
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Expected O, but got Unknown
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Expected O, but got Unknown
ConfigDefinition[] array = (ConfigDefinition[])(object)new ConfigDefinition[34]
{
new ConfigDefinition("Colors", "Green"),
new ConfigDefinition("Colors", "Yellow"),
new ConfigDefinition("Colors", "Blue"),
new ConfigDefinition("Colors", "Red"),
new ConfigDefinition("Colors", "Teal"),
new ConfigDefinition("Colors", "LaunchHeight"),
new ConfigDefinition("Colors", "SpreadAngle"),
new ConfigDefinition("Colors", "Interval"),
new ConfigDefinition("Colors", "Plain"),
new ConfigDefinition("Colors", "Rocket"),
new ConfigDefinition("Show", "Target"),
new ConfigDefinition("Show", "Style"),
new ConfigDefinition("Show", "FastForwardNight"),
new ConfigDefinition("Show", "NightHour"),
new ConfigDefinition("Show", "TransitionSpeed"),
new ConfigDefinition("Show", "RestoreDaylight"),
new ConfigDefinition("Show", "LaunchHeight"),
new ConfigDefinition("Show", "SpreadAngle"),
new ConfigDefinition("Show", "Interval"),
new ConfigDefinition("Show", "Diagnostics"),
new ConfigDefinition("Show", "Pitch"),
new ConfigDefinition("Show", "Bursts"),
new ConfigDefinition("Show", "Height"),
new ConfigDefinition("Show", "Spread"),
new ConfigDefinition("Launcher", "Trigger"),
new ConfigDefinition("Launcher", "Show"),
new ConfigDefinition("Launcher", "SalvoDelay"),
new ConfigDefinition("Launcher", "PadFrom"),
new ConfigDefinition("Launcher", "ChaseTrail"),
new ConfigDefinition("Launcher", "FinaleBursts"),
new ConfigDefinition("Launcher", "FinaleInterval"),
new ConfigDefinition("Launcher", "SalvoSet"),
new ConfigDefinition("Player Show", "FastForwardNight"),
new ConfigDefinition("Input", "ToggleKey")
};
ConfigDefinition[] array2 = array;
foreach (ConfigDefinition val in array2)
{
if (((BasePlugin)this).Config.ContainsKey(val))
{
try
{
((BasePlugin)this).Config.Remove(val);
}
catch
{
}
}
}
}
}
internal enum ShowTarget
{
Self,
Everyone
}
internal enum ShowStyle
{
Sky,
Fountain
}
public class Show : MonoBehaviour
{
private struct PendingAirBang
{
public float PlayTime;
public Vector3 Position;
}
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<int> Green;
internal static ConfigEntry<int> Yellow;
internal static ConfigEntry<int> Blue;
internal static ConfigEntry<int> Red;
internal static ConfigEntry<int> Teal;
internal static ConfigEntry<ShowTarget> Target;
internal static ConfigEntry<bool> Follow;
internal static ConfigEntry<ShowStyle> Style;
internal static ConfigEntry<bool> FlareSounds;
internal static ConfigEntry<float> LaunchHeight;
internal static ConfigEntry<float> SpreadAngle;
internal static ConfigEntry<float> Interval;
internal static ConfigEntry<bool> Diagnostics;
internal static ConfigEntry<KeyCode> ToggleKey;
internal static Show Instance;
private static readonly List<PendingAirBang> _pendingBangs = new List<PendingAirBang>();
private readonly List<PeckEffectParticleNetworked> _emitters = new List<PeckEffectParticleNetworked>();
private readonly List<PeckEffectParticleNetworked> _queue = new List<PeckEffectParticleNetworked>();
private readonly List<PlayerCharacter> _cast = new List<PlayerCharacter>();
private float _revalidate;
private bool _running;
private int _fired;
private int _sentTotal;
private float _nextBeat;
private Vector3 _anchor;
private float _effHeight;
private float _effSpread;
private bool _loggedGuest;
private float _diagNext;
private int _lastEmitterCount = -1;
private static AudioAsset _cachedBangAsset;
private static readonly List<PeckEffectParticleNetworked> _cachedEmitters = new List<PeckEffectParticleNetworked>();
private static float _lastEmitterScanTime = -100f;
private static int _lastSkippedTomatoes = 0;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
internal static void Bind(ConfigEntry<bool> enabled, ConfigEntry<int> green, ConfigEntry<int> yellow, ConfigEntry<int> blue, ConfigEntry<int> red, ConfigEntry<int> teal, ConfigEntry<ShowTarget> target, ConfigEntry<bool> follow, ConfigEntry<ShowStyle> style, ConfigEntry<bool> flareSounds, ConfigEntry<float> launchHeight, ConfigEntry<float> spreadAngle, ConfigEntry<float> interval, ConfigEntry<bool> diagnostics, ConfigEntry<KeyCode> toggleKey)
{
Enabled = enabled;
Green = green;
Yellow = yellow;
Blue = blue;
Red = red;
Teal = teal;
Target = target;
Follow = follow;
Style = style;
FlareSounds = flareSounds;
LaunchHeight = launchHeight;
SpreadAngle = spreadAngle;
Interval = interval;
Diagnostics = diagnostics;
ToggleKey = toggleKey;
}
private static void ProcessPendingAirBangs()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (_pendingBangs.Count == 0)
{
return;
}
float time = Time.time;
for (int num = _pendingBangs.Count - 1; num >= 0; num--)
{
if (time >= _pendingBangs[num].PlayTime)
{
PendingAirBang pendingAirBang = _pendingBangs[num];
_pendingBangs.RemoveAt(num);
PlayAirBang(pendingAirBang.Position);
}
}
}
private void Update()
{
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
bool flag = default(bool);
try
{
ProcessPendingAirBangs();
if (Input.GetKeyDown(ToggleKey.Value))
{
if (!Enabled.Value)
{
Plugin.Log.LogInfo((object)"Fireworks volley ignored (mod disabled).");
return;
}
if (!NetworkServer.active)
{
if (!_loggedGuest)
{
_loggedGuest = true;
Plugin.Log.LogInfo((object)"Fireworks volley ignored (host only in v1).");
}
return;
}
_loggedGuest = false;
if (_running)
{
StopVolley("restarted");
}
StartVolley();
}
if (!_running)
{
return;
}
if (!Enabled.Value)
{
StopVolley("disabled mid-show");
return;
}
if (Diagnostics.Value && Time.time >= _diagNext)
{
_diagNext = Time.time + 1f;
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Show: server=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(NetworkServer.active);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" emitters=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_emitters.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" fired=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_fired);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_queue.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" sent=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
}
log.LogInfo(val);
}
if (Time.time >= _nextBeat)
{
FireBeat();
}
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Show failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log2.LogError(val2);
if (_running)
{
SkyDirector.Instance?.ReleaseNight();
}
_running = false;
_queue.Clear();
_emitters.Clear();
_cast.Clear();
_revalidate = Time.time + 5f;
}
}
private void OnDisable()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (_running)
{
_running = false;
SkyDirector.Instance?.ReleaseNight();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Show stopped on disable (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bursts sent).");
}
log.LogInfo(val);
}
_queue.Clear();
_pendingBangs.Clear();
}
private void StartVolley()
{
//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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
RefreshEmitters(quiet: false);
if (_emitters.Count == 0)
{
Plugin.Log.LogWarning((object)"Fireworks volley ignored (no flare emitters found).");
return;
}
RefreshCast();
_anchor = FindAnchor();
_effHeight = ((Style.Value == ShowStyle.Fountain) ? 0.5f : LaunchHeight.Value);
_effSpread = ((Style.Value == ShowStyle.Fountain) ? Math.Max(SpreadAngle.Value, 25f) : SpreadAngle.Value);
BuildQueue();
if (_queue.Count == 0)
{
Plugin.Log.LogWarning((object)"Fireworks volley ignored (all color counts are 0).");
return;
}
_running = true;
_fired = 0;
_sentTotal = 0;
_nextBeat = Time.time;
_diagNext = Time.time + 1f;
SkyDirector.Instance?.RequestNight();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fireworks volley: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_queue.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bursts, ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ShowStyle>(Style.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" over ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ShowTarget>(Target.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_anchor.x, "0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_anchor.y, "0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(",");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_anchor.z, "0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
}
log.LogInfo(val);
}
private void StopVolley(string reason)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
if (_running)
{
_running = false;
SkyDirector.Instance?.ReleaseNight();
}
_queue.Clear();
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fireworks volley over (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sentTotal);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" bursts sent).");
}
log.LogInfo(val);
}
private Vector3 FindAnchor()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: 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_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
try
{
PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
if ((Object)(object)localPlayerCharacter != (Object)null && (Object)(object)((Component)localPlayerCharacter).transform != (Object)null)
{
return ((Component)localPlayerCharacter).transform.position;
}
}
catch
{
}
bool flag = default(bool);
try
{
List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
if (allPlayerCharacters != null && allPlayerCharacters.Count > 0)
{
for (int i = 0; i < allPlayerCharacters.Count; i++)
{
PlayerCharacter val = allPlayerCharacters[i];
if (!((Object)(object)val == (Object)null))
{
PlayerNetworking playerNetworking = val.playerNetworking;
if ((Object)(object)playerNetworking != (Object)null && ((NetworkBehaviour)playerNetworking).isLocalPlayer && (Object)(object)((Component)val).transform != (Object)null)
{
return ((Component)val).transform.position;
}
}
}
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Anchor scan fast-path failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
try
{
foreach (PlayerCharacter item in Object.FindObjectsOfType<PlayerCharacter>())
{
PlayerNetworking val3 = ((item != null) ? item.playerNetworking : null);
if ((Object)(object)val3 == (Object)null || !((NetworkBehaviour)val3).isLocalPlayer)
{
continue;
}
return ((Component)item).transform.position;
}
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Anchor scan fallback failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
}
log2.LogWarning(val2);
}
try
{
if (_emitters.Count > 0 && (Object)(object)_emitters[0] != (Object)null)
{
return ((Component)_emitters[0]).transform.position;
}
}
catch
{
}
return Vector3.zero;
}
private void RefreshCast()
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Expected O, but got Unknown
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Expected O, but got Unknown
_cast.Clear();
bool flag = default(bool);
try
{
List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
if (allPlayerCharacters != null && allPlayerCharacters.Count > 0)
{
for (int i = 0; i < allPlayerCharacters.Count; i++)
{
PlayerCharacter val = allPlayerCharacters[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
try
{
if (((Il2CppObjectBase)val).WasCollected)
{
continue;
}
}
catch
{
continue;
}
try
{
if ((Object)(object)((Component)val).transform == (Object)null)
{
continue;
}
}
catch
{
continue;
}
_cast.Add(val);
}
_cast.Sort((PlayerCharacter a, PlayerCharacter b) => string.CompareOrdinal(SafeName(a), SafeName(b)));
return;
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Cast scan fast-path failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
try
{
foreach (PlayerCharacter item in Object.FindObjectsOfType<PlayerCharacter>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
try
{
if (((Il2CppObjectBase)item).WasCollected)
{
continue;
}
}
catch
{
continue;
}
try
{
if ((Object)(object)((Component)item).transform == (Object)null)
{
continue;
}
}
catch
{
continue;
}
_cast.Add(item);
}
_cast.Sort((PlayerCharacter a, PlayerCharacter b) => string.CompareOrdinal(SafeName(a), SafeName(b)));
}
catch (Exception ex2)
{
ManualLogSource log2 = Plugin.Log;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Cast scan fallback failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
}
log2.LogWarning(val2);
}
}
private static string SafeName(PlayerCharacter pc)
{
try
{
return ((pc != null) ? ((Object)pc).name : null) ?? "";
}
catch
{
return "";
}
}
private Vector3 BeatAnchor(int beat)
{
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if (Target.Value == ShowTarget.Everyone)
{
try
{
for (int num = _cast.Count - 1; num >= 0; num--)
{
PlayerCharacter val = _cast[num];
bool flag = (Object)(object)val == (Object)null;
if (!flag)
{
try
{
flag = ((Il2CppObjectBase)val).WasCollected || (Object)(object)((Component)val).transform == (Object)null;
}
catch
{
flag = true;
}
}
if (flag)
{
_cast.RemoveAt(num);
}
}
if (_cast.Count > 0)
{
return ((Component)_cast[beat % _cast.Count]).transform.position;
}
}
catch
{
}
}
if (Follow != null && Follow.Value)
{
Vector3 val2 = FindAnchor();
if (val2 != Vector3.zero)
{
_anchor = val2;
}
}
return _anchor;
}
internal static string Bucket(PeckEffectParticleNetworked e)
{
try
{
Transform val = ((e != null) ? ((Component)e).transform : null);
int num = 0;
while (num < 4 && (Object)(object)val != (Object)null)
{
string text = ((Object)val).name ?? "";
if (text.Contains("Pomodoro"))
{
return "Tomato";
}
if (text.Contains("FixedFlare") || text.Contains("Rocket"))
{
return "Teal";
}
if (text.Contains("Green"))
{
return "Green";
}
if (text.Contains("Blue"))
{
return "Blue";
}
if (text.Contains("Yellow"))
{
return "Yellow";
}
num++;
val = val.parent;
}
val = ((e != null) ? ((Component)e).transform : null);
int num2 = 0;
while (num2 < 4 && (Object)(object)val != (Object)null)
{
if ((((Object)val).name ?? "").Contains("FlareGunProp"))
{
return "Red";
}
num2++;
val = val.parent;
}
}
catch
{
}
return "Other";
}
internal static List<PeckEffectParticleNetworked> BuildColorQueue(List<PeckEffectParticleNetworked> emitters)
{
List<PeckEffectParticleNetworked> list = new List<PeckEffectParticleNetworked>();
Dictionary<string, List<PeckEffectParticleNetworked>> dictionary = new Dictionary<string, List<PeckEffectParticleNetworked>>();
foreach (PeckEffectParticleNetworked emitter in emitters)
{
string key = Bucket(emitter);
if (!dictionary.TryGetValue(key, out var value))
{
value = (dictionary[key] = new List<PeckEffectParticleNetworked>());
}
value.Add(emitter);
}
List<KeyValuePair<List<PeckEffectParticleNetworked>, int>> list3 = new List<KeyValuePair<List<PeckEffectParticleNetworked>, int>>();
Take(list3, dictionary, "Green", Green.Value);
Take(list3, dictionary, "Yellow", Yellow.Value);
Take(list3, dictionary, "Blue", Blue.Value);
Take(list3, dictionary, "Red", Red.Value);
Take(list3, dictionary, "Teal", Teal.Value);
int[] array = new int[list3.Count];
for (int i = 0; i < list3.Count; i++)
{
array[i] = list3[i].Value;
}
bool flag;
do
{
flag = false;
for (int j = 0; j < list3.Count; j++)
{
if (array[j] > 0)
{
List<PeckEffectParticleNetworked> key2 = list3[j].Key;
if (key2.Count != 0)
{
PeckEffectParticleNetworked item = key2[0];
key2.RemoveAt(0);
key2.Add(item);
array[j]--;
list.Add(item);
flag = true;
}
}
}
}
while (flag);
return list;
}
private void BuildQueue()
{
_queue.Clear();
_queue.AddRange(BuildColorQueue(_emitters));
}
private static void Take(List<KeyValuePair<List<PeckEffectParticleNetworked>, int>> takes, Dictionary<string, List<PeckEffectParticleNetworked>> byBucket, string bucket, int n)
{
if (n > 0 && byBucket.TryGetValue(bucket, out var value) && value.Count > 0)
{
takes.Add(new KeyValuePair<List<PeckEffectParticleNetworked>, int>(value, n));
}
}
private void FireBeat()
{
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0069: 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_009c: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
if (_fired >= _queue.Count)
{
StopVolley("complete");
return;
}
_nextBeat = Time.time + Interval.Value;
int num = _fired++;
PeckEffectParticleNetworked val = _queue[num];
Vector3 val2 = BeatAnchor(num) + new Vector3(Random.Range(-0.75f, 0.75f), _effHeight, Random.Range(-0.75f, 0.75f));
Quaternion val3 = Aim(-90f, _effSpread);
try
{
if ((Object)(object)val == (Object)null)
{
throw new NullReferenceException("emitter gone");
}
val.RpcFire(val2, val3);
ScheduleAirBang(val2, val3, val);
_sentTotal++;
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Burst ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" failed, dropping emitter: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val4);
_emitters.Remove(val);
}
}
private static Vector3 GetListenerPosition()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Camera.main != (Object)null)
{
return ((Component)Camera.main).transform.position;
}
PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
if ((Object)(object)localPlayerCharacter != (Object)null && (Object)(object)((Component)localPlayerCharacter).transform != (Object)null)
{
return ((Component)localPlayerCharacter).transform.position;
}
}
catch
{
}
return Vector3.zero;
}
internal static ParticleOneShotSound FindParticleOneShotSound(PeckEffectParticleNetworked e)
{
if ((Object)(object)e == (Object)null)
{
return null;
}
try
{
if ((Object)(object)e.targetParticleSystem != (Object)null)
{
ParticleOneShotSound val = ((Component)e.targetParticleSystem).GetComponent<ParticleOneShotSound>() ?? ((Component)e.targetParticleSystem).GetComponentInChildren<ParticleOneShotSound>(true);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return ((Component)e).GetComponent<ParticleOneShotSound>() ?? ((Component)e).GetComponentInChildren<ParticleOneShotSound>(true) ?? ((Component)e).GetComponentInParent<ParticleOneShotSound>(true);
}
catch
{
}
return null;
}
private static void DiscoverBangAsset(PeckEffectParticleNetworked e)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
if ((Object)(object)_cachedBangAsset != (Object)null)
{
return;
}
ParticleOneShotSound val = FindParticleOneShotSound(e);
if (((val != null) ? val.Assets : null) == null || ((Il2CppArrayBase<AudioAsset>)(object)val.Assets).Length <= 0)
{
return;
}
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val3;
for (int i = 0; i < ((Il2CppArrayBase<AudioAsset>)(object)val.Assets).Length; i++)
{
AudioAsset val2 = ((Il2CppArrayBase<AudioAsset>)(object)val.Assets)[i];
if ((Object)(object)val2 != (Object)null && !((Object)val2).name.Contains("close", StringComparison.OrdinalIgnoreCase))
{
_cachedBangAsset = val2;
ManualLogSource log = Plugin.Log;
val3 = new BepInExInfoLogInterpolatedStringHandler(67, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Big Firework: Discovered native flare explosion AudioAsset '");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val2).name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' from ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)((Component)val).gameObject).name);
}
log.LogInfo(val3);
return;
}
}
_cachedBangAsset = ((Il2CppArrayBase<AudioAsset>)(object)val.Assets)[0];
ManualLogSource log2 = Plugin.Log;
val3 = new BepInExInfoLogInterpolatedStringHandler(67, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Big Firework: Discovered native flare explosion AudioAsset '");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)_cachedBangAsset).name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' from ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)((Component)val).gameObject).name);
}
log2.LogInfo(val3);
}
internal static void ScheduleAirBang(Vector3 pos, Quaternion rot, PeckEffectParticleNetworked e)
{
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if (FlareSounds == null || !FlareSounds.Value)
{
return;
}
if ((Object)(object)_cachedBangAsset == (Object)null)
{
DiscoverBangAsset(e);
}
try
{
Vector3 val = pos + rot * Vector3.forward * 35.7f;
Vector3 listenerPosition = GetListenerPosition();
float num = Vector3.Distance(listenerPosition, val);
float num2 = num / 343f;
_pendingBangs.Add(new PendingAirBang
{
PlayTime = Time.time + 1.75f + num2,
Position = val
});
}
catch (Exception ex)
{
if (Diagnostics != null && Diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ScheduleAirBang error: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
}
}
internal static void PlayAirBang(Vector3 airPos)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (FlareSounds == null || !FlareSounds.Value || (Object)(object)_cachedBangAsset == (Object)null)
{
return;
}
try
{
AudioPlayHelper.CreateEventAndPlay(_cachedBangAsset, airPos, (Object)null, (IAudioRTPCXProvider)null, (Transform)null, true, -1f, (FuncOneOut<XAxisType, float, bool>)null, (Func<float>)null, false);
}
catch (Exception ex)
{
if (Diagnostics != null && Diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PlayAirBang error: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val);
}
}
}
internal static Quaternion Aim(float pitchDeg, float spreadDeg)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
float num = (0f - pitchDeg) * ((float)Math.PI / 180f);
Vector3 center = default(Vector3);
((Vector3)(ref center))..ctor(0f, Mathf.Sin(num), Mathf.Cos(num));
return Quaternion.LookRotation(ConeSample(center, spreadDeg));
}
internal static List<PeckEffectParticleNetworked> ScanFlareEmitters(out int skippedTomatoes, bool forceRescan = false)
{
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
if (!forceRescan && _cachedEmitters.Count > 0 && Time.time - _lastEmitterScanTime < 15f)
{
PeckEffectParticleNetworked val = _cachedEmitters[0];
if ((Object)(object)val != (Object)null)
{
bool flag = false;
try
{
flag = ((Il2CppObjectBase)val).WasCollected;
}
catch
{
flag = true;
}
if (!flag)
{
skippedTomatoes = _lastSkippedTomatoes;
return _cachedEmitters;
}
}
}
_cachedEmitters.Clear();
skippedTomatoes = 0;
try
{
foreach (PeckEffectParticleNetworked item in Object.FindObjectsOfType<PeckEffectParticleNetworked>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
try
{
if (((Il2CppObjectBase)item).WasCollected)
{
continue;
}
}
catch
{
continue;
}
if (Bucket(item) == "Tomato")
{
skippedTomatoes++;
}
else
{
_cachedEmitters.Add(item);
}
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag2 = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Emitter scan failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogWarning(val2);
}
_lastEmitterScanTime = Time.time;
_lastSkippedTomatoes = skippedTomatoes;
return _cachedEmitters;
}
internal static Vector3 ConeSample(Vector3 center, float degrees)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
if (degrees <= 0f)
{
return center;
}
float num = degrees * ((float)Math.PI / 180f);
Vector3 val = ((Mathf.Abs(center.y) > 0.99f) ? Vector3.forward : Vector3.up);
Vector3 val2 = Vector3.Cross(val, center);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Vector3 val3 = Vector3.Cross(center, normalized);
float num2 = Mathf.Sqrt(Random.Range(0f, 1f)) * Mathf.Tan(num);
float num3 = Random.Range(0f, (float)Math.PI * 2f);
val2 = center + (normalized * Mathf.Cos(num3) + val3 * Mathf.Sin(num3)) * num2;
return ((Vector3)(ref val2)).normalized;
}
private void RefreshEmitters(bool quiet)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
_emitters.Clear();
_emitters.AddRange(ScanFlareEmitters(out var skippedTomatoes));
_revalidate = Time.time + 5f;
if (!quiet && (Diagnostics.Value || _emitters.Count != _lastEmitterCount))
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_emitters.Count);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" flare emitters (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(skippedTomatoes);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" pomodoro dispensers skipped).");
}
log.LogInfo(val);
}
_lastEmitterCount = _emitters.Count;
}
}
public class SkyDirector : MonoBehaviour
{
private enum SkyState
{
Idle,
FastForwardingToNight,
HoldingNight,
WaitingToRestore,
RestoringDaylight
}
internal static ConfigEntry<bool> FastNight;
internal static ConfigEntry<float> TargetNightHour;
internal static ConfigEntry<float> TransitionSpeed;
internal static ConfigEntry<bool> RestoreDaylight;
internal static ConfigEntry<float> RestoreDelay;
private SkyState _state = SkyState.Idle;
private float _originalHour;
private float _fromHour;
private float _targetHour;
private float _forwardDistance;
private float _transitionStartTime;
private float _transitionDuration;
private float _restoreTime;
private int _activeShowsCount;
internal static SkyDirector Instance { get; private set; }
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
RestoreImmediate();
}
private void OnDisable()
{
RestoreImmediate();
}
internal static void Bind(ConfigEntry<bool> fastNight, ConfigEntry<float> targetNightHour, ConfigEntry<float> transitionSpeed, ConfigEntry<bool> restoreDaylight, ConfigEntry<float> restoreDelay)
{
FastNight = fastNight;
TargetNightHour = targetNightHour;
TransitionSpeed = transitionSpeed;
RestoreDaylight = restoreDaylight;
RestoreDelay = restoreDelay;
}
public void RequestNight()
{
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Expected O, but got Unknown
if (!NetworkServer.active || FastNight == null || !FastNight.Value || !SkyManager.initalized)
{
return;
}
_activeShowsCount++;
if (_activeShowsCount > 1 && (_state == SkyState.FastForwardingToNight || _state == SkyState.HoldingNight))
{
return;
}
if (_state == SkyState.WaitingToRestore)
{
_state = SkyState.HoldingNight;
return;
}
float currentTime = SkyManager.GetCurrentTime();
if (_state == SkyState.Idle)
{
_originalHour = currentTime;
}
_fromHour = currentTime;
_targetHour = Mathf.Repeat(TargetNightHour?.Value ?? 0f, 24f);
float num;
for (num = _targetHour - _fromHour; num < 0f; num += 24f)
{
}
_forwardDistance = num;
_transitionDuration = Mathf.Max(0.5f, TransitionSpeed?.Value ?? 2.5f);
_transitionStartTime = Time.time;
_state = SkyState.FastForwardingToNight;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(71, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SkyDirector: Fast-forwarding time from ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_fromHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h to night ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_targetHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_forwardDistance, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h forward over ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_transitionDuration, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s).");
}
log.LogInfo(val);
}
public void ReleaseNight()
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
if (!NetworkServer.active)
{
return;
}
if (_activeShowsCount > 0)
{
_activeShowsCount--;
}
if (_activeShowsCount > 0 || _state == SkyState.Idle)
{
return;
}
if (!SkyManager.initalized)
{
_state = SkyState.Idle;
return;
}
if (RestoreDaylight == null || !RestoreDaylight.Value)
{
RestoreImmediate();
return;
}
float num = ((RestoreDelay != null) ? Mathf.Max(0f, RestoreDelay.Value) : 0f);
if (num > 0f)
{
_restoreTime = Time.time + num;
_state = SkyState.WaitingToRestore;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SkyDirector: Night held for ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s before daylight restores.");
}
log.LogInfo(val);
}
else
{
BeginRestoringDaylight();
}
}
private void BeginRestoringDaylight()
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
if (!NetworkServer.active || !SkyManager.initalized)
{
RestoreImmediate();
return;
}
float currentTime = SkyManager.GetCurrentTime();
_fromHour = currentTime;
_targetHour = _originalHour;
float num;
for (num = _targetHour - _fromHour; num < 0f; num += 24f)
{
}
_forwardDistance = num;
_transitionDuration = Mathf.Max(0.5f, (TransitionSpeed?.Value ?? 2.5f) * 0.8f);
_transitionStartTime = Time.time;
_state = SkyState.RestoringDaylight;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(74, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SkyDirector: Fast-forwarding time from ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_fromHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h to daylight ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_targetHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_forwardDistance, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h forward over ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_transitionDuration, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s).");
}
log.LogInfo(val);
}
private void Update()
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Expected O, but got Unknown
bool flag = default(bool);
if (!NetworkServer.active || !SkyManager.initalized)
{
if (_state != SkyState.Idle)
{
_state = SkyState.Idle;
}
}
else if (_state == SkyState.FastForwardingToNight)
{
float num = Time.time - _transitionStartTime;
float num2 = Mathf.Clamp01(num / _transitionDuration);
float num3 = Mathf.SmoothStep(0f, 1f, num2);
float fixedTime = Mathf.Repeat(_fromHour + _forwardDistance * num3, 24f);
SkyManager.SetFixedTime(fixedTime);
if (num2 >= 1f)
{
_state = SkyState.HoldingNight;
SkyManager.SetFixedTime(_targetHour);
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SkyDirector: Night reached (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_targetHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h locked for firework show).");
}
log.LogInfo(val);
}
}
else if (_state == SkyState.HoldingNight || _state == SkyState.WaitingToRestore)
{
SkyManager.SetFixedTime(_targetHour);
if (_state == SkyState.WaitingToRestore && Time.time >= _restoreTime)
{
BeginRestoringDaylight();
}
}
else
{
if (_state != SkyState.RestoringDaylight)
{
return;
}
float num4 = Time.time - _transitionStartTime;
float num5 = Mathf.Clamp01(num4 / _transitionDuration);
float num6 = Mathf.SmoothStep(0f, 1f, num5);
float fixedTime2 = Mathf.Repeat(_fromHour + _forwardDistance * num6, 24f);
SkyManager.SetFixedTime(fixedTime2);
if (num5 >= 1f)
{
RestoreImmediate();
ManualLogSource log2 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SkyDirector: Daylight restored (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_originalHour, "0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("h), natural clock resumed.");
}
log2.LogInfo(val);
}
}
}
public void RestoreImmediate()
{
_activeShowsCount = 0;
_state = SkyState.Idle;
_restoreTime = 0f;
if (SkyManager.initalized)
{
try
{
SkyManager.ClearFixedTime();
}
catch
{
}
}
}
}
}