using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
using Pigeon.Movement;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace KineticDiveMod
{
[BepInPlugin("com.coloron.kineticdive", "Kinetic Dive", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class KineticDivePlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <SpeedBurstRoutine>d__8 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Player player;
public float targetSpeed;
public float duration;
public KineticDivePlugin <>4__this;
private float <time>5__1;
private float <halfDur>5__2;
private float <outDuration>5__3;
private float <currentAdd>5__4;
private float <t>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpeedBurstRoutine>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<time>5__1 = 0f;
break;
case 1:
<>1__state = -1;
<time>5__1 += Time.fixedDeltaTime;
break;
}
if (<time>5__1 < duration)
{
<halfDur>5__2 = duration * 0.5f;
<outDuration>5__3 = Mathf.Min(0.3f, <halfDur>5__2);
<currentAdd>5__4 = targetSpeed;
if (<time>5__1 > duration - <outDuration>5__3)
{
<t>5__5 = 1f - (<time>5__1 - (duration - <outDuration>5__3)) / <outDuration>5__3;
<currentAdd>5__4 = targetSpeed * ((<t>5__5 < 0.5f) ? (2f * <t>5__5 * <t>5__5) : (1f - Mathf.Pow(-2f * <t>5__5 + 2f, 2f) / 2f));
}
<>4__this.ApplyTempMoveSpeed(player, <currentAdd>5__4);
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 1;
return true;
}
<>4__this._speedCoroutine = null;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string PluginGUID = "com.coloron.kineticdive";
public const int ModUpgradeID = 88889;
public static KineticDivePlugin Instance;
public static Upgrade CustomUpgradeInstance;
private Coroutine _speedCoroutine;
private void Awake()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Kinetic Dive 1.0.0...");
new Harmony("com.coloron.kineticdive").PatchAll();
PlayerData.AddRegisterUpgradesCallback((Action)InitializeUpgrades);
}
private static void InitializeUpgrades()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
IUpgradable val = PlayerData.FindGear("Bruiser");
if (val != null)
{
CustomUpgradeParams val2 = CustomUpgradeParams.Create(val, 88889, "Kinetic Converter", "Converts kinetic energy into dive power. Damage increases the further you dive.", (Rarity)3, (Sprite)null);
ref UpgradeFlags flags = ref val2.flags;
flags = (UpgradeFlags)((uint)flags | 0x2000u);
UpgradeProperty_KineticUI upgradeProperty_KineticUI = new UpgradeProperty_KineticUI();
CustomUpgradeInstance = PlayerData.CreateUpgrade("com.coloron.kineticdive", val2, (UpgradeProperty[])(object)new UpgradeProperty[1] { upgradeProperty_KineticUI });
if ((Object)(object)CustomUpgradeInstance != (Object)null)
{
HexMap val3 = new HexMap(3, 3);
val3[0, 0].enabled = true;
val3[1, 0].enabled = true;
val3[1, 0].connections = (Direction)34;
val3[2, 0].enabled = true;
SetPrivateField(CustomUpgradeInstance, "pattern", val3);
}
}
}
public void TriggerSpeedBuff(Player p, float distMeters)
{
float targetSpeed = distMeters * 1f;
if (_speedCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(_speedCoroutine);
}
_speedCoroutine = ((MonoBehaviour)this).StartCoroutine(SpeedBurstRoutine(p, targetSpeed, 3f));
}
[IteratorStateMachine(typeof(<SpeedBurstRoutine>d__8))]
private IEnumerator SpeedBurstRoutine(Player player, float targetSpeed, float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpeedBurstRoutine>d__8(0)
{
<>4__this = this,
player = player,
targetSpeed = targetSpeed,
duration = duration
};
}
private void ApplyTempMoveSpeed(Player p, float amount)
{
try
{
PropertyInfo property = typeof(Player).GetProperty("TempAddMoveSpeed", BindingFlags.Instance | BindingFlags.Public);
if (property != null)
{
property.SetValue(p, (float)property.GetValue(p) + amount);
return;
}
FieldInfo field = typeof(Player).GetField("TempAddMoveSpeed", BindingFlags.Instance | BindingFlags.Public);
if (field != null)
{
field.SetValue(p, (float)field.GetValue(p) + amount);
}
}
catch
{
}
}
public static bool SetPrivateField(object target, string name, object value)
{
Type type = target.GetType();
FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
while (field == null && type.BaseType != null)
{
type = type.BaseType;
field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
if (field != null)
{
field.SetValue(target, value);
return true;
}
return false;
}
}
[HarmonyPatch(typeof(NoseDiveUpgrade))]
public static class KineticDivePatch
{
private static Vector3 _startPos;
[HarmonyPatch("StartSlam")]
[HarmonyPrefix]
private static void StartSlam_Prefix()
{
//IL_0015: 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)
if ((Object)(object)Player.LocalPlayer != (Object)null)
{
_startPos = Player.LocalPlayer.PhysicsPosition;
}
}
[HarmonyPatch("TriggerNoseDive")]
[HarmonyPrefix]
private static void TriggerNoseDive_Prefix(NoseDiveUpgrade __instance, Vector3 position, bool isTrueDive, ref float damageMultiplier)
{
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Player.LocalPlayer == (Object)null || (Object)(object)KineticDivePlugin.CustomUpgradeInstance == (Object)null || !isTrueDive)
{
return;
}
bool flag = false;
bool flag2 = false;
if (Player.LocalPlayer.ActiveUpgrades != null)
{
foreach (UpgradeInstance activeUpgrade in Player.LocalPlayer.ActiveUpgrades)
{
UpgradeID iD = activeUpgrade.Upgrade.ID;
if (((object)(UpgradeID)(ref iD)).Equals((object?)KineticDivePlugin.CustomUpgradeInstance.ID))
{
flag = true;
flag2 = activeUpgrade.IsTurbocharged;
break;
}
}
}
if (!flag)
{
return;
}
float num = Vector3.Distance(_startPos, position);
float num2 = num * 10f;
if (!(num2 < 1f))
{
float damage = __instance.NoseDiveData.landDamage.damage;
if (damage > 0f)
{
float num3 = (damage + num2) / damage;
damageMultiplier *= num3;
}
if (flag2)
{
KineticDivePlugin.Instance.TriggerSpeedBuff(Player.LocalPlayer, num);
}
}
}
}
[Serializable]
public class UpgradeProperty_KineticUI : UpgradeProperty
{
[CompilerGenerated]
private sealed class <GetStatData>d__0 : IEnumerator<StatData>, IDisposable, IEnumerator
{
private int <>1__state;
private StatData <>2__current;
public Random rand;
public IUpgradable gear;
public UpgradeInstance upgrade;
public UpgradeProperty_KineticUI <>4__this;
StatData IEnumerator<StatData>.Current
{
[DebuggerHidden]
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return <>2__current;
}
}
[DebuggerHidden]
public <GetStatData>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = new StatData("<b>+10</b> damage per meter");
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (upgrade != null && upgrade.IsTurbocharged)
{
<>2__current = new StatData("\n<color=red>Turbocharged</color>\nSpeed Boost: <b>+10%</b> per meter\nDuration: <b>3s</b>\n");
<>1__state = 2;
return true;
}
break;
case 2:
<>1__state = -1;
break;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<GetStatData>d__0))]
public override IEnumerator<StatData> GetStatData(Random rand, IUpgradable gear, UpgradeInstance upgrade)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetStatData>d__0(0)
{
<>4__this = this,
rand = rand,
gear = gear,
upgrade = upgrade
};
}
public override string GetTurbochargedInfo(Random rand, IUpgradable gear, UpgradeInstance upgrade)
{
return "<color=red><b>Turbocharged</b></color>\nSpeed Boost: <b>+10%</b> per meter\nDuration: <b>3s</b>";
}
public override void Apply(Player p, UpgradeInstance u, ref Random r)
{
}
public override void Remove(Player p, Player pf, UpgradeInstance i, ref Random r)
{
}
}
}