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.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Mirror;
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("EnderBuoy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+4259bc4c0c5e16625dfac9c9527ce922b41aee95")]
[assembly: AssemblyProduct("Enderpearl-style buoy teleport")]
[assembly: AssemblyTitle("EnderBuoy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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;
}
}
}
public sealed class SettingsSectionTag
{
public string Section { get; set; }
public int? Order { get; set; }
}
public sealed class SettingsEntryTag
{
public int? Order { get; set; }
public double? SliderStep { get; set; }
}
public static class SettingsTags
{
public static SettingsSectionTag Section(string section, int? order = null)
{
return new SettingsSectionTag
{
Section = section,
Order = order
};
}
public static SettingsEntryTag Entry(int? order = null, double? sliderStep = null)
{
return new SettingsEntryTag
{
Order = order,
SliderStep = sliderStep
};
}
}
namespace EnderBuoy
{
public class Blink : MonoBehaviour
{
private struct PlayerPalette
{
public Color32 Smoke;
public Color32 SparkPrimary;
public Color32 SparkGlow;
public Color32 SparkAccent;
}
private static ConfigEntry<bool> _enabled;
private static ConfigEntry<bool> _blink;
private static ConfigEntry<bool> _requireLit;
private static ConfigEntry<bool> _diagnostics;
private static ConfigEntry<bool> _playSound;
private static ConfigEntry<bool> _spawnSmoke;
private static ConfigEntry<bool> _autoRetrieve;
private static ConfigEntry<bool> _flightTrail;
private static ConfigEntry<float> _maxDist;
private static ConfigEntry<float> _timeout;
private static ConfigEntry<KeyCode> _key;
private static bool _tracking;
private static Prop _trackedProp;
private static Transform _trackedTransform;
private static Rigidbody _trackedRb;
private static Vector3 _releasePoint;
private static float _releaseTime;
private static float _ignoreUntil;
private static float _prevSpeed;
private static float _lastSafeY = float.MinValue;
private static float _nextDiag;
private static GameObject _smokeTemplate;
private static GameObject _flightTrailObj;
private static ParticleSystem _flightTrailPs;
private static readonly Dictionary<int, Vector3> _lastPlayerPositions = new Dictionary<int, Vector3>();
private static readonly List<Prop> _cachedBuoys = new List<Prop>();
private static float _nextBuoyScanTime = -100f;
private static float _pendingArrivalPuffTime = -1f;
private const float KillMargin = 30f;
private const float MinThrowSqrImpulse = 4f;
private static float _nextPlayerScan;
private static PlayerCharacter[] _cachedPlayers;
private const float PlayerStandingVerticalOffset = 0.7f;
public static bool Armed => _enabled != null && _blink != null && _enabled.Value && _blink.Value;
public static void Bind(ConfigEntry<bool> enabled, ConfigEntry<bool> blink, ConfigEntry<bool> requireLit, ConfigEntry<float> maxDist, ConfigEntry<float> timeout, ConfigEntry<bool> diagnostics, ConfigEntry<KeyCode> key, ConfigEntry<bool> playSound, ConfigEntry<bool> spawnSmoke, ConfigEntry<bool> autoRetrieve, ConfigEntry<bool> flightTrail)
{
_enabled = enabled;
_blink = blink;
_requireLit = requireLit;
_maxDist = maxDist;
_timeout = timeout;
_diagnostics = diagnostics;
_key = key;
_playSound = playSound;
_spawnSmoke = spawnSmoke;
_autoRetrieve = autoRetrieve;
_flightTrail = flightTrail;
}
private static bool IsBuoyName(string name)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
return name.IndexOf("buoy", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("bouy", StringComparison.OrdinalIgnoreCase) >= 0;
}
private static Transform FindBouyLight(Transform root)
{
if ((Object)(object)root == (Object)null)
{
return null;
}
try
{
for (int i = 0; i < root.childCount; i++)
{
Transform child = root.GetChild(i);
if (!((Object)(object)child == (Object)null))
{
string name = ((Object)((Component)child).gameObject).name;
if ((string.Equals(name, "bouyLight", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "buoyLight", StringComparison.OrdinalIgnoreCase)) && (Object)(object)((Component)child).GetComponent<Prop>() == (Object)null)
{
return child;
}
Transform val = FindBouyLight(child);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
}
}
catch
{
}
return null;
}
private static bool IsLit(Prop prop, PlayerCharacter holder)
{
try
{
if ((Object)(object)prop != (Object)null && (Object)(object)((Component)prop).gameObject != (Object)null)
{
Transform val = FindBouyLight(((Component)prop).gameObject.transform);
if ((Object)(object)val != (Object)null)
{
return ((Component)val).gameObject.activeSelf;
}
}
}
catch
{
}
try
{
Transform val2 = (((Object)(object)holder != (Object)null) ? FindDescendant(((Component)holder).transform, "grasperHand") : null);
if ((Object)(object)val2 != (Object)null)
{
Transform val3 = FindBouyLight(val2);
if ((Object)(object)val3 != (Object)null)
{
return ((Component)val3).gameObject.activeSelf;
}
}
}
catch
{
}
return false;
}
private static Transform FindDescendant(Transform root, string name)
{
if ((Object)(object)root == (Object)null)
{
return null;
}
for (int i = 0; i < root.childCount; i++)
{
Transform val = null;
try
{
val = root.GetChild(i);
}
catch
{
continue;
}
if ((Object)(object)val == (Object)null)
{
continue;
}
try
{
if (((Object)((Component)val).gameObject).name == name)
{
return val;
}
}
catch
{
continue;
}
Transform val2 = FindDescendant(val, name);
if (!((Object)(object)val2 != (Object)null))
{
continue;
}
return val2;
}
return null;
}
private static PlayerCharacter LocalPlayer()
{
try
{
PlayerCharacter localPlayerCharacter = WorldManager.localPlayerCharacter;
if ((Object)(object)localPlayerCharacter != (Object)null)
{
return localPlayerCharacter;
}
}
catch
{
}
try
{
List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
if (allPlayerCharacters != null)
{
for (int i = 0; i < allPlayerCharacters.Count; i++)
{
PlayerCharacter val = allPlayerCharacters[i];
if ((Object)(object)val != (Object)null && (Object)(object)val.playerNetworking != (Object)null && ((NetworkBehaviour)val.playerNetworking).isLocalPlayer)
{
return val;
}
}
}
}
catch
{
}
return null;
}
private static bool IsPlayerCollider(Collider col)
{
if ((Object)(object)col == (Object)null)
{
return false;
}
try
{
if ((Object)(object)((Component)col).GetComponentInParent<PlayerCharacter>() != (Object)null)
{
return true;
}
}
catch
{
}
return false;
}
internal static void OnThrown(Prop prop, PlayerCharacter holder, Vector3 throwForce)
{
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Expected O, but got Unknown
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Expected O, but got Unknown
//IL_0302: 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_00e6: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Expected O, but got Unknown
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
if (!Armed)
{
return;
}
bool flag = false;
try
{
flag = (Object)(object)holder != (Object)null && (Object)(object)holder.playerNetworking != (Object)null && ((NetworkBehaviour)holder.playerNetworking).isLocalPlayer;
}
catch
{
return;
}
if (!flag)
{
return;
}
string text = "";
try
{
text = (((Object)(object)prop != (Object)null && (Object)(object)((Component)prop).gameObject != (Object)null) ? ((Object)((Component)prop).gameObject).name : "");
}
catch
{
return;
}
if (!IsBuoyName(text))
{
return;
}
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val;
if (((Vector3)(ref throwForce)).sqrMagnitude < 4f)
{
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(49, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: release ignored (gentle drop, force=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref throwForce)).magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
}
log.LogInfo(val);
}
return;
}
if (_tracking)
{
Plugin.Log.LogInfo((object)"EnderBuoy: throw ignored, already tracking an active flight.");
return;
}
bool flag3 = true;
if (_requireLit != null && _requireLit.Value)
{
flag3 = IsLit(prop, holder);
}
ManualLogSource log2 = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(39, 4, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: THROW prop=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" lit=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" force=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(((Vector3)(ref throwForce)).magnitude, "F1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" pos=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)prop).gameObject.transform.position);
}
log2.LogInfo(val);
if (!flag3)
{
Plugin.Log.LogInfo((object)"EnderBuoy: throw ignored (unlit buoy).");
return;
}
try
{
_trackedProp = prop;
_trackedTransform = ((Component)prop).gameObject.transform;
_trackedRb = ((Component)prop).GetComponent<Rigidbody>();
_releasePoint = _trackedTransform.position;
_releaseTime = Time.time;
_ignoreUntil = Time.time + 0.05f;
_prevSpeed = ((Vector3)(ref throwForce)).magnitude;
_nextDiag = Time.time + 1f;
_lastSafeY = float.MinValue;
try
{
PlayerCharacter val2 = LocalPlayer();
PlayerGround val3 = (((Object)(object)val2 != (Object)null) ? val2.ground : null);
if (val3 != null)
{
_lastSafeY = val3.lastSafePosition.y;
}
}
catch
{
}
_tracking = true;
ManualLogSource log3 = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: tracking start release=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(_releasePoint);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" safeY=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_lastSafeY);
}
log3.LogInfo(val);
AttachFlightTrail(_trackedTransform, holder);
}
catch (Exception ex)
{
ManualLogSource log4 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(46, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("EnderBuoy: error initializing throw tracking: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
}
log4.LogError(val4);
_tracking = false;
_trackedProp = null;
_trackedTransform = null;
_trackedRb = null;
}
}
internal static void OnDroppedWithoutForce(Prop prop, PlayerCharacter holder)
{
}
internal static void OnPropCollisionEnter(GameObject go, Collision col)
{
//IL_010e: 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_00c9: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
if (!_tracking || (Object)(object)_trackedProp == (Object)null || (Object)(object)go == (Object)null || Time.time < _ignoreUntil || (Object)(object)go != (Object)(object)((Component)_trackedProp).gameObject || (col != null && (Object)(object)col.collider != (Object)null && ((Object)(object)((Component)col.collider).gameObject == (Object)(object)((Component)_trackedProp).gameObject || IsPlayerCollider(col.collider))))
{
return;
}
Vector3 contactPoint = (((Object)(object)_trackedTransform != (Object)null) ? _trackedTransform.position : go.transform.position);
Vector3 normal = Vector3.up;
try
{
if (col != null && col.contactCount > 0)
{
ContactPoint contact = col.GetContact(0);
contactPoint = ((ContactPoint)(ref contact)).point;
normal = ((ContactPoint)(ref contact)).normal;
}
}
catch
{
}
TriggerImpact(contactPoint, normal, "physical collision");
}
private void FixedUpdate()
{
//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_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Expected O, but got Unknown
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Unknown result type (might be due to invalid IL or missing references)
//IL_044f: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0463: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
if (!_tracking || (Object)(object)_trackedTransform == (Object)null || (Object)(object)_trackedRb == (Object)null || Time.time < _ignoreUntil)
{
return;
}
Vector3 position;
try
{
position = _trackedTransform.position;
}
catch
{
Cancel("prop transform lost");
return;
}
if (Time.time - _releaseTime > ((_timeout != null) ? _timeout.Value : 8f))
{
Cancel("timeout, no landing");
return;
}
if (_lastSafeY > -1.7014117E+38f && position.y < _lastSafeY - 30f)
{
Cancel("below kill plane");
return;
}
float num = Vector2.Distance(new Vector2(_releasePoint.x, _releasePoint.z), new Vector2(position.x, position.z));
if (_maxDist != null && num > _maxDist.Value)
{
Cancel($"beyond max distance in flight ({num:F1} m)");
return;
}
Vector3 velocity = _trackedRb.velocity;
float magnitude = ((Vector3)(ref velocity)).magnitude;
if (_diagnostics != null && _diagnostics.Value && Time.time >= _nextDiag)
{
_nextDiag = Time.time + 1f;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: tracking pos=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(position);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" sp=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(magnitude, "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" dist=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m");
}
log.LogInfo(val);
}
if (_flightTrail != null && _flightTrail.Value && (Object)(object)_flightTrailPs != (Object)null)
{
PlayerPalette playerPalette = GetPlayerPalette(LocalPlayer());
Vector3 val2 = -velocity * 0.12f + Random.insideUnitSphere * 0.25f;
for (int i = 0; i < 2; i++)
{
Vector3 val3 = position + Random.insideUnitSphere * 0.08f;
float num2 = Random.Range(0.12f, 0.24f);
float num3 = Random.Range(0.45f, 0.75f);
Color32 val4 = ((i == 0) ? playerPalette.SparkGlow : playerPalette.SparkAccent);
_flightTrailPs.Emit(val3, val2, num2, num3, val4);
}
if (Time.frameCount % 3 == 0)
{
Vector3 val5 = position + Random.insideUnitSphere * 0.05f;
Vector3 val6 = -velocity * 0.08f + Vector3.up * 0.1f;
_flightTrailPs.Emit(val5, val6, 0.55f, 0.75f, playerPalette.Smoke);
}
}
if (magnitude > 0.5f)
{
Vector3 val7 = velocity / magnitude;
float num4 = magnitude * Time.fixedDeltaTime + 0.15f;
RaycastHit val8 = default(RaycastHit);
if (Physics.SphereCast(position, 0.12f, val7, ref val8, num4, -1, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val8)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val8)).collider).gameObject != (Object)(object)((Component)_trackedProp).gameObject && !IsPlayerCollider(((RaycastHit)(ref val8)).collider))
{
TriggerImpact(((RaycastHit)(ref val8)).point, ((RaycastHit)(ref val8)).normal, "spherecast sweep");
return;
}
}
RaycastHit val9 = default(RaycastHit);
if (_prevSpeed > 3f && magnitude < 1f && Physics.Raycast(position + Vector3.up * 0.1f, Vector3.down, ref val9, 0.6f, -1, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val9)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val9)).collider).gameObject != (Object)(object)((Component)_trackedProp).gameObject && !IsPlayerCollider(((RaycastHit)(ref val9)).collider))
{
TriggerImpact(((RaycastHit)(ref val9)).point, ((RaycastHit)(ref val9)).normal, "velocity halt fallback");
}
else
{
_prevSpeed = magnitude;
}
}
private static void RefreshBuoyCache()
{
if (Time.time < _nextBuoyScanTime)
{
return;
}
_nextBuoyScanTime = Time.time + 5f;
_cachedBuoys.Clear();
try
{
List<Prop> allProps = Prop.allProps;
if (allProps == null)
{
return;
}
for (int i = 0; i < allProps.Count; i++)
{
Prop val = allProps[i];
if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null && IsBuoyName(((Object)((Component)val).gameObject).name))
{
_cachedBuoys.Add(val);
}
}
}
catch
{
}
}
private static bool IsNearAnyBuoy(Vector3 pos, float maxDist)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
RefreshBuoyCache();
try
{
if (_cachedBuoys.Count > 0)
{
float num = maxDist * maxDist;
for (int i = 0; i < _cachedBuoys.Count; i++)
{
Prop val = _cachedBuoys[i];
if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject != (Object)null)
{
Vector3 val2 = pos - ((Component)val).transform.position;
if (((Vector3)(ref val2)).sqrMagnitude <= num)
{
return true;
}
}
}
return false;
}
}
catch
{
}
return true;
}
private void CheckRemoteTeleports()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: 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_0191: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0374: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Expected O, but got Unknown
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
try
{
List<PlayerCharacter> allPlayerCharacters = PlayerCharacter.allPlayerCharacters;
bool flag = default(bool);
if (allPlayerCharacters != null && allPlayerCharacters.Count > 0)
{
PlayerCharacter val = LocalPlayer();
for (int i = 0; i < allPlayerCharacters.Count; i++)
{
PlayerCharacter val2 = allPlayerCharacters[i];
if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null)
{
continue;
}
int instanceID = ((Object)val2).GetInstanceID();
Vector3 position = ((Component)val2).transform.position;
if ((Object)(object)val != (Object)null && (Object)(object)val2 == (Object)(object)val)
{
_lastPlayerPositions[instanceID] = position;
continue;
}
if (_lastPlayerPositions.TryGetValue(instanceID, out var value))
{
float num = Vector3.Distance(value, position);
if (num > 2.5f && num < 250f && IsNearAnyBuoy(position, 6f))
{
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(49, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("EnderBuoy: observed remote friend teleport (");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val2).name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num, "F1");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" m)");
}
log.LogInfo(val3);
SpawnSmoke(value, val2);
SpawnSmoke(position, val2);
PlayTeleportSound(position, val2);
PlayTeleportSound(value, val2);
}
}
_lastPlayerPositions[instanceID] = position;
}
return;
}
if (Time.time >= _nextPlayerScan)
{
_nextPlayerScan = Time.time + 2f;
_cachedPlayers = Il2CppArrayBase<PlayerCharacter>.op_Implicit(Object.FindObjectsOfType<PlayerCharacter>());
}
if (_cachedPlayers == null)
{
return;
}
PlayerCharacter val4 = LocalPlayer();
for (int j = 0; j < _cachedPlayers.Length; j++)
{
PlayerCharacter val5 = _cachedPlayers[j];
if ((Object)(object)val5 == (Object)null || (Object)(object)((Component)val5).gameObject == (Object)null)
{
continue;
}
int instanceID2 = ((Object)val5).GetInstanceID();
Vector3 position2 = ((Component)val5).transform.position;
if ((Object)(object)val4 != (Object)null && (Object)(object)val5 == (Object)(object)val4)
{
_lastPlayerPositions[instanceID2] = position2;
continue;
}
if (_lastPlayerPositions.TryGetValue(instanceID2, out var value2))
{
float num2 = Vector3.Distance(value2, position2);
if (num2 > 2.5f && num2 < 250f && IsNearAnyBuoy(position2, 6f))
{
ManualLogSource log2 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(49, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("EnderBuoy: observed remote friend teleport (");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val5).name);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num2, "F1");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" m)");
}
log2.LogInfo(val3);
SpawnSmoke(value2, val5);
SpawnSmoke(position2, val5);
PlayTeleportSound(position2, val5);
PlayTeleportSound(value2, val5);
}
}
_lastPlayerPositions[instanceID2] = position2;
}
}
catch
{
}
}
private void Update()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
if (_enabled != null && _enabled.Value && _key != null && (int)_key.Value != 0 && Input.GetKeyDown(_key.Value) && _blink != null)
{
_blink.Value = !_blink.Value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: Blink ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_blink.Value ? "on" : "off");
}
log.LogInfo(val);
if (!_blink.Value && _tracking)
{
Cancel("disarmed mid-flight");
}
}
if (_enabled != null && !_enabled.Value && _tracking)
{
Cancel("mod disabled mid-flight");
}
if (_pendingArrivalPuffTime > 0f && Time.time >= _pendingArrivalPuffTime)
{
_pendingArrivalPuffTime = -1f;
if (NetworkServer.active)
{
try
{
PlayerCharacter val2 = LocalPlayer();
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.playerNetworking != (Object)null && val2.looks != null)
{
int randomLookId = val2.looks.GetRandomLookId();
int randomLookId2 = val2.looks.GetRandomLookId();
val2.playerNetworking.RPCPuff(randomLookId, (LookPart)1);
val2.playerNetworking.RPCPuff(randomLookId2, (LookPart)2);
}
}
catch
{
}
}
}
CheckRemoteTeleports();
}
private static bool IsPropOrPlayerCollider(Collider col, Prop prop)
{
if ((Object)(object)col == (Object)null)
{
return false;
}
try
{
if (IsPlayerCollider(col))
{
return true;
}
if ((Object)(object)prop != (Object)null)
{
if ((Object)(object)((Component)col).gameObject == (Object)(object)((Component)prop).gameObject)
{
return true;
}
if ((Object)(object)((Component)col).GetComponentInParent<Prop>() == (Object)(object)prop)
{
return true;
}
}
}
catch
{
}
return false;
}
private static Vector3 CalculateLandingPosition(Vector3 contactPoint, Vector3 normal, Prop prop, Vector3 buoyVelocity)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_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)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_003b: 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_004b: 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_005b: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: 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)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
Vector3 up = Vector3.up;
Vector3 val = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref normal)).normalized : up);
float num = Vector3.Dot(val, up);
Vector3 val2;
if (num >= 0.5f)
{
val2 = contactPoint + val * 0.15f + up * 0.7f;
}
else
{
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(val.x, 0f, val.z);
if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
{
((Vector3)(ref val3))..ctor(0f - buoyVelocity.x, 0f, 0f - buoyVelocity.z);
}
if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
{
val3 = Vector3.forward;
}
val3 = ((Vector3)(ref val3)).normalized;
Vector3 val4 = contactPoint + val3 * 0.65f;
RaycastHit val5 = default(RaycastHit);
val2 = ((!Physics.Raycast(val4 + up * 0.5f, Vector3.down, ref val5, 4.5f, -1, (QueryTriggerInteraction)1)) ? (val4 + up * 0.7f) : ((!((Object)(object)((RaycastHit)(ref val5)).collider != (Object)null) || IsPropOrPlayerCollider(((RaycastHit)(ref val5)).collider, prop)) ? (val4 + up * 0.7f) : (((RaycastHit)(ref val5)).point + up * 0.7f)));
}
RaycastHit val6 = default(RaycastHit);
if (Physics.Raycast(val2 + up * 1f, Vector3.down, ref val6, 1.8f, -1, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val6)).collider != (Object)null && !IsPropOrPlayerCollider(((RaycastHit)(ref val6)).collider, prop))
{
float num2 = ((RaycastHit)(ref val6)).point.y + 0.7f;
if (num2 > val2.y)
{
val2.y = num2;
}
}
return val2;
}
private static void TriggerImpact(Vector3 contactPoint, Vector3 normal, string source)
{
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Expected O, but got Unknown
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Expected O, but got Unknown
//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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Expected O, but got Unknown
//IL_0061: 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_02a3: 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_0068: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0089: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
if (!_tracking)
{
return;
}
_tracking = false;
PlayerCharacter val = LocalPlayer();
if ((Object)(object)val == (Object)null)
{
Cancel("local player lost");
return;
}
bool flag = default(bool);
try
{
Vector3 position = ((Component)val).transform.position;
Vector3 buoyVelocity = (((Object)(object)_trackedRb != (Object)null) ? _trackedRb.velocity : Vector3.zero);
Vector3 val2 = CalculateLandingPosition(contactPoint, normal, _trackedProp, buoyVelocity);
PlayTeleportSound(position, val);
PlayTeleportSound(val2, val);
SpawnSmoke(position + Vector3.up * 0.5f, val);
SpawnSmoke(val2 + Vector3.up * 0.5f, val);
if (NetworkServer.active)
{
try
{
PlayerLooks looks = val.looks;
int num = ((looks != null) ? looks.GetRandomLookId() : 0);
int num2 = ((looks != null) ? looks.GetRandomLookId() : 0);
PlayerNetworking playerNetworking = val.playerNetworking;
if (playerNetworking != null)
{
playerNetworking.RPCPuff(num, (LookPart)1);
}
PlayerNetworking playerNetworking2 = val.playerNetworking;
if (playerNetworking2 != null)
{
playerNetworking2.RPCPuff(num2, (LookPart)2);
}
}
catch
{
}
}
Rigidbody rb = val.rb;
if ((Object)(object)rb != (Object)null)
{
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.position = val2;
}
try
{
PlayerFaller faller = val.faller;
if (faller != null)
{
faller.ClearNextFall();
}
}
catch
{
}
if (val.grease != null)
{
val.grease.Teleport(val2, ((Component)val).transform.rotation, true);
}
((Component)val).transform.position = val2;
if (NetworkServer.active)
{
_pendingArrivalPuffTime = Time.time + 0.08f;
}
if (val.mover != null)
{
try
{
val.mover.cachedKernalPos = val2;
}
catch
{
}
}
float num3 = Vector3.Distance(position, val2);
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(39, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("EnderBuoy: teleported (");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(source);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Vector3>(position);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Vector3>(val2);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (dist ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(num3, "F1");
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" m)");
}
log.LogInfo(val3);
try
{
_lastPlayerPositions[((Object)val).GetInstanceID()] = val2;
}
catch
{
}
if (_autoRetrieve == null || !_autoRetrieve.Value || !((Object)(object)_trackedProp != (Object)null))
{
return;
}
try
{
PlayerActions actions = val.actions;
if (actions != null)
{
actions.ActionPickUpProp(_trackedProp, val2);
}
if (_diagnostics != null && _diagnostics.Value)
{
Plugin.Log.LogInfo((object)"EnderBuoy: AutoRetrieve picked up buoy into hands.");
}
}
catch (Exception ex)
{
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log2 = Plugin.Log;
val3 = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("EnderBuoy: AutoRetrieve failed: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
log2.LogInfo(val3);
}
}
}
catch (Exception ex2)
{
ManualLogSource log3 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("EnderBuoy: teleport write failed: ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex2);
}
log3.LogError(val4);
}
finally
{
DetachFlightTrail();
_trackedProp = null;
_trackedTransform = null;
_trackedRb = null;
}
}
private static void PlayTeleportSound(Vector3 targetPos, PlayerCharacter player)
{
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_00c1: 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_00fb: Expected O, but got Unknown
if (_playSound == null || !_playSound.Value || (Object)(object)player == (Object)null)
{
return;
}
bool flag = default(bool);
try
{
PlayerAudioReferences playerAudio = player.playerAudio;
if ((Object)(object)playerAudio == (Object)null)
{
return;
}
AudioRandomContainer throwSound = playerAudio.throwSound;
if ((Object)(object)throwSound == (Object)null || throwSound.Cues == null || ((Il2CppArrayBase<SoundCue>)(object)throwSound.Cues).Length == 0)
{
return;
}
int num = Random.Range(0, ((Il2CppArrayBase<SoundCue>)(object)throwSound.Cues).Length);
SoundCue val = ((Il2CppArrayBase<SoundCue>)(object)throwSound.Cues)[num];
if (!((Object)(object)val != (Object)null) || !((Object)(object)val.Clip != (Object)null))
{
return;
}
AudioSource.PlayClipAtPoint(val.Clip, targetPos, 1f);
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EnderBuoy: played throwSound cue #");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val.Clip).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
log.LogInfo(val2);
}
}
catch (Exception ex)
{
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log2 = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EnderBuoy: sound play error: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log2.LogInfo(val2);
}
}
}
private static GameObject GetSmokeTemplate(PlayerCharacter player)
{
if ((Object)(object)_smokeTemplate != (Object)null)
{
return _smokeTemplate;
}
try
{
Il2CppArrayBase<ParticleSystem> val = Object.FindObjectsOfType<ParticleSystem>(true);
if (val != null)
{
foreach (ParticleSystem item in val)
{
if ((Object)(object)item != (Object)null && (Object)(object)((Component)item).gameObject != (Object)null && ((Object)((Component)item).gameObject).name == "SmokeParticleSystem")
{
_smokeTemplate = ((Component)item).gameObject;
Plugin.Log.LogInfo((object)"EnderBuoy: cached SmokeParticleSystem template from scene.");
return _smokeTemplate;
}
}
}
}
catch
{
}
try
{
if ((Object)(object)player != (Object)null && player.looks != null && (Object)(object)player.looks.puffTorso != (Object)null)
{
_smokeTemplate = ((Component)player.looks.puffTorso).gameObject;
Plugin.Log.LogInfo((object)"EnderBuoy: cached player puffTorso template.");
return _smokeTemplate;
}
}
catch
{
}
return null;
}
private static PlayerPalette GetPlayerPalette(PlayerCharacter player)
{
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: 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_021d: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)player != (Object)null && player.looks != null && (Object)(object)player.looks.lookSet != (Object)null)
{
int lookId = player.looks.GetLookId((LookPart)1);
int lookId2 = player.looks.GetLookId((LookPart)0);
Color color = player.looks.lookSet.GetColor(lookId);
Color color2 = player.looks.lookSet.GetColor(lookId2);
Color val = Color.Lerp(color, Color.white, 0.6f);
return new PlayerPalette
{
Smoke = new Color32((byte)Mathf.Clamp(color.r * 255f, 0f, 255f), (byte)Mathf.Clamp(color.g * 255f, 0f, 255f), (byte)Mathf.Clamp(color.b * 255f, 0f, 255f), (byte)180),
SparkPrimary = new Color32((byte)Mathf.Clamp(color.r * 255f, 0f, 255f), (byte)Mathf.Clamp(color.g * 255f, 0f, 255f), (byte)Mathf.Clamp(color.b * 255f, 0f, 255f), byte.MaxValue),
SparkGlow = new Color32((byte)Mathf.Clamp(val.r * 255f, 0f, 255f), (byte)Mathf.Clamp(val.g * 255f, 0f, 255f), (byte)Mathf.Clamp(val.b * 255f, 0f, 255f), byte.MaxValue),
SparkAccent = new Color32((byte)Mathf.Clamp(color2.r * 255f, 0f, 255f), (byte)Mathf.Clamp(color2.g * 255f, 0f, 255f), (byte)Mathf.Clamp(color2.b * 255f, 0f, 255f), byte.MaxValue)
};
}
}
catch
{
}
return new PlayerPalette
{
Smoke = new Color32((byte)235, (byte)235, (byte)235, (byte)180),
SparkPrimary = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
SparkGlow = new Color32(byte.MaxValue, (byte)240, (byte)200, byte.MaxValue),
SparkAccent = new Color32((byte)220, (byte)220, byte.MaxValue, byte.MaxValue)
};
}
private static void EmitPuffAndSparks(ParticleSystem ps, Vector3 position, PlayerPalette palette)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0064: 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_008f: 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_00b4: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)ps == (Object)null))
{
((Component)ps).gameObject.SetActive(true);
ps.Play(true);
for (int i = 0; i < 35; i++)
{
Vector3 val = position + Random.insideUnitSphere * 0.45f;
Vector3 val2 = Random.insideUnitSphere * 0.35f + Vector3.up * 0.25f;
float num = Random.Range(1.6f, 2.6f);
float num2 = Random.Range(2.8f, 3.2f);
ps.Emit(val, val2, num, num2, palette.Smoke);
}
for (int j = 0; j < 35; j++)
{
Vector3 val3 = position + Random.insideUnitSphere * 0.15f;
Vector3 onUnitSphere = Random.onUnitSphere;
float num3 = Random.Range(3.5f, 7.5f);
Vector3 val4 = onUnitSphere * num3 + Vector3.up * 1.5f;
float num4 = Random.Range(0.12f, 0.28f);
float num5 = Random.Range(0.35f, 0.75f);
Color32 val5 = ((j % 3 == 0) ? palette.SparkPrimary : ((j % 3 == 1) ? palette.SparkGlow : palette.SparkAccent));
ps.Emit(val3, val4, num4, num5, val5);
}
}
}
private static void SpawnSmoke(Vector3 position, PlayerCharacter player)
{
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: 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_0066: 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_007d: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
if (_spawnSmoke == null || !_spawnSmoke.Value)
{
return;
}
try
{
GameObject smokeTemplate = GetSmokeTemplate(player);
if ((Object)(object)smokeTemplate == (Object)null)
{
return;
}
GameObject val = Object.Instantiate<GameObject>(smokeTemplate, position, Quaternion.identity);
if (!((Object)(object)val != (Object)null))
{
return;
}
val.SetActive(true);
val.transform.position = position;
val.transform.localScale = Vector3.one * 1.8f;
PlayerPalette playerPalette = GetPlayerPalette(player);
Il2CppArrayBase<ParticleSystem> componentsInChildren = val.GetComponentsInChildren<ParticleSystem>(true);
if (componentsInChildren != null && componentsInChildren.Length > 0)
{
foreach (ParticleSystem item in componentsInChildren)
{
EmitPuffAndSparks(item, position, playerPalette);
}
}
else
{
ParticleSystem component = val.GetComponent<ParticleSystem>();
EmitPuffAndSparks(component, position, playerPalette);
}
Object.Destroy((Object)(object)val, 4.5f);
}
catch (Exception ex)
{
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EnderBuoy: smoke spawn error: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log.LogInfo(val2);
}
}
}
private static void AttachFlightTrail(Transform buoyTransform, PlayerCharacter player)
{
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Expected O, but got Unknown
//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)
if (_flightTrail == null || !_flightTrail.Value)
{
return;
}
try
{
GameObject smokeTemplate = GetSmokeTemplate(player);
if ((Object)(object)smokeTemplate == (Object)null)
{
return;
}
_flightTrailObj = Object.Instantiate<GameObject>(smokeTemplate, buoyTransform.position, Quaternion.identity);
if ((Object)(object)_flightTrailObj != (Object)null)
{
_flightTrailObj.SetActive(true);
_flightTrailPs = _flightTrailObj.GetComponentInChildren<ParticleSystem>(true);
if ((Object)(object)_flightTrailPs == (Object)null)
{
_flightTrailPs = _flightTrailObj.GetComponent<ParticleSystem>();
}
if ((Object)(object)_flightTrailPs != (Object)null)
{
_flightTrailPs.Stop(true, (ParticleSystemStopBehavior)0);
}
}
}
catch (Exception ex)
{
if (_diagnostics != null && _diagnostics.Value)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: error attaching flight trail: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogInfo(val);
}
}
}
private static void DetachFlightTrail()
{
try
{
if ((Object)(object)_flightTrailObj != (Object)null)
{
Object.Destroy((Object)(object)_flightTrailObj, 1.2f);
}
}
catch
{
}
finally
{
_flightTrailObj = null;
_flightTrailPs = null;
}
}
private static void Cancel(string reason)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("EnderBuoy: cancelled (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
}
log.LogInfo(val);
_pendingArrivalPuffTime = -1f;
DetachFlightTrail();
_tracking = false;
_trackedProp = null;
_trackedTransform = null;
_trackedRb = null;
}
}
[HarmonyPatch(typeof(Prop), "SetDropped", new Type[]
{
typeof(PlayerCharacter),
typeof(Vector3),
typeof(Vector3)
})]
internal static class ThrowPatch3
{
[HarmonyPostfix]
private static void Postfix(Prop __instance, PlayerCharacter holder, Vector3 throwForce, Vector3 throwTorque)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
Blink.OnThrown(__instance, holder, throwForce);
}
}
[HarmonyPatch(typeof(Prop), "SetDropped", new Type[] { typeof(PlayerCharacter) })]
internal static class ThrowPatch1
{
[HarmonyPostfix]
private static void Postfix(Prop __instance, PlayerCharacter holder)
{
Blink.OnDroppedWithoutForce(__instance, holder);
}
}
[HarmonyPatch(typeof(PlatformingBody), "OnCollisionEnter")]
internal static class PlatformingBodyCollisionPatch
{
[HarmonyPostfix]
private static void Postfix(PlatformingBody __instance, Collision col)
{
if (!((Object)(object)__instance == (Object)null) && col != null)
{
Blink.OnPropCollisionEnter(((Component)__instance).gameObject, col);
}
}
}
[BepInPlugin("walker.enderbuoy", "EnderBuoy", "1.1.1")]
public class Plugin : BasePlugin
{
public const string PLUGIN_GUID = "walker.enderbuoy";
public const string PLUGIN_NAME = "EnderBuoy";
public const string PLUGIN_VERSION = "1.1.1";
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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Expected O, but got Unknown
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Expected O, but got Unknown
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Expected O, but got Unknown
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Expected O, but got Unknown
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Expected O, but got Unknown
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0371: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ConfigEntry<bool> enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Master switch for EnderBuoy. Turn this off to fully disable the mod.", (AcceptableValueBase)null, new object[2]
{
SettingsTags.Section("General", 10),
SettingsTags.Entry(10)
}));
ConfigEntry<bool> blink = ((BasePlugin)this).Config.Bind<bool>("Blink", "BlinkEnabled", true, new ConfigDescription("When on, throwing a buoy teleports you to where it first lands. Turn off to throw buoys normally.", (AcceptableValueBase)null, new object[2]
{
SettingsTags.Section("Blink", 20),
SettingsTags.Entry(10)
}));
ConfigEntry<bool> requireLit = ((BasePlugin)this).Config.Bind<bool>("Blink", "RequireLit", true, new ConfigDescription("Only lit buoys teleport you. Turn off so even unlit (toggled-off) buoys teleport.", (AcceptableValueBase)null, new object[1] { SettingsTags.Entry(20) }));
ConfigEntry<float> maxDist = ((BasePlugin)this).Config.Bind<float>("Blink", "MaxDistance", 60f, new ConfigDescription("Longest allowed teleport in meters, measured from throw point to landing. Longer throws do nothing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 200f), new object[1] { SettingsTags.Entry(30, 5.0) }));
ConfigEntry<bool> autoRetrieve = ((BasePlugin)this).Config.Bind<bool>("Blink", "AutoRetrieve", false, new ConfigDescription("Automatically pick the buoy back up into your hands upon landing for continuous chain teleports.", (AcceptableValueBase)null, new object[1] { SettingsTags.Entry(35) }));
ConfigFile val = new ConfigFile(((BasePlugin)this).Config.ConfigFilePath, true);
ConfigEntry<float> timeout = val.Bind<float>("Blink", "Timeout", 10f, "Safety fuse: seconds a tracked throw may stay airborne before giving up. Covers lost props; normal throws land long before this. Giving up means no teleport.");
ConfigEntry<bool> diagnostics = ((BasePlugin)this).Config.Bind<bool>("Blink", "Diagnostics", false, new ConfigDescription("Writes a status line to the game log once per second while tracking a thrown buoy.", (AcceptableValueBase)null, new object[1] { SettingsTags.Entry(40) }));
ConfigEntry<KeyCode> key = ((BasePlugin)this).Config.Bind<KeyCode>("Input", "ToggleKey", (KeyCode)288, new ConfigDescription("Keyboard shortcut that turns Blink on and off. (It does not change the master Enabled switch.)", (AcceptableValueBase)null, new object[2]
{
SettingsTags.Section("Input", 30),
SettingsTags.Entry(10)
}));
ConfigEntry<bool> playSound = ((BasePlugin)this).Config.Bind<bool>("Effects", "PlaySound", true, new ConfigDescription("Play throw whoosh sounds at departure and arrival upon teleporting.", (AcceptableValueBase)null, new object[2]
{
SettingsTags.Section("Effects", 25),
SettingsTags.Entry(10)
}));
ConfigEntry<bool> flightTrail = ((BasePlugin)this).Config.Bind<bool>("Effects", "FlightTrail", true, new ConfigDescription("Emit a luminous, sparkling trail behind the thrown buoy matching your outfit colors while in flight.", (AcceptableValueBase)null, new object[1] { SettingsTags.Entry(15) }));
ConfigEntry<bool> spawnSmoke = ((BasePlugin)this).Config.Bind<bool>("Effects", "SpawnSmoke", true, new ConfigDescription("Spawn flare smoke clouds at departure and arrival locations.", (AcceptableValueBase)null, new object[1] { SettingsTags.Entry(20) }));
Blink.Bind(enabled, blink, requireLit, maxDist, timeout, diagnostics, key, playSound, spawnSmoke, autoRetrieve, flightTrail);
new Harmony("walker.enderbuoy").PatchAll();
((BasePlugin)this).AddComponent<Blink>();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("EnderBuoy v");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.1.1");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded.");
}
log.LogInfo(val2);
}
}
}