using System;
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.Logging;
using CG;
using CG.Game;
using CG.Input;
using CG.Ship.Modules;
using CG.Space;
using Gameplay.SpacePlatforms;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.ModMessages;
using VoidManager.Progression;
using VoidManager.Utilities;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MiniJump")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+08a4d37c85588e2c9f709976890f8e45cc898d0f")]
[assembly: AssemblyProduct("MiniJump")]
[assembly: AssemblyTitle("Allows the ship to make a short range jump within a system. Host and Pilot. Disables Progression.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[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 MiniJump
{
internal class Configs
{
public const int jumpCooldownSeconds = 90;
internal static ConfigEntry<KeyCode> miniJumpKeybind;
internal static ConfigEntry<bool> allowJumpConfig;
internal static void Load(BepinPlugin plugin)
{
miniJumpKeybind = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("MiniJump", "MiniJumpKey", (KeyCode)103, (ConfigDescription)null);
allowJumpConfig = ((BaseUnityPlugin)plugin).Config.Bind<bool>("MiniJump", "AllowJump", true, (ConfigDescription)null);
}
}
internal class GUI : ModSettingsMenu
{
public override string Name()
{
return "Mini Jump";
}
public override void Draw()
{
GUITools.DrawCheckbox("Allow mini jump", ref Configs.allowJumpConfig);
GUITools.DrawChangeKeybindButton("Mini jump keybind", ref Configs.miniJumpKeybind);
}
}
internal class Jump
{
private static readonly FieldInfo playerShipSpacePlatformField = AccessTools.Field(typeof(AbstractPlayerControlledShip), "playerShipSpacePlatform");
internal static DateTime lastJumpTime = DateTime.MinValue;
internal static int CooldownRemaining()
{
int num = (int)(lastJumpTime.AddSeconds(90.0) - DateTime.Now).TotalSeconds;
if (num > 0)
{
return num;
}
return 0;
}
internal static void CheckDoJump(object sender, EventArgs e)
{
//IL_0062: 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)
if (!Game.PlayerShipExists || Game.InVoid)
{
return;
}
InputService instance = ServiceBase<InputService>.Instance;
if (instance == null)
{
return;
}
CursorVisibilityControl cursorVisibilityControl = instance.CursorVisibilityControl;
if (((cursorVisibilityControl != null) ? new bool?(cursorVisibilityControl.IsCursorShown) : null) != false || (int)Configs.miniJumpKeybind.Value == 0 || !UnityInput.Current.GetKeyDown(Configs.miniJumpKeybind.Value))
{
return;
}
AbstractPlayerControlledShip playerShip = ClientGame.Current.PlayerShip;
ChairBase chair = ((Component)playerShip).GetComponentInChildren<Helm>().Chair;
TakeoverChair val = (TakeoverChair)(object)((chair is TakeoverChair) ? chair : null);
if (val.IsAvailable || !((MonoBehaviourPun)val).photonView.AmOwner)
{
return;
}
VoidDriveModule componentInChildren = ((AbstractCloneStarObject)playerShip).GameObject.GetComponentInChildren<VoidDriveModule>();
if (!componentInChildren.IsFullyCharged)
{
Messaging.Notification("Void drive not charged", 8000L, false);
return;
}
int num = CooldownRemaining();
if (num > 0)
{
Messaging.Notification($"Mini Jump on cooldown for {num} seconds", 8000L, false);
}
else if (PhotonNetwork.IsMasterClient)
{
if (Configs.allowJumpConfig.Value)
{
DoJump();
}
}
else
{
MessageHandler.RequestJump();
}
}
internal static void DoJump()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
ClientGame current = ClientGame.Current;
AbstractPlayerControlledShip val = ((current != null) ? current.PlayerShip : null);
VoidDriveModule componentInChildren = ((AbstractCloneStarObject)val).GameObject.GetComponentInChildren<VoidDriveModule>();
componentInChildren.StopEnginesCharging();
MovingSpacePlatform val2 = (MovingSpacePlatform)playerShipSpacePlatformField.GetValue(val);
Vector3 val3 = val2.Rotation * Vector3.forward;
AccelerateThenJump(val2, val3 * 50f, val3 * 4500f, 20);
}
private static void AccelerateThenJump(MovingSpacePlatform platform, Vector3 velocityIncrease, Vector3 jumpDistance, int durationTicks)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
MovingSpacePlatform obj = platform;
((SpacePlatform)obj).Velocity = ((SpacePlatform)obj).Velocity + velocityIncrease;
if (durationTicks > 0)
{
Tools.DelayDo((Action)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
AccelerateThenJump(platform, velocityIncrease, jumpDistance, durationTicks - 1);
}, 1.0);
}
else
{
MovingSpacePlatform obj2 = platform;
obj2.CorrectedPosition += jumpDistance;
MessageHandler.NotifyJump();
}
}
}
internal class MessageHandler : ModMessage
{
private enum MessageType
{
request,
approve,
deny,
notify
}
private const int version = 2;
public override void Handle(object[] arguments, Player sender)
{
if (arguments.Length < 2)
{
return;
}
if ((int)arguments[0] != 2)
{
BepinPlugin.Log.LogInfo((object)$"Expected version {2}, got {(int)arguments[0]}");
return;
}
switch ((MessageType)arguments[1])
{
case MessageType.request:
{
if (!PhotonNetwork.IsMasterClient)
{
break;
}
if (!Configs.allowJumpConfig.Value)
{
DenyJump(sender, 0);
break;
}
int num2 = Jump.CooldownRemaining();
if (num2 == 0)
{
ApproveJump(sender);
}
else
{
DenyJump(sender, num2);
}
break;
}
case MessageType.approve:
if (sender == PhotonNetwork.MasterClient)
{
Jump.DoJump();
}
break;
case MessageType.deny:
if (sender == PhotonNetwork.MasterClient && arguments.Length >= 3)
{
int num = (int)arguments[2];
if (num == 0)
{
Messaging.Notification("Mini Jump currently disabled by host", 8000L, false);
}
else
{
Messaging.Notification($"Mini Jump on cooldown for {num} seconds", 8000L, false);
}
}
break;
case MessageType.notify:
Jump.lastJumpTime = DateTime.Now;
break;
}
}
internal static void RequestJump()
{
if (!PhotonNetwork.IsMasterClient)
{
ModMessage.Send("id107.MiniJump", ModMessage.GetIdentifier(typeof(MessageHandler)), (ReceiverGroup)2, new object[2]
{
2,
MessageType.request
}, false);
}
}
internal static void ApproveJump(Player sender)
{
if (PhotonNetwork.IsMasterClient)
{
ModMessage.Send("id107.MiniJump", ModMessage.GetIdentifier(typeof(MessageHandler)), sender, new object[2]
{
2,
MessageType.approve
}, false);
}
}
internal static void DenyJump(Player sender, int cooldown)
{
if (PhotonNetwork.IsMasterClient)
{
ModMessage.Send("id107.MiniJump", ModMessage.GetIdentifier(typeof(MessageHandler)), sender, new object[3]
{
2,
MessageType.deny,
cooldown
}, false);
}
}
internal static void NotifyJump()
{
ModMessage.Send("id107.MiniJump", ModMessage.GetIdentifier(typeof(MessageHandler)), (ReceiverGroup)1, new object[2]
{
2,
MessageType.notify
}, false);
}
}
public class MyPluginInfo
{
public const string PLUGIN_GUID = "id107.MiniJump";
public const string PLUGIN_NAME = "MiniJump";
public const string USERS_PLUGIN_NAME = "Mini Jump";
public const string PLUGIN_VERSION = "0.0.1";
public const string PLUGIN_DESCRIPTION = "Allows the ship to make a short range jump within a system. Host and Pilot. Disables Progression.";
public const string PLUGIN_ORIGINAL_AUTHOR = "id107";
public const string PLUGIN_AUTHORS = "id107";
public const string PLUGIN_THUNDERSTORE_ID = "";
}
[BepInPlugin("id107.MiniJump", "Mini Jump", "0.0.1")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "id107.MiniJump");
Configs.Load(this);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.MiniJump is loaded!");
}
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)14;
public override string Author => "id107";
public override string Description => "Allows the ship to make a short range jump within a system. Host and Pilot. Disables Progression.";
public override string ThunderstoreID => "";
public VoidManagerPlugin()
{
Events.Instance.LateUpdate += Jump.CheckDoJump;
}
public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
CallType callType = input.CallType;
CallType val = callType;
if ((int)val == 1 || (int)val == 4)
{
ProgressionHandler.DisableProgression("id107.MiniJump");
}
return ((VoidPlugin)this).OnSessionChange(input);
}
}
}