using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Rewired;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SitAnywhere")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+babed5d3f1ebe844f936f6925836e8052d0d437e")]
[assembly: AssemblyProduct("SitAnywhere")]
[assembly: AssemblyTitle("SitAnywhere")]
[assembly: AssemblyVersion("1.0.1.0")]
[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;
}
}
}
namespace SitAnywhere
{
[BepInPlugin("sodmods.sitanywhere", "Sit Anywhere", "1.0.1")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Logger;
internal static ConfigEntry<float> MinSeatHeight;
internal static ConfigEntry<float> MaxSeatHeight;
internal static ConfigEntry<float> Reach;
internal static ConfigEntry<bool> LedgeSitting;
internal static ConfigEntry<float> LedgeMinDrop;
internal static ConfigEntry<float> EyeAboveSeat;
internal static ConfigEntry<float> SitTime;
internal static ConfigEntry<float> StandTime;
internal static ConfigEntry<float> LookLimit;
internal static ConfigEntry<bool> TurnAround;
internal static ConfigEntry<bool> PassTime;
internal static ConfigEntry<bool> DebugLogging;
public override void Load()
{
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BasePlugin)this).Log;
MinSeatHeight = ((BasePlugin)this).Config.Bind<float>("Seats", "MinSeatHeight", 0.3f, "Lowest surface (metres above your feet) you can sit on.");
MaxSeatHeight = ((BasePlugin)this).Config.Bind<float>("Seats", "MaxSeatHeight", 0.85f, "Highest surface (metres above your feet) you can sit on. Desks and tables are around 0.75.");
Reach = ((BasePlugin)this).Config.Bind<float>("Seats", "Reach", 2f, "How far away (metres) you can look at a spot and sit there.");
LedgeSitting = ((BasePlugin)this).Config.Bind<bool>("Ledges", "Enabled", true, "Sit on the edge of roofs, balconies and low walls with your legs over the drop.");
LedgeMinDrop = ((BasePlugin)this).Config.Bind<float>("Ledges", "MinDrop", 0.8f, "How far (metres) the ground has to fall away past an edge for it to count as a ledge.");
EyeAboveSeat = ((BasePlugin)this).Config.Bind<float>("Seated", "EyeHeightAboveSeat", 0.75f, "Height of your eyes above the surface you're sitting on (metres).");
SitTime = ((BasePlugin)this).Config.Bind<float>("Seated", "SitDownSeconds", 0.7f, "How long sitting down takes.");
StandTime = ((BasePlugin)this).Config.Bind<float>("Seated", "StandUpSeconds", 0.5f, "How long getting up takes.");
LookLimit = ((BasePlugin)this).Config.Bind<float>("Seated", "LookAroundDegrees", 120f, "How far you can turn your head left or right while seated. 180 = no limit.");
TurnAround = ((BasePlugin)this).Config.Bind<bool>("Seated", "TurnAround", true, "Turn around to sit on things in front of you, the way you'd sit on a bench. Off = sit facing the way you were looking. Ledges always face out over the drop.");
PassTime = ((BasePlugin)this).Config.Bind<bool>("Seated", "PassTime", true, "Allow passing time with your watch alarm while seated, like on a chair.");
DebugLogging = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogSeats", false, "Log seat detection results (for tuning and bug reports).");
new Harmony("sodmods.sitanywhere").PatchAll(typeof(Plugin).Assembly);
((BasePlugin)this).Log.LogInfo((object)"Sit Anywhere loaded");
PhysicsSelfTest();
}
private void PhysicsSelfTest()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references)
try
{
Vector3 val = new Vector3(0f, -10000f, 0f);
RaycastHit val2 = default(RaycastHit);
Physics.Raycast(val, Vector3.down, ref val2, 1f, -1, (QueryTriggerInteraction)1);
Physics.OverlapCapsule(val, val + Vector3.up, 0.3f, -1, (QueryTriggerInteraction)1);
((BasePlugin)this).Log.LogInfo((object)"Physics self-test OK");
}
catch (Exception ex)
{
((BasePlugin)this).Log.LogError((object)("Physics self-test FAILED, sitting will not work: " + ex.Message));
}
}
}
internal static class Prompts
{
private sealed class Hint
{
public string Name;
public InteractionKey[] Keys;
}
private static readonly Dictionary<InteractionKey, string> Buttons = new Dictionary<InteractionKey, string>
{
[(InteractionKey)1] = "Primary",
[(InteractionKey)2] = "Secondary",
[(InteractionKey)3] = "Alternative",
[(InteractionKey)4] = "ScrollAxisUp",
[(InteractionKey)5] = "ScrollAxisDown",
[(InteractionKey)6] = "Jump"
};
private static readonly Dictionary<(InteractionKey, string), InteractableCurrentAction> actions = new Dictionary<(InteractionKey, string), InteractableCurrentAction>();
private static readonly List<Hint> wanted = new List<Hint>();
private static readonly Dictionary<InteractionKey, string> placed = new Dictionary<InteractionKey, string>();
private static bool rebuilding;
private static bool seatAvailable;
private static bool wasSmoking;
private static float nextScan;
public static void Scan(Player p)
{
if (Time.unscaledTime < nextScan)
{
return;
}
nextScan = Time.unscaledTime + 0.1f;
Seat seat;
bool flag = CanLookForSeat(p) && SeatFinder.TryFind(p, out seat);
if (Plugin.DebugLogging.Value && !flag && SeatFinder.LastFailure != null)
{
InputController instance = InputController.Instance;
if (instance != null)
{
Player player = instance.player;
if (((player != null) ? new bool?(player.GetButton("Primary")) : ((bool?)null)) == true)
{
Plugin.Logger.LogInfo((object)("Sit: " + SeatFinder.LastFailure));
}
}
}
if (flag != seatAvailable)
{
seatAvailable = flag;
Refresh();
}
}
public static void WatchSmoking()
{
bool flag = Smoking();
if (flag != wasSmoking)
{
wasSmoking = flag;
Refresh();
}
}
public static void Refresh()
{
if ((Object)(object)InteractionController.Instance != (Object)null)
{
InteractionController.Instance.UpdateInteractionText();
}
}
private static bool Smoking()
{
if ((Object)(object)FirstPersonItemController.Instance != (Object)null)
{
return FirstPersonItemController.Instance.smokingActive > 0;
}
return false;
}
private static bool CanLookForSeat(Player p)
{
InteractionController instance = InteractionController.Instance;
if ((Object)(object)p.fps != (Object)null && p.fps.enableMovement && (Object)(object)p.charController != (Object)null && ((Collider)p.charController).enabled && p.charController.isGrounded && !p.transitionActive && !((Actor)p).inAirVent && !p.autoTravelActive && !p.playerKOInProgress && (Object)(object)((Human)p).currentVehicle == (Object)null && (Object)(object)instance != (Object)null && instance.lockedInInteraction == null && (Object)(object)instance.carryingObject == (Object)null && !instance.dialogMode && (Object)(object)instance.currentlyDragging == (Object)null)
{
if ((Object)(object)ModifiersController.Instance != (Object)null)
{
return !ModifiersController.Instance.ratDetectiveModifierEnabled;
}
return true;
}
return false;
}
private static bool HintsAllowed()
{
InteractionController instance = InteractionController.Instance;
if ((Object)(object)instance != (Object)null && !instance.dialogMode && (Object)(object)instance.currentlyDragging == (Object)null && (Object)(object)InterfaceController.Instance != (Object)null && !InterfaceController.Instance.desktopMode && (Object)(object)BioScreenController.Instance != (Object)null && !BioScreenController.Instance.isOpen && (Object)(object)Player.Instance != (Object)null)
{
return !Player.Instance.autoTravelActive;
}
return false;
}
public static void BeginRebuild()
{
rebuilding = true;
wanted.Clear();
placed.Clear();
if (!HintsAllowed())
{
return;
}
Player instance = Player.Instance;
InteractionKey[] keys = (InteractionKey[])(object)((!Smoking()) ? new InteractionKey[1] { (InteractionKey)1 } : new InteractionKey[2]
{
(InteractionKey)2,
(InteractionKey)3
});
switch (Seated.Phase)
{
case Phase.None:
if (seatAvailable)
{
Want("Sit", keys);
}
break;
case Phase.Seated:
if (instance.setAlarmMode)
{
Want("Pass Time", (InteractionKey)1);
Want("Cancel", (InteractionKey)2);
Want("Switch Hours/Minutes", (InteractionKey)3);
Want("Alarm Forward", (InteractionKey)4);
Want("Alarm Back", (InteractionKey)5);
}
else if (instance.spendingTimeMode || instance.spendingTimeDelay > 0f)
{
Want("Cancel", (InteractionKey)2);
Want("Get Up", (InteractionKey)6);
}
else
{
if (Plugin.PassTime.Value)
{
Want("Pass Time", keys);
}
Want("Get Up", (InteractionKey)6);
}
break;
}
}
public static void EndRebuild()
{
rebuilding = false;
}
public static void OnSetKey(InteractionKey key, ref InteractableCurrentAction action)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0066: 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_0081: Unknown result type (might be due to invalid IL or missing references)
if (action != null)
{
if (!rebuilding)
{
placed.Remove(key);
}
return;
}
if (!rebuilding)
{
if (placed.TryGetValue(key, out var value))
{
action = Action(key, value);
}
return;
}
foreach (Hint item in wanted)
{
if (!placed.ContainsValue(item.Name) && Array.IndexOf(item.Keys, key) >= 0)
{
placed[key] = item.Name;
action = Action(key, item.Name);
break;
}
}
}
private static void Want(string name, params InteractionKey[] keys)
{
wanted.Add(new Hint
{
Name = name,
Keys = keys
});
}
private static InteractableCurrentAction Action(InteractionKey key, string name)
{
//IL_0005: 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_001a: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (!actions.TryGetValue((key, name), out var value))
{
value = new InteractableCurrentAction
{
display = true,
enabled = true,
overrideInteractionName = name
};
actions[(key, name)] = value;
}
return value;
}
private static bool Pressed(string name)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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)
InteractionController instance = InteractionController.Instance;
InteractionSetting val = default(InteractionSetting);
foreach (KeyValuePair<InteractionKey, string> item in placed)
{
if (!(item.Value != name) && Buttons.TryGetValue(item.Key, out var value) && instance.currentInteractions.TryGetValue(item.Key, ref val) && ((val != null) ? val.currentSetting : null) != null && !(((Il2CppObjectBase)val.currentSetting).Pointer != ((Il2CppObjectBase)Action(item.Key, name)).Pointer) && InputController.Instance.player.GetButtonDown(value))
{
return true;
}
}
return false;
}
public static void HandleInput()
{
//IL_00c2: 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)
if (placed.Count == 0 || !HintsAllowed())
{
return;
}
InteractionController instance = InteractionController.Instance;
if (instance.inputCooldown > 0f || InterfaceController.Instance.playerTextInputActive)
{
return;
}
InputController instance2 = InputController.Instance;
if (((instance2 != null) ? instance2.player : null) == null)
{
return;
}
Player instance3 = Player.Instance;
switch (Seated.Phase)
{
case Phase.None:
if (Pressed("Sit"))
{
if (SeatFinder.TryFind(instance3, out var seat))
{
Seated.SitDown(instance3, seat);
}
else
{
Refresh();
}
instance.inputCooldown = 0.1f;
}
break;
case Phase.Seated:
if (instance3.setAlarmMode)
{
if (Pressed("Pass Time"))
{
AudioController.Instance.PlayWorldOneShot(AudioControls.Instance.setAlarm, (Actor)(object)instance3, ((Actor)instance3).currentNode, ((Actor)instance3).lookAtThisTransform.position, (Interactable)null, (List<FMODParam>)null, 1f, (List<NewNode>)null, false, (SoundMaterialOverride)null, false);
instance3.SetSettingAlarmMode(false);
SelectSlot((StaticSlot)1);
instance3.spendingTimeDelay = 0.5f;
Done(instance);
}
else if (Pressed("Alarm Forward"))
{
ActionController.Instance.WatchForward((Interactable)null, (NewNode)null, (Actor)null);
}
else if (Pressed("Alarm Back"))
{
ActionController.Instance.WatchBack((Interactable)null, (NewNode)null, (Actor)null);
}
else if (Pressed("Switch Hours/Minutes"))
{
ActionController.Instance.HoursMinutesToggle((Interactable)null, (NewNode)null, (Actor)null);
}
else if (Pressed("Cancel"))
{
instance3.SetSettingAlarmMode(false);
SelectSlot((StaticSlot)1);
Done(instance);
}
}
else if (instance3.spendingTimeMode || instance3.spendingTimeDelay > 0f)
{
if (Pressed("Cancel"))
{
instance3.spendingTimeDelay = 0f;
if (instance3.spendingTimeMode)
{
instance3.SetSpendingTimeMode(false);
}
Done(instance);
}
}
else if (Pressed("Pass Time"))
{
SelectSlot((StaticSlot)2);
instance3.SetSettingAlarmMode(true);
Done(instance);
}
break;
}
}
private static void Done(InteractionController ic)
{
ic.inputCooldown = 0.1f;
Refresh();
}
private static void SelectSlot(StaticSlot which)
{
//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)
FirstPersonItemController instance = FirstPersonItemController.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)BioScreenController.Instance == (Object)null)
{
return;
}
Enumerator<InventorySlot> enumerator = instance.slots.GetEnumerator();
while (enumerator.MoveNext())
{
InventorySlot current = enumerator.Current;
if (current != null && current.isStatic == which)
{
BioScreenController.Instance.SelectSlot(current, false, false, true);
break;
}
}
}
}
[HarmonyPatch(typeof(InteractionController), "UpdateInteractionText", new Type[] { })]
internal static class HintsPatch
{
private static void Prefix()
{
try
{
Prompts.BeginRebuild();
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
}
}
private static void Finalizer()
{
Prompts.EndRebuild();
}
}
[HarmonyPatch(typeof(InteractionController), "SetCurrentPlayerInteraction")]
internal static class SetKeyPatch
{
private static void Prefix(InteractionKey key, ref InteractableCurrentAction newCurrentAction)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
try
{
Prompts.OnSetKey(key, ref newCurrentAction);
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
}
}
}
[HarmonyPatch(typeof(FirstPersonItemController), "StartSmokeToke")]
internal static class NoTokeWhileSettingAlarmPatch
{
private static bool Prefix()
{
if (Seated.Phase == Phase.Seated && (Object)(object)Player.Instance != (Object)null)
{
return !Player.Instance.setAlarmMode;
}
return true;
}
}
[HarmonyPatch(typeof(InteractionController), "Update")]
internal static class InputPatch
{
private static float nextErrorLog;
private static void Postfix()
{
try
{
if (!((Object)(object)SessionData.Instance == (Object)null) && SessionData.Instance.play && !((Object)(object)Player.Instance == (Object)null) && !Player.Instance.transitionActive)
{
Prompts.WatchSmoking();
Prompts.HandleInput();
}
}
catch (Exception ex)
{
if (Time.unscaledTime >= nextErrorLog)
{
nextErrorLog = Time.unscaledTime + 10f;
Plugin.Logger.LogError((object)ex);
}
}
}
}
internal enum Phase
{
None,
SittingDown,
Seated,
StandingUp
}
internal static class Seated
{
public static Phase Phase;
public static Seat Current;
public static float GraceUntil;
private static Vector3 standPos;
private static Vector3 fromPos;
private static Quaternion fromRot;
private static Quaternion toRot;
private static float fromPitch;
private static float toPitch;
private static float startTime;
private static float duration;
private static bool movementReleased;
private static IntPtr seatedPlayer;
public static bool Active => Phase != Phase.None;
public static void SitDown(Player p, Seat seat)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0045: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
Current = seat;
standPos = ((Component)p).transform.position;
fromPos = standPos;
fromRot = ((Component)p).transform.rotation;
toRot = Quaternion.Euler(0f, seat.Yaw, 0f);
fromPitch = SignedAngle(((Component)p.fps.m_Camera).transform.localEulerAngles.x);
toPitch = seat.Pitch;
seatedPlayer = ((Il2CppObjectBase)p).Pointer;
p.EnablePlayerMovement(false, false);
p.fps.m_StickToGroundForce = 0f;
p.fps.m_GravityMultiplier = 0f;
p.fps.m_MoveDir = Vector3.zero;
p.fps.m_Jump = false;
p.EnableCharacterController(false);
p.fps.enableHeadBob = false;
p.fps.m_UseJumpBob = false;
p.fps.enableLook = false;
Begin(Phase.SittingDown, Plugin.SitTime.Value);
movementReleased = false;
if (Plugin.DebugLogging.Value)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Sit: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(seat.Ledge ? "ledge" : "seat");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" eye ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(seat.Eye);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" yaw ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(seat.Yaw, "0");
}
logger.LogInfo(val);
}
Prompts.Refresh();
}
public static void StandUp(Player p)
{
//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)
Phase phase = Phase;
if ((phase != Phase.None && phase != Phase.StandingUp) || 1 == 0)
{
StopPassingTime(p);
p.fps.m_MouseLook.Init(((Component)p).transform, ((Component)p.fps.m_Camera).transform);
p.fps.enableLook = true;
fromPos = ((Component)p).transform.position;
Begin(Phase.StandingUp, Plugin.StandTime.Value);
Prompts.Refresh();
}
}
public static void EndNow(Player p, bool restoreController)
{
if (Active)
{
StopPassingTime(p);
Phase = Phase.None;
if (restoreController)
{
Restore(p);
}
Prompts.Refresh();
}
}
public static void StandNow(Player p)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if (Active)
{
StopPassingTime(p);
Phase = Phase.None;
((Component)p).transform.position = standPos;
p.fps.m_MouseLook.Init(((Component)p).transform, ((Component)p.fps.m_Camera).transform);
Restore(p);
Prompts.Refresh();
}
}
public static void Forget()
{
Phase = Phase.None;
Prompts.Refresh();
}
public static void Tick(Player p)
{
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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_01cb: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
if (!Active)
{
return;
}
if (((Il2CppObjectBase)p).Pointer != seatedPlayer)
{
Phase = Phase.None;
return;
}
if (p.transitionActive)
{
Forget();
return;
}
if (p.playerKOInProgress || ((Actor)p).inAirVent || ((Object)(object)CutSceneController.Instance != (Object)null && CutSceneController.Instance.cutSceneActive))
{
StandNow(p);
return;
}
bool flag = p.autoTravelActive;
if (flag)
{
Phase phase = Phase;
bool flag2 = (uint)(phase - 1) <= 1u;
flag = flag2;
}
if (flag)
{
StandUp(p);
return;
}
GraceUntil = Time.time + 0.5f;
FirstPersonController fps = p.fps;
fps.fallCount = 0f;
float num = ((duration <= 0f) ? 1f : Mathf.Clamp01((Time.time - startTime) / duration));
float num2 = Mathf.SmoothStep(0f, 1f, num);
switch (Phase)
{
case Phase.SittingDown:
((Component)p).transform.position = Vector3.Lerp(fromPos, SeatOrigin(p), num2);
((Component)p).transform.rotation = Quaternion.Slerp(fromRot, toRot, num2);
((Component)fps.m_Camera).transform.localRotation = Quaternion.Euler(Mathf.Lerp(fromPitch, toPitch, num2), 0f, 0f);
if (num >= 1f)
{
fps.m_MouseLook.Init(((Component)p).transform, ((Component)fps.m_Camera).transform);
fps.enableLook = true;
Phase = Phase.Seated;
Prompts.Refresh();
}
break;
case Phase.Seated:
((Component)p).transform.position = SeatOrigin(p);
if (WantsToStand())
{
StandUp(p);
}
break;
case Phase.StandingUp:
((Component)p).transform.position = Vector3.Lerp(fromPos, standPos, num2);
if (num >= 1f)
{
Phase = Phase.None;
Restore(p);
Prompts.Refresh();
}
break;
}
}
private static bool WantsToStand()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
InputController instance = InputController.Instance;
Player val = ((instance != null) ? instance.player : null);
if (val == null)
{
return false;
}
if (val.GetButtonDown("Jump"))
{
return true;
}
float num;
float num2;
if (InputController.Instance.mouseInputMode)
{
num = val.GetAxis("MoveLeft") + val.GetAxis("MoveRight");
num2 = val.GetAxis("MoveBack") + val.GetAxis("MoveForward");
}
else
{
num = val.GetAxis("MoveHorizontal");
num2 = val.GetAxis("MoveVertical");
}
Vector2 val2 = new Vector2(num, num2);
float magnitude = ((Vector2)(ref val2)).magnitude;
if (magnitude < 0.2f)
{
movementReleased = true;
}
if (movementReleased)
{
return magnitude > 0.5f;
}
return false;
}
private static Vector3 SeatOrigin(Player p)
{
//IL_0005: 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_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_0024: Unknown result type (might be due to invalid IL or missing references)
return Current.Eye - Vector3.up * p.camHeightParent.localPosition.y;
}
private static void Restore(Player p)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
p.EnableCharacterController(true);
p.fps.m_StickToGroundForce = 7f;
p.fps.m_GravityMultiplier = 2f;
p.fps.enableHeadBob = true;
p.fps.m_UseJumpBob = true;
p.fps.enableLook = true;
p.fps.fallCount = 0f;
p.fps.lastY = ((Component)p).transform.position.y;
p.EnablePlayerMovement(true, true);
GraceUntil = Time.time + 0.5f;
}
private static void StopPassingTime(Player p)
{
if (p.setAlarmMode)
{
p.SetSettingAlarmMode(false);
}
if (p.spendingTimeMode)
{
p.SetSpendingTimeMode(false);
}
p.spendingTimeDelay = 0f;
}
private static void Begin(Phase phase, float seconds)
{
Phase = phase;
startTime = Time.time;
duration = Mathf.Max(0f, seconds);
}
private static float SignedAngle(float a)
{
if (!(a > 180f))
{
return a;
}
return a - 360f;
}
}
[HarmonyPatch(typeof(Player), "Update")]
internal static class SeatedTickPatch
{
private static float nextErrorLog;
private static void Postfix(Player __instance)
{
try
{
if (!((Object)(object)SessionData.Instance == (Object)null) && SessionData.Instance.play)
{
Seated.Tick(__instance);
if (!Seated.Active)
{
Prompts.Scan(__instance);
}
}
}
catch (Exception ex)
{
if (Time.unscaledTime >= nextErrorLog)
{
nextErrorLog = Time.unscaledTime + 10f;
Plugin.Logger.LogError((object)ex);
}
}
}
}
[HarmonyPatch(typeof(FirstPersonController), "Update")]
internal static class NoFallDamagePatch
{
private static void Prefix(FirstPersonController __instance)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (Seated.Active || !(Time.time > Seated.GraceUntil))
{
__instance.fallCount = 0f;
__instance.lastY = ((Component)__instance).transform.position.y;
}
}
}
[HarmonyPatch(typeof(MouseLook), "LookRotation")]
internal static class LookLimitPatch
{
private static void Postfix(MouseLook __instance, Transform character)
{
//IL_003d: 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)
//IL_0086: 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_0090: Unknown result type (might be due to invalid IL or missing references)
if (Seated.Phase != Phase.Seated)
{
return;
}
float value = Plugin.LookLimit.Value;
if (!(value >= 180f) && !((Object)(object)Player.Instance == (Object)null) && !((Object)(object)character != (Object)(object)((Component)Player.Instance).transform))
{
float y = character.eulerAngles.y;
float num = Mathf.DeltaAngle(Seated.Current.Yaw, y);
if (!(Mathf.Abs(num) <= value))
{
Quaternion rotation = Quaternion.Euler(0f, Seated.Current.Yaw + Mathf.Clamp(num, 0f - value, value), 0f);
character.rotation = rotation;
__instance.m_CharacterTargetRot = character.localRotation;
}
}
}
}
[HarmonyPatch(typeof(Actor), "SetCrouched")]
internal static class NoCrouchPatch
{
private static bool Prefix(Actor __instance)
{
if (Seated.Active)
{
return !__instance.isPlayer;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "RecieveDamage")]
internal static class DamagePatch
{
private static void Postfix(Player __instance, float amount)
{
bool flag = amount > 0.01f;
if (flag)
{
Phase phase = Seated.Phase;
bool flag2 = (uint)(phase - 1) <= 1u;
flag = flag2;
}
if (flag)
{
Seated.StandUp(__instance);
}
}
}
[HarmonyPatch(typeof(Player), "TransformPlayerController")]
internal static class GameTransitionPatch
{
private static void Prefix(Player __instance)
{
try
{
Seated.StandNow(__instance);
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)ex);
}
}
}
[HarmonyPatch(typeof(Player), "Teleport")]
internal static class TeleportPatch
{
private static void Prefix(Player __instance)
{
Seated.EndNow(__instance, restoreController: true);
}
}
[HarmonyPatch(typeof(Player), "SetPosition")]
internal static class SetPositionPatch
{
private static void Prefix(Player __instance)
{
Seated.EndNow(__instance, restoreController: true);
}
}
internal struct Seat
{
public Vector3 Eye;
public float Yaw;
public float Pitch;
public bool Ledge;
}
internal static class SeatFinder
{
private const float Step = 0.05f;
private const float FlatNormal = 0.85f;
private const float SameTopTolerance = 0.04f;
private const float HeadRadius = 0.17f;
public static string LastFailure;
public static bool TryFind(Player player, out Seat seat)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0068: 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)
//IL_0082: 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_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_00eb: 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_00f4: 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_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
seat = default(Seat);
LastFailure = null;
Camera val = (((Object)(object)CameraController.Instance != (Object)null) ? CameraController.Instance.cam : null);
if ((Object)(object)val == (Object)null)
{
return Fail("no camera");
}
int playerMovementLayerMask = Toolbox.Instance.playerMovementLayerMask;
Transform transform = ((Component)player).transform;
Vector3 position = ((Component)val).transform.position;
Vector3 forward = ((Component)val).transform.forward;
float num = transform.position.y - player.GetPlayerHeightNormal() * 0.5f;
RaycastHit val2 = default(RaycastHit);
if (!Physics.Raycast(position, forward, ref val2, Plugin.Reach.Value, playerMovementLayerMask, (QueryTriggerInteraction)1))
{
return Fail("not looking at anything");
}
if (IsExcluded(((RaycastHit)(ref val2)).collider, transform))
{
return Fail("looking at a person");
}
Vector3 val3 = Flat(forward);
if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
{
val3 = Flat(transform.forward);
}
((Vector3)(ref val3)).Normalize();
Vector3 val4 = ((RaycastHit)(ref val2)).point;
if (((RaycastHit)(ref val2)).normal.y < 0.7f)
{
val4 += val3 * 0.08f;
}
float value = Plugin.MaxSeatHeight.Value;
if (!TopAt(val4, num + value + 0.3f, value + 0.6f, transform, playerMovementLayerMask, out var topY))
{
return Fail("no flat top");
}
float num2 = topY - num;
if (num2 >= Plugin.MinSeatHeight.Value && num2 <= value)
{
return SeatHeight(player, transform, playerMovementLayerMask, val4, topY, num, val3, position, out seat);
}
if (Mathf.Abs(num2) <= 0.15f && Plugin.LedgeSitting.Value)
{
return FloorEdge(player, transform, playerMovementLayerMask, val4, topY, val3, position, out seat);
}
return Fail($"wrong height ({num2:0.00}m)");
}
private static bool SeatHeight(Player player, Transform t, int mask, Vector3 sample, float topY, float feetY, Vector3 dir, Vector3 camPos, out Seat seat)
{
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0041: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_014e: 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_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: 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)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: 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_017e: 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_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: 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_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
seat = default(Seat);
bool leftTop;
Vector3 val = March(sample, -dir, 1.2f, topY, t, mask, out leftTop);
bool leftTop2;
Vector3 val2 = March(sample, dir, 1.5f, topY, t, mask, out leftTop2);
Vector3 val3 = Flat(val2 - val);
float magnitude = ((Vector3)(ref val3)).magnitude;
if (magnitude < 0.15f)
{
return Fail($"too thin ({magnitude:0.00}m)");
}
val3 = Flat(val - t.position);
if (((Vector3)(ref val3)).magnitude > 1.3f)
{
return Fail("too far away");
}
bool flag = Plugin.LedgeSitting.Value && magnitude <= 0.9f && leftTop2 && DropBeyond(val2 + dir * 0.15f, topY, Mathf.Min(feetY, topY) - Plugin.LedgeMinDrop.Value, t, mask);
Vector3 hips;
Vector3 facing;
if (flag)
{
hips = val2 - dir * Mathf.Min(0.15f, magnitude * 0.5f);
facing = dir;
if (!LegRoom(val2, topY, dir, t, mask))
{
return Fail("no room for legs");
}
}
else
{
hips = val + dir * Mathf.Min(0.2f, magnitude * 0.5f);
facing = (Plugin.TurnAround.Value ? (-dir) : dir);
}
hips.y = topY;
return Finish(t, mask, hips, facing, flag, camPos, out seat);
}
private static bool FloorEdge(Player player, Transform t, int mask, Vector3 sample, float topY, Vector3 dir, Vector3 camPos, out Seat seat)
{
//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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0062: 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_0079: 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_0085: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: 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)
seat = default(Seat);
bool leftTop;
Vector3 val = March(sample, dir, 1f, topY, t, mask, out leftTop);
if (!leftTop)
{
return Fail("floor, no edge nearby");
}
if (!DropBeyond(val + dir * 0.15f, topY, topY - Plugin.LedgeMinDrop.Value, t, mask))
{
return Fail("edge without a drop");
}
if (!LegRoom(val, topY, dir, t, mask))
{
return Fail("no room for legs");
}
Vector3 val2 = val - dir * 0.1f;
val2.y = topY;
Vector3 val3 = Flat(val2 - t.position);
if (((Vector3)(ref val3)).magnitude > Plugin.Reach.Value)
{
return Fail("too far away");
}
return Finish(t, mask, val2, dir, ledge: true, camPos, out seat);
}
private static bool Finish(Transform t, int mask, Vector3 hips, Vector3 facing, bool ledge, Vector3 camPos, out Seat seat)
{
//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_0018: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_00cf: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: 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_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: 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_014b: Unknown result type (might be due to invalid IL or missing references)
seat = default(Seat);
Vector3 val = hips + Vector3.up * Plugin.EyeAboveSeat.Value + facing * 0.05f;
Vector3 val2 = hips + Vector3.up * 0.37f;
Vector3 val3 = val + Vector3.up * 0.05f;
foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapCapsule(val2, val3, 0.17f, mask, (QueryTriggerInteraction)1))
{
if (!((Object)(object)item == (Object)null) && !((Component)item).transform.IsChildOf(t))
{
return Fail("no headroom (" + ((Object)item).name + ")");
}
}
Vector3 val4 = val - camPos;
RaycastHit val5 = default(RaycastHit);
if (Physics.Raycast(camPos, ((Vector3)(ref val4)).normalized, ref val5, ((Vector3)(ref val4)).magnitude, mask, (QueryTriggerInteraction)1) && !((Component)((RaycastHit)(ref val5)).collider).transform.IsChildOf(t))
{
return Fail("seat is blocked (" + ((Object)((RaycastHit)(ref val5)).collider).name + ")");
}
Seat seat2 = new Seat
{
Eye = val
};
Quaternion val6 = Quaternion.LookRotation(facing, Vector3.up);
seat2.Yaw = ((Quaternion)(ref val6)).eulerAngles.y;
seat2.Pitch = (ledge ? 20f : 5f);
seat2.Ledge = ledge;
seat = seat2;
return true;
}
private static Vector3 March(Vector3 from, Vector3 dir, float max, float topY, Transform t, int mask, out bool leftTop)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: 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_000b: 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)
//IL_0012: 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_0018: 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_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_0029: Unknown result type (might be due to invalid IL or missing references)
Vector3 result = from;
for (float num = 0.05f; num <= max; num += 0.05f)
{
Vector3 val = from + dir * num;
if (!SameTop(val, topY, t, mask))
{
leftTop = true;
return result;
}
result = val;
}
leftTop = false;
return result;
}
private static bool SameTop(Vector3 p, float topY, Transform t, int mask)
{
//IL_0000: 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)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0055: Unknown result type (might be due to invalid IL or missing references)
RaycastHit val = default(RaycastHit);
if (!Physics.Raycast(new Vector3(p.x, topY + 0.25f, p.z), Vector3.down, ref val, 0.35f, mask, (QueryTriggerInteraction)1))
{
return false;
}
if (IsExcluded(((RaycastHit)(ref val)).collider, t))
{
return false;
}
if (((RaycastHit)(ref val)).normal.y >= 0.85f)
{
return Mathf.Abs(((RaycastHit)(ref val)).point.y - topY) <= 0.04f;
}
return false;
}
private static bool TopAt(Vector3 p, float fromY, float distance, Transform t, int mask, out float topY)
{
//IL_0008: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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)
topY = 0f;
RaycastHit val = default(RaycastHit);
if (!Physics.Raycast(new Vector3(p.x, fromY, p.z), Vector3.down, ref val, distance, mask, (QueryTriggerInteraction)1))
{
return false;
}
if (IsExcluded(((RaycastHit)(ref val)).collider, t) || ((RaycastHit)(ref val)).normal.y < 0.85f)
{
return false;
}
topY = ((RaycastHit)(ref val)).point.y;
return true;
}
private static bool DropBeyond(Vector3 p, float topY, float lowestY, Transform t, int mask)
{
//IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(p.x, topY + 0.25f, p.z);
float num = val.y - lowestY;
if (num <= 0f)
{
return false;
}
RaycastHit val2 = default(RaycastHit);
if (!Physics.Raycast(val, Vector3.down, ref val2, num, mask, (QueryTriggerInteraction)1))
{
return true;
}
return ((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(t);
}
private static bool LegRoom(Vector3 edge, float topY, Vector3 dir, Transform t, int mask)
{
//IL_0000: 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)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
RaycastHit val = default(RaycastHit);
return !Physics.Raycast(new Vector3(edge.x, topY - 0.25f, edge.z) - dir * 0.05f, dir, ref val, 0.5f, mask, (QueryTriggerInteraction)1);
}
private static bool IsExcluded(Collider c, Transform player)
{
if ((Object)(object)c == (Object)null)
{
return true;
}
if (((Component)c).transform.IsChildOf(player))
{
return true;
}
return (Object)(object)((Component)c).GetComponentInParent<Actor>() != (Object)null;
}
private static Vector3 Flat(Vector3 v)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(v.x, 0f, v.z);
}
private static bool Fail(string reason)
{
LastFailure = reason;
return false;
}
}
}