Decompiled source of RideMeExtended v1.2.0

RideMeExtended.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using KinematicCharacterController;
using On.RoR2;
using RoR2;
using RoR2.Networking;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RideMeExtended")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RideMeExtended")]
[assembly: AssemblyTitle("RideMeExtended")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace RideMeExtended;

public class RideableController : NetworkBehaviour, IInteractable, IDisplayNameProvider
{
	internal const string DisplayNameToken = "RIDE_INTERACTION";

	private const string ContextToken = "RIDE_CONTEXT";

	public TeamIndex TeamIndex;

	public CharacterBody CharacterBody;

	public List<RideSeat> AvailableSeats = new List<RideSeat>();

	[SyncVar]
	public bool CanRide = true;

	public bool NetworkCanRide
	{
		get
		{
			return CanRide;
		}
		[param: In]
		set
		{
			((NetworkBehaviour)this).SetSyncVar<bool>(value, ref CanRide, 1u);
		}
	}

	private void Start()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Run.instance))
		{
			return;
		}
		CanRide = true;
		TeamIndex = ((Component)this).GetComponent<TeamComponent>().teamIndex;
		CharacterBody = ((Component)this).GetComponent<CharacterBody>();
		string bodyName = BodyCatalog.GetBodyName(BodyCatalog.FindBodyIndex(((Object)CharacterBody).name));
		if (!string.IsNullOrEmpty(bodyName) && RideMeExtended.AvailableSeatsDictionary.ContainsKey(bodyName))
		{
			Func<CharacterBody, List<RideSeat>> func = RideMeExtended.AvailableSeatsDictionary[bodyName];
			if (func != null)
			{
				List<RideSeat> list = func(CharacterBody);
				if (list == null)
				{
					return;
				}
				{
					foreach (RideSeat item in list)
					{
						item.SeatOwner = this;
						item.SeatUser = null;
						AvailableSeats.Add(item);
					}
					return;
				}
			}
		}
		ModelLocator component = ((Component)this).GetComponent<ModelLocator>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform))
		{
			ChildLocator component2 = ((Component)component.modelTransform).GetComponent<ChildLocator>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Transform val = component2.FindChild("Chest");
				if (Object.op_Implicit((Object)(object)val))
				{
					AvailableSeats.Add(new RideSeat
					{
						SeatUser = null,
						SeatOwner = this,
						SeatTransform = val,
						PositionOffsetGetter = GetLegacyPositionOffset
					});
					return;
				}
			}
			AvailableSeats.Add(new RideSeat
			{
				SeatUser = null,
				SeatOwner = this,
				SeatTransform = ((Component)this).GetComponent<ModelLocator>().modelTransform,
				PositionOffsetGetter = GetLegacyPositionOffset
			});
		}
		else
		{
			AvailableSeats.Add(new RideSeat
			{
				SeatUser = null,
				SeatOwner = this,
				SeatTransform = ((Component)this).transform,
				PositionOffsetGetter = GetLegacyPositionOffset
			});
		}
	}

	private static Vector3 GetLegacyPositionOffset(RideSeat seat)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		return RideMeExtendedConfig.defaultSeatPositionOffset;
	}

	public string GetContextString(Interactor activator)
	{
		return Language.GetString("RIDE_CONTEXT");
	}

	public override int GetNetworkChannel()
	{
		return QosChannelIndex.defaultReliable.intVal;
	}

	public Interactability GetInteractability(Interactor activator)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		if (CanRide && Object.op_Implicit((Object)(object)activator) && Object.op_Implicit((Object)(object)((Component)activator).gameObject) && (Object)(object)((Component)activator).gameObject != (Object)(object)((Component)this).gameObject)
		{
			TeamComponent component = ((Component)activator).GetComponent<TeamComponent>();
			RiderController component2 = ((Component)activator).GetComponent<RiderController>();
			RideableController component3 = ((Component)activator).GetComponent<RideableController>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && (RideMeExtendedConfig.canRideOtherTeams || component.teamIndex == TeamIndex) && component2.CurrentSeat == null && (!Object.op_Implicit((Object)(object)component3) || !component3.AvailableSeats.Any((RideSeat x) => Object.op_Implicit((Object)(object)x.SeatUser))) && AvailableSeats.Any((RideSeat x) => !Object.op_Implicit((Object)(object)x.SeatUser)))
			{
				return (Interactability)2;
			}
		}
		return (Interactability)0;
	}

	[Server]
	public void OnInteractionBegin(Interactor activator)
	{
		RiderController component = ((Component)activator).GetComponent<RiderController>();
		if (CanRide && Object.op_Implicit((Object)(object)component))
		{
			int nextAvailableSeatIndex = GetNextAvailableSeatIndex(component.CurrentSeat);
			if (nextAvailableSeatIndex != -1)
			{
				RpcEnterSeat(nextAvailableSeatIndex, ((Component)activator).gameObject);
			}
		}
	}

	[ClientRpc]
	public void RpcEnterSeat(int seatIndex, GameObject rider)
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)rider))
		{
			return;
		}
		RiderController component = rider.GetComponent<RiderController>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			return;
		}
		RideSeat seatAtIndex = GetSeatAtIndex(seatIndex);
		if (seatAtIndex == null)
		{
			return;
		}
		RideSeat currentSeat = component.CurrentSeat;
		if (component.CurrentSeat != null)
		{
			component.CurrentSeat.SeatUser = null;
		}
		seatAtIndex.SeatUser = component;
		component.CurrentSeat = seatAtIndex;
		CharacterBody characterBody = component.CharacterBody;
		if (Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)characterBody.characterMotor))
		{
			if (Object.op_Implicit((Object)(object)((BaseCharacterController)characterBody.characterMotor).Motor))
			{
				((BaseCharacterController)characterBody.characterMotor).Motor.ForceUnground(0.1f);
			}
			characterBody.characterMotor.useGravity = false;
			characterBody.characterMotor.velocity = Vector3.zero;
			if (Object.op_Implicit((Object)(object)characterBody.characterDirection))
			{
				((Behaviour)characterBody.characterDirection).enabled = !seatAtIndex.AlignToSeatRotation;
			}
		}
		component.ToggleRiderCollisions(disable: true);
		RideMeExtended.Instance.Logger.LogMessage((object)(((Object)rider).name + " is now riding " + ((Object)this).name));
		RideMeExtended.OnGlobalSeatChange?.Invoke(component, currentSeat, seatAtIndex);
	}

	public int GetNextAvailableSeatIndex(RideSeat currentSeat)
	{
		int count = AvailableSeats.Count;
		if (currentSeat != null && count > 1)
		{
			int num = AvailableSeats.IndexOf(currentSeat);
			if (num != -1)
			{
				for (int i = num + 1; num != i; i++)
				{
					if (i >= count)
					{
						i = 0;
					}
					if (!Object.op_Implicit((Object)(object)AvailableSeats[i].SeatUser))
					{
						return i;
					}
				}
				return -1;
			}
		}
		return AvailableSeats.FindIndex((RideSeat x) => !Object.op_Implicit((Object)(object)x.SeatUser));
	}

	public RideSeat GetSeatAtIndex(int index)
	{
		if (index >= 0 && index < AvailableSeats.Count)
		{
			return AvailableSeats[index];
		}
		return null;
	}

	public string GetDisplayName()
	{
		return Language.GetString("RIDE_INTERACTION");
	}

	public bool ShouldIgnoreSpherecastForInteractibility(Interactor activator)
	{
		return false;
	}

	public bool ShouldShowOnScanner()
	{
		return false;
	}

	public void OnEnable()
	{
		InstanceTracker.Add<RideableController>(this);
	}

	public void OnDisable()
	{
		InstanceTracker.Remove<RideableController>(this);
	}

	public void SetCanRide(bool value)
	{
		if (NetworkServer.active)
		{
			NetworkCanRide = value;
		}
		else
		{
			CmdSetCanRide(value);
		}
	}

	[Command]
	private void CmdSetCanRide(bool value)
	{
		NetworkCanRide = value;
	}

	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		if (forceAll)
		{
			writer.Write(CanRide);
			return true;
		}
		bool flag = false;
		if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
		{
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
				flag = true;
			}
			writer.Write(CanRide);
		}
		if (!flag)
		{
			writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
		}
		return flag;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		if (initialState)
		{
			CanRide = reader.ReadBoolean();
		}
		else if ((reader.ReadPackedUInt32() & (true ? 1u : 0u)) != 0)
		{
			CanRide = reader.ReadBoolean();
		}
	}

	public bool ShouldProximityHighlight()
	{
		return CanRide;
	}
}
public static class RideMeExtendedConfig
{
	public static bool disableRiderHurtBoxEnabled;

	public static bool jumpRiderOnExitEnabled;

	public static float jumpRiderOnExitVelocity;

	public static Vector3 defaultSeatPositionOffset;

	public static bool canRideOtherTeams;

	public static void ReadConfig()
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		canRideOtherTeams = GetSetConfig("Riders", "Can ride the other teams", defaultValue: false, "Allows characters to ride other characters regardless of team").Value;
		disableRiderHurtBoxEnabled = GetSetConfig("Riders", "Disable hurtboxes upon riding", defaultValue: false, "Disable hurtboxes upon riding").Value;
		jumpRiderOnExitEnabled = GetSetConfig("Riders", "Enable jump on seat exit", defaultValue: true, "Enable jump on seat exit").Value;
		jumpRiderOnExitVelocity = GetSetConfig("Riders", "Jump velocity on seat exit", 20f, "Jump velocity on seat exit").Value;
		defaultSeatPositionOffset = GetSetConfig<Vector3>("Rideables", "Default seat position offset", new Vector3(0f, 3f, 0f), "Default seat position offset").Value;
	}

	internal static ConfigEntry<T> GetSetConfig<T>(string section, string key, T defaultValue, string description)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0023: Expected O, but got Unknown
		return ((BaseUnityPlugin)RideMeExtended.Instance).Config.Bind<T>(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
	}
}
[BepInPlugin("com.Mico27.RideMeExtended", "RideMeExtended", "1.2.0")]
public sealed class RideMeExtended : BaseUnityPlugin
{
	public delegate void SeatChangeCallback(RiderController rider, RideSeat oldSeat, RideSeat newSeat);

	public const string MODNAME = "RideMeExtended";

	public const string MODAUTHOR = "Mico27";

	public const string MODUID = "com.Mico27.RideMeExtended";

	public const string MODVERSION = "1.2.0";

	public const string developerPrefix = "Mico27";

	public static RideMeExtended Instance;

	public static SeatChangeCallback OnGlobalSeatChange;

	public static HashSet<string> RiderBodyBlacklist = new HashSet<string>();

	public static HashSet<string> RideableBodyBlacklist = new HashSet<string>();

	internal static Dictionary<string, Func<CharacterBody, List<RideSeat>>> AvailableSeatsDictionary = new Dictionary<string, Func<CharacterBody, List<RideSeat>>>();

	public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

	public void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		Instance = this;
		try
		{
			RideMeExtendedConfig.ReadConfig();
			Language.Init += new hook_Init(Language_Init);
			BodyCatalog.Init += new hook_Init(BodyCatalog_Init);
			GlobalEventManager.OnInteractionBegin += new hook_OnInteractionBegin(GlobalEventManager_OnInteractionBegin);
		}
		catch (Exception ex)
		{
			Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
		}
	}

	private IEnumerator Language_Init(orig_Init orig)
	{
		yield return orig.Invoke();
		Language.english.SetStringByToken("RIDE_INTERACTION", "Ride me");
		Language.english.SetStringByToken("RIDE_CONTEXT", "Ride me");
	}

	private IEnumerator BodyCatalog_Init(orig_Init orig)
	{
		yield return orig.Invoke();
		GameObject[] bodyPrefabs = BodyCatalog.bodyPrefabs;
		foreach (GameObject val in bodyPrefabs)
		{
			if (!RiderBodyBlacklist.Contains(((Object)val).name) && !((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Rider blacklist", ((Object)val).name), false, new ConfigDescription("Makes " + ((Object)val).name + " not able to ride anything.", (AcceptableValueBase)null, Array.Empty<object>())).Value && !Object.op_Implicit((Object)(object)val.GetComponent<RiderController>()))
			{
				val.AddComponent<RiderController>();
			}
			if (RideableBodyBlacklist.Contains(((Object)val).name) || ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Rideable blacklist", ((Object)val).name), false, new ConfigDescription("Makes " + ((Object)val).name + " not rideable.", (AcceptableValueBase)null, Array.Empty<object>())).Value)
			{
				continue;
			}
			if (((Object)val).name == "EngiTurretBody" || ((Object)val).name == "EngiWalkerTurretBody" || ((Object)val).name == "SquidTurretBody" || (RideMeExtendedConfig.canRideOtherTeams && val.layer != 0))
			{
				val.layer = 0;
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<RideableController>()))
			{
				val.AddComponent<RideableController>();
			}
			Highlight val2 = val.GetComponent<Highlight>();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = val.AddComponent<Highlight>();
			}
			val2.highlightColor = (HighlightColor)0;
			val2.isOn = false;
			val2.strength = 1f;
			ModelLocator component = val.GetComponent<ModelLocator>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform) && Object.op_Implicit((Object)(object)((Component)component.modelTransform).gameObject))
			{
				CharacterModel component2 = ((Component)component.modelTransform).gameObject.GetComponent<CharacterModel>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					val2.targetRenderer = (Renderer)(object)component2.mainSkinnedMeshRenderer;
				}
			}
			if (!Object.op_Implicit((Object)(object)val2.targetRenderer))
			{
				val2.targetRenderer = val.GetComponentInChildren<Renderer>();
			}
			GenericDisplayNameProvider val3 = val.GetComponent<GenericDisplayNameProvider>();
			if (!Object.op_Implicit((Object)(object)val3))
			{
				val3 = val.AddComponent<GenericDisplayNameProvider>();
			}
			val3.displayToken = "RIDE_INTERACTION";
			EntityLocator val4 = val.GetComponent<EntityLocator>();
			if (!Object.op_Implicit((Object)(object)val4))
			{
				val4 = val.AddComponent<EntityLocator>();
			}
			val4.entity = val;
		}
	}

	private void GlobalEventManager_OnInteractionBegin(orig_OnInteractionBegin orig, GlobalEventManager self, Interactor interactor, IInteractable interactable, GameObject interactableObject)
	{
		if (!Object.op_Implicit((Object)(object)interactableObject.GetComponent<RideableController>()))
		{
			orig.Invoke(self, interactor, interactable, interactableObject);
		}
	}

	public static void RegisterRideSeats(string bodyName, Func<CharacterBody, List<RideSeat>> rideSeatsGetter)
	{
		AvailableSeatsDictionary[bodyName] = rideSeatsGetter;
	}
}
public class RiderController : NetworkBehaviour
{
	public CharacterBody CharacterBody;

	public RideSeat CurrentSeat;

	private void Start()
	{
		if (Object.op_Implicit((Object)(object)Run.instance))
		{
			CharacterBody = ((Component)this).GetComponent<CharacterBody>();
		}
	}

	private void FixedUpdate()
	{
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: 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_0161: 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_017b: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)CharacterBody) || CurrentSeat == null)
		{
			return;
		}
		RideSeat currentSeat = CurrentSeat;
		if (Object.op_Implicit((Object)(object)currentSeat.SeatTransform) && (Object)(object)currentSeat.SeatUser == (Object)(object)this && Object.op_Implicit((Object)(object)currentSeat.SeatOwner) && currentSeat.SeatOwner.CanRide)
		{
			if (Util.HasEffectiveAuthority(((Component)this).gameObject))
			{
				if (((ButtonState)(ref CharacterBody.inputBank.jump)).justPressed)
				{
					CmdExitSeat();
					return;
				}
				if (((ButtonState)(ref CharacterBody.inputBank.interact)).justPressed && CurrentSeat.SeatOwner.GetNextAvailableSeatIndex(CurrentSeat) != -1)
				{
					CmdSwapSeat();
					return;
				}
			}
			KinematicCharacterMotor motor = ((BaseCharacterController)CharacterBody.characterMotor).Motor;
			if (Object.op_Implicit((Object)(object)motor))
			{
				Transform seatTransform = currentSeat.SeatTransform;
				Func<RideSeat, Vector3> positionOffsetGetter = currentSeat.PositionOffsetGetter;
				Vector3 val = ((positionOffsetGetter != null) ? (seatTransform.position + positionOffsetGetter(currentSeat)) : seatTransform.position);
				if (currentSeat.AlignToSeatRotation && Object.op_Implicit((Object)(object)CharacterBody.characterDirection))
				{
					Func<RideSeat, Quaternion> rotationOffsetGetter = currentSeat.RotationOffsetGetter;
					Quaternion val2 = ((rotationOffsetGetter != null) ? (seatTransform.rotation * rotationOffsetGetter(currentSeat)) : seatTransform.rotation);
					motor.SetPositionAndRotation(val, val2, true);
					CharacterBody.characterDirection.targetTransform.rotation = val2;
				}
				else
				{
					motor.SetPosition(val, true);
				}
			}
		}
		else if (Util.HasEffectiveAuthority(((Component)this).gameObject))
		{
			CmdExitSeat();
		}
	}

	public override int GetNetworkChannel()
	{
		return QosChannelIndex.defaultReliable.intVal;
	}

	[Command]
	public void CmdExitSeat()
	{
		RpcExitSeat();
	}

	[ClientRpc]
	public void RpcExitSeat()
	{
		//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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		if (CurrentSeat == null)
		{
			return;
		}
		RideSeat currentSeat = CurrentSeat;
		CurrentSeat.SeatUser = null;
		CurrentSeat = null;
		if (Object.op_Implicit((Object)(object)CharacterBody) && Object.op_Implicit((Object)(object)CharacterBody.characterMotor))
		{
			CharacterMotor characterMotor = CharacterBody.characterMotor;
			characterMotor.useGravity = true;
			characterMotor.velocity = Vector3.zero;
			if (RideMeExtendedConfig.jumpRiderOnExitEnabled)
			{
				((BaseCharacterController)characterMotor).Motor.ForceUnground(0.1f);
				characterMotor.velocity = new Vector3(characterMotor.velocity.x, Mathf.Max(characterMotor.velocity.y, RideMeExtendedConfig.jumpRiderOnExitVelocity), characterMotor.velocity.z);
			}
			if (Object.op_Implicit((Object)(object)CharacterBody.characterDirection))
			{
				((Behaviour)CharacterBody.characterDirection).enabled = true;
			}
		}
		ToggleRiderCollisions(disable: false);
		RideMeExtended.OnGlobalSeatChange?.Invoke(this, currentSeat, null);
	}

	[Command]
	public void CmdSwapSeat()
	{
		if (CurrentSeat != null && (Object)(object)CurrentSeat.SeatOwner != (Object)null)
		{
			int nextAvailableSeatIndex = CurrentSeat.SeatOwner.GetNextAvailableSeatIndex(CurrentSeat);
			if (nextAvailableSeatIndex != -1)
			{
				RpcSwapSeat(nextAvailableSeatIndex);
			}
		}
	}

	[ClientRpc]
	public void RpcSwapSeat(int seatIndex)
	{
		if (CurrentSeat == null || !((Object)(object)CurrentSeat.SeatOwner != (Object)null))
		{
			return;
		}
		RideSeat seatAtIndex = CurrentSeat.SeatOwner.GetSeatAtIndex(seatIndex);
		if (seatAtIndex != null && CurrentSeat != seatAtIndex)
		{
			RideSeat currentSeat = CurrentSeat;
			CurrentSeat.SeatUser = null;
			CurrentSeat = seatAtIndex;
			seatAtIndex.SeatUser = this;
			if (Object.op_Implicit((Object)(object)CharacterBody.characterDirection))
			{
				((Behaviour)CharacterBody.characterDirection).enabled = !seatAtIndex.AlignToSeatRotation;
			}
			RideMeExtended.OnGlobalSeatChange?.Invoke(this, currentSeat, seatAtIndex);
		}
	}

	public void ToggleRiderCollisions(bool disable)
	{
		if (RideMeExtendedConfig.disableRiderHurtBoxEnabled && Object.op_Implicit((Object)(object)CharacterBody) && Object.op_Implicit((Object)(object)CharacterBody.modelLocator) && Object.op_Implicit((Object)(object)CharacterBody.modelLocator.modelTransform))
		{
			HurtBoxGroup component = ((Component)CharacterBody.modelLocator.modelTransform).GetComponent<HurtBoxGroup>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if (disable)
				{
					int hurtBoxesDeactivatorCounter = component.hurtBoxesDeactivatorCounter;
					component.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter + 1;
				}
				else
				{
					int hurtBoxesDeactivatorCounter = component.hurtBoxesDeactivatorCounter;
					component.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter - 1;
				}
			}
		}
		if (Object.op_Implicit((Object)(object)CharacterBody) && Object.op_Implicit((Object)(object)CharacterBody.characterMotor) && Object.op_Implicit((Object)(object)CharacterBody.characterMotor.capsuleCollider))
		{
			((Collider)CharacterBody.characterMotor.capsuleCollider).enabled = !disable;
		}
	}

	public void OnEnable()
	{
		InstanceTracker.Add<RiderController>(this);
	}

	public void OnDisable()
	{
		InstanceTracker.Remove<RiderController>(this);
	}
}
public class RideSeat
{
	public string Name;

	public Transform SeatTransform;

	public RideableController SeatOwner;

	public RiderController SeatUser;

	public Func<RideSeat, Vector3> PositionOffsetGetter;

	public Func<RideSeat, Quaternion> RotationOffsetGetter;

	public bool AlignToSeatRotation;
}