Decompiled source of Slipstream v1.0.1

Slipstream.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CG;
using CG.Client.UI;
using CG.Game;
using CG.Game.Player;
using CG.Space;
using Gameplay.SpacePlatforms;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Opsive.UltimateCharacterController.Character;
using UnityEngine;
using VoidManager;
using VoidManager.MPModChecks;

[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("Slipstream")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Slipstream")]
[assembly: AssemblyTitle("Players near the ship keep most of the ship's velocity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 Slipstream
{
	[HarmonyPatch(typeof(CharacterLocomotion))]
	internal class CharacterLocomotionPatch
	{
		private static Vector3 lastShipVelocity = Vector3.zero;

		private static Quaternion lastShipRotation = Quaternion.identity;

		[HarmonyPrefix]
		[HarmonyPatch("UpdateExternalForces")]
		private static void PrefixForces(CharacterLocomotion __instance, ref Vector3 ___m_ExternalForce, out Vector3 __state)
		{
			//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_006c: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0184: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_01ba: 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_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			__state = Vector3.zero;
			if (!VoidManagerPlugin.Enabled || (Object)(object)((Player)LocalPlayer.Instance).Locomotion != (Object)(object)__instance)
			{
				return;
			}
			ClientGame current = ClientGame.Current;
			if (current == null)
			{
				return;
			}
			AbstractPlayerControlledShip playerShip = current.PlayerShip;
			Vector3? obj;
			if (playerShip == null)
			{
				obj = null;
			}
			else
			{
				MovingSpacePlatform platform = playerShip.Platform;
				obj = ((platform != null) ? new Vector3?(((SpacePlatform)platform).Velocity) : null);
			}
			Vector3? val = obj;
			if (!val.HasValue || (Object)(object)((AbstractCloneStarObject)ClientGame.Current.PlayerShip).Transform == (Object)null)
			{
				return;
			}
			Vector3 velocity = ((SpacePlatform)ClientGame.Current.PlayerShip.Platform).Velocity;
			Quaternion rotation = ClientGame.Current.PlayerShip.Platform.Rotation;
			if (!((Player)LocalPlayer.Instance).IsBeingSimulated)
			{
				Vector3 position = ((Player)LocalPlayer.Instance).Position;
				IEnumerable<Collider> colliders = ((AbstractSpaceCraft)ClientGame.Current.PlayerShip).GetColliders();
				if (colliders != null && colliders.Any(delegate(Collider collider)
				{
					//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_000a: Unknown result type (might be due to invalid IL or missing references)
					Bounds bounds = collider.bounds;
					return ((Bounds)(ref bounds)).Contains(position);
				}))
				{
					__state = velocity;
					___m_ExternalForce -= __state;
					__state += velocity - lastShipVelocity;
					Quaternion val2 = Quaternion.Inverse(lastShipRotation) * rotation;
					Vector3 val3 = position - ClientGame.Current.playerShip.Platform.Position;
					Vector3 val4 = val2 * val3;
					LocalPlayer instance = LocalPlayer.Instance;
					((Player)instance).Position = ((Player)instance).Position + (val4 - val3);
				}
			}
			lastShipVelocity = velocity;
			lastShipRotation = rotation;
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdateExternalForces")]
		private static void PostfixForces(ref Vector3 ___m_ExternalForce, Vector3 __state)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (VoidManagerPlugin.Enabled)
			{
				___m_ExternalForce += __state;
			}
		}
	}
	[HarmonyPatch(typeof(LocalPlayer), "SetPlatform")]
	internal class LocalPlayerPatch
	{
		private static readonly FieldInfo externalForce = AccessTools.Field(typeof(CharacterLocomotion), "m_ExternalForce");

		private static void Prefix(SpacePlatform ___spacePlatform, out SpacePlatform __state)
		{
			__state = ___spacePlatform;
		}

		private static void Postfix(LocalPlayer __instance, SpacePlatform platform, SpacePlatform __state)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (VoidManagerPlugin.Enabled && !((Object)(object)platform == (Object)(object)__state))
			{
				if ((Object)(object)platform != (Object)null)
				{
					externalForce.SetValue(((Player)__instance).Locomotion, Vector3.zero);
				}
				else if ((Object)(object)__state != (Object)null)
				{
					Vector3 val = (Vector3)externalForce.GetValue(((Player)__instance).Locomotion);
					externalForce.SetValue(((Player)__instance).Locomotion, val + __state.Velocity);
				}
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "id107.slipstream";

		public const string PLUGIN_NAME = "Slipstream";

		public const string USERS_PLUGIN_NAME = "Slipstream";

		public const string PLUGIN_VERSION = "1.0.1";

		public const string PLUGIN_DESCRIPTION = "Players near the ship keep most of the ship's velocity";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "";
	}
	[HarmonyPatch(typeof(FadeController), "Start")]
	internal class Patch
	{
		private static void Postfix()
		{
			BepinPlugin.Log.LogInfo((object)"Example Patch Executed");
		}
	}
	[BepInPlugin("id107.slipstream", "Slipstream", "1.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(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.slipstream is loaded!");
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public static bool Enabled { get; private set; }

		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107";

		public override string Description => "Players near the ship keep most of the ship's velocity";

		public override string ThunderstoreID => "";

		public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
		{
			//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Enabled = input.IsMod_Session;
			SessionChangedReturn result = default(SessionChangedReturn);
			result.SetMod_Session = true;
			return result;
		}
	}
}