using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using Sodalite;
using Sodalite.Api;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using Valve.VR;
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace JerryAr.SpaceAnchor
{
[BepInPlugin("JerryAr.SpaceAnchor", "SpaceAnchor", "0.2.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class SpaceAnchorPlugin : BaseUnityPlugin
{
private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ManualLogSource Logger;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
LoadAssets();
}
private void LoadAssets()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "JerryAr.SpaceAnchor");
AtlasPlugin.RegisterScene(Path.Combine(BasePath, "greenscreenspace"));
OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.SpaceAnchor", "", "", "spaceanchor", "");
}
}
}
public class SnapToPoint : MonoBehaviour
{
public GameObject Obj;
public GameObject Targ;
private void Start()
{
}
private void Update()
{
//IL_0017: 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)
Obj.transform.position = Targ.transform.position;
Obj.transform.rotation = Targ.transform.rotation;
}
}
namespace JerrySpaceAnchor
{
public class ConFollow : MonoBehaviour
{
public GameObject colGeoL;
public GameObject conGeoR;
public GameObject ConL;
public GameObject ConR;
public GameObject ConGeoLSub;
public GameObject ConGeoRSub;
public AR15HandleSightFlipper conltog;
public AR15HandleSightFlipper conrtog;
public Material White;
public Material Green;
public Vector3 temppos;
public Vector3 temprot;
public AudioEvent click;
private Vector3 lastStableHeadPos;
private Vector3 lastStableHeadRot;
private bool hasInitialized = false;
public float speedThreshold = 3f;
public float rotSpeedThreshold = 180f;
private Vector3 lastStableLocalPos;
private Vector3 lastStableLocalRot;
private Vector3 lastStableWorldPos;
private Vector3 lastStableWorldRot;
private bool needForceFix = false;
private Vector3 forceFixLocalPos;
private Vector3 forceFixLocalRot;
public float cd;
public bool needfix;
private int lockRemainingFrames = 0;
private Transform tempTr;
private Transform curTr;
private Transform lockTr;
private float localPosThreshold = 0.01f;
private float localRotThreshold = 1f;
private int lockFrames = 0;
public float speedvelthr = 0.5f;
public bool logOpenVRPose = false;
public float openVRLogInterval = 1f;
public float resetZeroThreshold = 0.08f;
public float resetMovementThreshold = 0.12f;
public float resetJumpThreshold = 0.1f;
public float resetRotationJumpThreshold = 20f;
public float resetYawZeroThreshold = 8f;
private CVRSystem openVRSystem;
private Vector3 openVRCurrentStanding;
private Vector3 openVRCurrentSeated;
private Vector3 openVRCurrentRaw;
private Vector3 openVRPreviousStanding;
private Vector3 openVRPreviousSeated;
private Vector3 openVRPreviousRaw;
private bool hasOpenVRPose = false;
private float openVRCurrentYaw = 0f;
private float openVRPreviousYaw = 0f;
private bool steamVRResetEventReceived = false;
private float nextOpenVRLogTime = 0f;
private bool resetCompensationInProgress = false;
private int resetCooldownFrames = 0;
private bool rotationCompensationActive = false;
private float forcedManagerYaw = 0f;
public float xSign;
public float zSign;
public void Start()
{
//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_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)
//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_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)
Transform transform = ((Component)GM.CurrentMovementManager).gameObject.transform;
lastStableHeadPos = transform.position;
lastStableHeadRot = transform.eulerAngles;
hasInitialized = true;
temppos = transform.position;
temprot = transform.eulerAngles;
try
{
SteamVR_Events.System((EVREventType)804).Listen((UnityAction<VREvent_t>)OnSteamVRReset);
Debug.Log((object)"[ConFollow] SteamVR Reset listener installed.");
}
catch (Exception ex)
{
Debug.LogWarning((object)("[ConFollow] Failed to install SteamVR Reset listener: " + ex.Message));
}
InitializeOpenVR();
}
private void InitializeOpenVR()
{
try
{
openVRSystem = OpenVR.System;
if (openVRSystem == null)
{
Debug.LogWarning((object)"[ConFollow] OpenVR.System is NULL.");
}
else
{
Debug.Log((object)"[ConFollow] OpenVR system initialized.");
}
}
catch (Exception ex)
{
openVRSystem = null;
Debug.LogWarning((object)("[ConFollow] OpenVR initialization failed: " + ex.Message));
}
}
private void OnSteamVRReset(VREvent_t e)
{
steamVRResetEventReceived = true;
Debug.Log((object)"[ConFollow] SteamVR Reset event received.");
}
private bool GetOpenVRPose(ETrackingUniverseOrigin origin, out Vector3 position, out float yaw)
{
//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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
position = Vector3.zero;
yaw = 0f;
if (openVRSystem == null)
{
InitializeOpenVR();
if (openVRSystem == null)
{
return false;
}
}
try
{
TrackedDevicePose_t[] array = (TrackedDevicePose_t[])(object)new TrackedDevicePose_t[64];
openVRSystem.GetDeviceToAbsoluteTrackingPose(origin, 0f, array);
uint num = 0u;
if (num >= array.Length)
{
return false;
}
if (!array[num].bPoseIsValid)
{
return false;
}
HmdMatrix34_t mDeviceToAbsoluteTracking = array[num].mDeviceToAbsoluteTracking;
((Vector3)(ref position))..ctor(mDeviceToAbsoluteTracking.m3, mDeviceToAbsoluteTracking.m7, 0f - mDeviceToAbsoluteTracking.m11);
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(mDeviceToAbsoluteTracking.m2, mDeviceToAbsoluteTracking.m6, 0f - mDeviceToAbsoluteTracking.m10);
val.y = 0f;
if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
{
((Vector3)(ref val)).Normalize();
yaw = Mathf.Atan2(val.x, val.z) * 57.29578f;
yaw = NormalizeAngle(yaw);
}
return true;
}
catch (Exception ex)
{
Debug.LogWarning((object)("[ConFollow] OpenVR pose read failed: " + ex.Message));
return false;
}
}
private float NormalizeAngle(float angle)
{
while (angle > 180f)
{
angle -= 360f;
}
while (angle < -180f)
{
angle += 360f;
}
return angle;
}
private void UpdateOpenVRPose()
{
//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_0075: 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)
//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_003c: 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)
if (!resetCompensationInProgress && GetOpenVRPose((ETrackingUniverseOrigin)1, out var position, out var yaw))
{
if (!hasOpenVRPose)
{
openVRCurrentStanding = position;
openVRPreviousStanding = position;
openVRCurrentYaw = yaw;
openVRPreviousYaw = yaw;
hasOpenVRPose = true;
}
else
{
openVRPreviousStanding = openVRCurrentStanding;
openVRPreviousYaw = openVRCurrentYaw;
openVRCurrentStanding = position;
openVRCurrentYaw = yaw;
}
}
}
private bool DetectOpenVRPositionReset(Vector3 previous, Vector3 current)
{
//IL_003b: 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)
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(previous.x, previous.z);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(current.x, current.z);
float magnitude = ((Vector2)(ref val)).magnitude;
float magnitude2 = ((Vector2)(ref val2)).magnitude;
float num = Vector2.Distance(val, val2);
if (magnitude < resetMovementThreshold)
{
return false;
}
if (magnitude2 > resetZeroThreshold)
{
return false;
}
if (num < resetJumpThreshold)
{
return false;
}
return true;
}
private bool DetectOpenVRRotationReset(float previousYaw, float currentYaw)
{
float num = Mathf.Abs(Mathf.DeltaAngle(previousYaw, currentYaw));
return num >= resetRotationJumpThreshold;
}
private bool DetectOpenVRReset()
{
//IL_0064: 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)
if (steamVRResetEventReceived)
{
return true;
}
float num = Mathf.Abs(Mathf.DeltaAngle(openVRPreviousYaw, openVRCurrentYaw));
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(openVRPreviousStanding.x, openVRPreviousStanding.z);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(openVRCurrentStanding.x, openVRCurrentStanding.z);
float num2 = Vector2.Distance(val, val2);
bool flag = num >= 8f;
return num2 >= 0.03f || flag;
}
private bool ForceGetOpenVRPose(out Vector3 position, out float yaw)
{
//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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
position = Vector3.zero;
yaw = 0f;
if (openVRSystem == null)
{
InitializeOpenVR();
if (openVRSystem == null)
{
return false;
}
}
try
{
TrackedDevicePose_t[] array = (TrackedDevicePose_t[])(object)new TrackedDevicePose_t[64];
openVRSystem.GetDeviceToAbsoluteTrackingPose((ETrackingUniverseOrigin)1, 0f, array);
uint num = 0u;
if (num >= array.Length || !array[num].bPoseIsValid)
{
return false;
}
HmdMatrix34_t mDeviceToAbsoluteTracking = array[num].mDeviceToAbsoluteTracking;
((Vector3)(ref position))..ctor(mDeviceToAbsoluteTracking.m3, mDeviceToAbsoluteTracking.m7, 0f - mDeviceToAbsoluteTracking.m11);
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(mDeviceToAbsoluteTracking.m2, mDeviceToAbsoluteTracking.m6, 0f - mDeviceToAbsoluteTracking.m10);
val.y = 0f;
if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
{
((Vector3)(ref val)).Normalize();
yaw = Mathf.Atan2(val.x, val.z) * 57.29578f;
yaw = NormalizeAngle(yaw);
}
return true;
}
catch (Exception ex)
{
Debug.LogWarning((object)("[ConFollow] Force OpenVR pose read failed: " + ex.Message));
return false;
}
}
public void ApplyResetCompensation()
{
//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)
if (!resetCompensationInProgress && hasOpenVRPose)
{
Vector3 val = openVRPreviousStanding;
float num = openVRPreviousYaw;
((MonoBehaviour)this).StartCoroutine(ApplyResetCompensationCoroutine());
}
}
private IEnumerator ApplyResetCompensationCoroutine()
{
resetCompensationInProgress = true;
Transform manager = ((Component)GM.CurrentMovementManager).gameObject.transform;
if ((Object)(object)GM.CurrentPlayerBody == (Object)null || (Object)(object)GM.CurrentPlayerBody.Head == (Object)null)
{
resetCompensationInProgress = false;
yield break;
}
lockFrames = 0;
lockTr = null;
tempTr = null;
Vector3 managerPosBefore = manager.position;
Quaternion managerRotBefore = manager.rotation;
Vector3 oldOpenVRPos = openVRPreviousStanding;
float oldOpenVRYaw = openVRPreviousYaw;
yield return null;
yield return null;
if (!ForceGetOpenVRPose(out var newOpenVRPos, out var newOpenVRYaw))
{
resetCompensationInProgress = false;
yield break;
}
Vector3 deltaOpenVR = new Vector3(newOpenVRPos.x - oldOpenVRPos.x, 0f, newOpenVRPos.z - oldOpenVRPos.z);
Transform hmd = ((Component)GM.CurrentPlayerBody.Head).transform;
float hmdYaw = hmd.eulerAngles.y;
Vector3 worldDelta = Quaternion.Euler(0f, hmdYaw, 0f) * deltaOpenVR;
manager.position = managerPosBefore;
manager.rotation = managerRotBefore;
float deltaYaw = Mathf.DeltaAngle(newOpenVRYaw, oldOpenVRYaw);
if (Mathf.Abs(deltaYaw) > 0.001f)
{
manager.Rotate(Vector3.up, deltaYaw, (Space)0);
}
Vector3 targetPos = managerPosBefore - worldDelta;
targetPos.y = 0f;
manager.position = targetPos;
temppos = manager.position;
temprot = manager.eulerAngles;
steamVRResetEventReceived = false;
resetCooldownFrames = 10;
resetCompensationInProgress = false;
}
private void Update()
{
//IL_0024: 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_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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
UpdateOpenVRPose();
Transform transform = ((Component)GM.CurrentMovementManager).gameObject.transform;
if (FlagPostPlugin.SpawnFlagPosts)
{
temppos = transform.position;
temprot = transform.eulerAngles;
}
else
{
if (resetCooldownFrames > 0)
{
resetCooldownFrames--;
}
else if (DetectOpenVRReset())
{
ApplyResetCompensation();
}
else if (steamVRResetEventReceived)
{
steamVRResetEventReceived = false;
}
if (!resetCompensationInProgress)
{
temppos.y = 0f;
transform.position = temppos;
transform.eulerAngles = temprot;
}
}
GM.CurrentMovementManager.m_isTwinStickSmoothTurningClockwise = false;
GM.CurrentMovementManager.m_isTwinStickSmoothTurningCounterClockwise = false;
GM.CurrentMovementManager.m_timeSinceSnapTurn = 999f;
if (FlagPostPlugin.SpawnFlagPosts)
{
if ((Object)(object)White != (Object)null)
{
White.SetColor("_Color", Color.Lerp(White.GetColor("_Color"), Color.white, Time.deltaTime * 2.5f));
}
if ((Object)(object)Green != (Object)null)
{
Green.SetColor("_Color", Color.Lerp(Green.GetColor("_Color"), new Color(0f, 1f, 0f, 0f), Time.deltaTime * 2.5f));
}
}
if (!FlagPostPlugin.SpawnFlagPosts)
{
if ((Object)(object)White != (Object)null)
{
White.SetColor("_Color", Color.Lerp(White.GetColor("_Color"), new Color(1f, 1f, 1f, 0f), Time.deltaTime * 2.5f));
}
if ((Object)(object)Green != (Object)null)
{
Green.SetColor("_Color", Color.Lerp(Green.GetColor("_Color"), Color.green, Time.deltaTime * 2.5f));
}
}
if ((Object)(object)ConL != (Object)null && GM.CurrentMovementManager.Hands != null && GM.CurrentMovementManager.Hands.Length > 0 && (Object)(object)GM.CurrentMovementManager.Hands[0] != (Object)null && (Object)(object)GM.CurrentMovementManager.Hands[0].Collider_Fingers != (Object)null)
{
ConL.transform.position = ((Component)GM.CurrentMovementManager.Hands[0].Collider_Fingers).transform.position;
ConL.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[0].Collider_Fingers).transform.rotation;
}
if ((Object)(object)ConR != (Object)null && GM.CurrentMovementManager.Hands != null && GM.CurrentMovementManager.Hands.Length > 1 && (Object)(object)GM.CurrentMovementManager.Hands[1] != (Object)null && (Object)(object)GM.CurrentMovementManager.Hands[1].Collider_Fingers != (Object)null)
{
ConR.transform.position = ((Component)GM.CurrentMovementManager.Hands[1].Collider_Fingers).transform.position;
ConR.transform.rotation = ((Component)GM.CurrentMovementManager.Hands[1].Collider_Fingers).transform.rotation;
}
}
private void FixedUpdate()
{
//IL_0076: 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_00d1: 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)
if ((Object)(object)conltog != (Object)null && (Object)(object)ConGeoLSub != (Object)null && (Object)(object)ConL != (Object)null)
{
if (!conltog.m_isLargeAperture && !ConGeoLSub.activeSelf)
{
if (click != null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, click, ConL.transform.position);
}
ConGeoLSub.SetActive(true);
}
if (conltog.m_isLargeAperture && ConGeoLSub.activeSelf)
{
if (click != null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, click, ConL.transform.position);
}
ConGeoLSub.SetActive(false);
}
}
if ((Object)(object)conrtog != (Object)null && (Object)(object)ConGeoRSub != (Object)null && (Object)(object)ConR != (Object)null)
{
if (!conrtog.m_isLargeAperture && !ConGeoRSub.activeSelf)
{
if (click != null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, click, ConR.transform.position);
}
ConGeoRSub.SetActive(true);
}
if (conrtog.m_isLargeAperture && ConGeoRSub.activeSelf)
{
if (click != null)
{
SM.PlayCoreSound((FVRPooledAudioType)41, click, ConR.transform.position);
}
ConGeoRSub.SetActive(false);
}
}
if (GM.CurrentMovementManager.Hands != null && GM.CurrentMovementManager.Hands.Length > 0 && (Object)(object)GM.CurrentMovementManager.Hands[0] != (Object)null && (Object)(object)colGeoL != (Object)null)
{
if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable != (Object)null)
{
colGeoL.SetActive(false);
}
else
{
colGeoL.SetActive(true);
}
}
if (GM.CurrentMovementManager.Hands != null && GM.CurrentMovementManager.Hands.Length > 1 && (Object)(object)GM.CurrentMovementManager.Hands[1] != (Object)null && (Object)(object)conGeoR != (Object)null)
{
if ((Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable != (Object)null)
{
conGeoR.SetActive(false);
}
else
{
conGeoR.SetActive(true);
}
}
}
private void LateUpdate()
{
//IL_014e: 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_016a: 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_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
if (FlagPostPlugin.SpawnFlagPosts)
{
return;
}
if (resetCompensationInProgress || resetCooldownFrames > 0)
{
if ((Object)(object)GM.CurrentPlayerBody != (Object)null && (Object)(object)GM.CurrentPlayerBody.Head != (Object)null)
{
tempTr = ((Component)GM.CurrentPlayerBody.Head).gameObject.transform;
}
}
else
{
if ((Object)(object)GM.CurrentPlayerBody == (Object)null || (Object)(object)GM.CurrentPlayerBody.Head == (Object)null)
{
return;
}
Transform transform = ((Component)GM.CurrentPlayerBody.Head).gameObject.transform;
curTr = ((Component)transform).transform;
if (!hasInitialized)
{
tempTr = curTr;
hasInitialized = true;
return;
}
if (lockFrames > 0)
{
if ((Object)(object)lockTr != (Object)null)
{
GM.CurrentPlayerBody.MoveTransformRelativeToTarget(((Component)GM.CurrentPlayerBody.Head).gameObject.transform, lockTr, true);
}
lockFrames--;
return;
}
if ((Object)(object)tempTr != (Object)null)
{
float num = Vector3.Distance(curTr.localPosition, tempTr.localPosition);
float num2 = Mathf.Abs(Mathf.DeltaAngle(curTr.localEulerAngles.y, tempTr.localEulerAngles.y));
if ((num > localPosThreshold || num2 > localRotThreshold) && GM.CurrentPlayerBody.GetBodyMovementSpeed() > speedvelthr)
{
GM.CurrentPlayerBody.MoveTransformRelativeToTarget(((Component)GM.CurrentPlayerBody.Head).gameObject.transform, tempTr, true);
lockFrames = 10;
lockTr = tempTr;
return;
}
}
tempTr = curTr;
}
}
}
public class FlagPostGreen : MonoBehaviour
{
public FlagPostGreen OtherAnchor;
public float cd = 0.25f;
public bool isRoot;
private void FixedUpdate()
{
//IL_0027: 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_0123: Unknown result type (might be due to invalid IL or missing references)
if (isRoot)
{
((Component)this).gameObject.transform.eulerAngles = new Vector3(0f, 0f, 0f);
}
if (!isRoot)
{
((Component)this).gameObject.transform.eulerAngles = new Vector3(0f, 90f, 0f);
}
if (cd > 0f)
{
cd -= Time.deltaTime;
}
if (!(cd <= 0f))
{
return;
}
cd = 0f;
if ((Object)(object)OtherAnchor == (Object)null)
{
FlagPostGreen[] array = Object.FindObjectsOfType<FlagPostGreen>();
if (array.Length > 0)
{
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)(object)this)
{
OtherAnchor = array[i];
}
}
}
}
if ((Object)(object)OtherAnchor != (Object)null)
{
((Component)this).gameObject.transform.position = ((Component)OtherAnchor).gameObject.transform.position;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
isRoot = true;
}
private void OnDisable()
{
isRoot = false;
cd = 0.25f;
}
}
[BepInPlugin("JerryDLL.JerrySpaceAnchor", "JSA", "1.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
[BepInProcess("h3vr.exe")]
public class FlagPostPlugin : BaseUnityPlugin
{
public GameObject FlagPostPreView;
public GameObject FlagPostRed;
public GameObject FlagPostGreen;
public GameObject FlagPostRedTemp;
public GameObject FlagPostGreenTemp;
public GameObject Anchor;
public GameObject AnchorGM;
public float triggercd = 1f;
public bool shouldsetred;
public bool isLeft;
public bool isRight;
public bool isTriggerHeld;
public static bool SpawnFlagPosts = false;
public Vector3 pos;
public Vector3 rot;
public LayerMask lm;
public bool TransformAccuired;
public bool disabled = false;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogMessage((object)"New harmony");
Logger.LogMessage((object)"Setted the fields");
Harmony.CreateAndPatchAll(typeof(FlagPostPlugin), (string)null);
Logger.LogMessage((object)"Loaded sf System");
}
[HarmonyPatch(typeof(FVRWristMenu2), "Awake")]
[HarmonyPostfix]
public static void SFWMAH(FVRWristMenu2 __instance)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
if ((Object)(object)__instance == (Object)null)
{
Logger.LogMessage((object)"No FVRWristMenu2");
}
bool flag = false;
string text = "SetSpaceAnchor?";
foreach (WristMenuButton button in WristMenuAPI.Buttons)
{
Logger.LogMessage((object)("CC " + button.Text));
if (button.Text == text)
{
flag = true;
break;
}
}
if (!flag)
{
WristMenuAPI.Buttons.Add(new WristMenuButton(text, new ButtonClickEvent(SpawnSAFP)));
}
}
private static void SpawnSAFP(object sender, ButtonClickEventArgs args)
{
//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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "GreenScreenSpace")
{
SpawnFlagPosts = !SpawnFlagPosts;
}
Scene activeScene2 = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene2)).name != "GreenScreenSpace")
{
SpawnFlagPosts = false;
}
}
public void FixedUpdate()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_00aa: 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)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
lm = LayerMask.op_Implicit(268435456);
if (SpawnFlagPosts)
{
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "GreenScreenSpace")
{
if ((Object)(object)FlagPostRedTemp == (Object)null && (Object)(object)Object.FindObjectOfType<FlagPostRed>() != (Object)null)
{
FlagPostRedTemp = ((Component)Object.FindObjectOfType<FlagPostRed>()).gameObject;
}
if ((Object)(object)FlagPostGreenTemp == (Object)null && (Object)(object)Object.FindObjectOfType<FlagPostGreen>() != (Object)null)
{
FlagPostGreenTemp = ((Component)Object.FindObjectOfType<FlagPostGreen>()).gameObject;
}
}
}
Scene activeScene2 = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene2)).name == "GreenScreenSpace"))
{
return;
}
if (SpawnFlagPosts && (Object)(object)GM.CurrentMovementManager != (Object)null)
{
if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable == (Object)null)
{
GM.CurrentMovementManager.Hands[0].Display_Controller.SetActive(true);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere.SetActive(true);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere_Palm.SetActive(true);
}
else if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable != (Object)null)
{
GM.CurrentMovementManager.Hands[0].Display_Controller.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere_Palm.SetActive(false);
}
if ((Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable == (Object)null)
{
GM.CurrentMovementManager.Hands[1].Display_Controller.SetActive(true);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere.SetActive(true);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere_Palm.SetActive(true);
}
else if ((Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable != (Object)null)
{
GM.CurrentMovementManager.Hands[1].Display_Controller.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere_Palm.SetActive(false);
}
GM.CurrentMovementManager.Hands[0].Display_Controller_Cosmos.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_HPR2.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Index.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Quest2.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Quest3.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_RiftS.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Touch.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Vive.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_WMR.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Cosmos.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_HPR2.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Index.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Quest2.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Quest3.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_RiftS.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Touch.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Vive.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_WMR.SetActive(false);
if (disabled)
{
GM.CurrentMovementManager.Hands[0].Collider_Fingers.radius = GM.CurrentMovementManager.Hands[0].Collider_Fingers.radius * 0.5f;
GM.CurrentMovementManager.Hands[0].Collider_Palm.radius = GM.CurrentMovementManager.Hands[0].Collider_Palm.radius * 0.5f;
GM.CurrentMovementManager.Hands[1].Collider_Fingers.radius = GM.CurrentMovementManager.Hands[1].Collider_Fingers.radius * 0.5f;
GM.CurrentMovementManager.Hands[1].Collider_Palm.radius = GM.CurrentMovementManager.Hands[1].Collider_Palm.radius * 0.5f;
disabled = false;
}
}
if (!SpawnFlagPosts && (Object)(object)GM.CurrentMovementManager != (Object)null)
{
GM.CurrentMovementManager.Hands[0].Display_Controller.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_InteractionSphere_Palm.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_InteractionSphere_Palm.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Cosmos.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_HPR2.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Index.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Quest2.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Quest3.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_RiftS.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Touch.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_Vive.SetActive(false);
GM.CurrentMovementManager.Hands[0].Display_Controller_WMR.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Cosmos.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_HPR2.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Index.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Quest2.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Quest3.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_RiftS.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Touch.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_Vive.SetActive(false);
GM.CurrentMovementManager.Hands[1].Display_Controller_WMR.SetActive(false);
if (!disabled)
{
GM.CurrentMovementManager.Hands[0].Collider_Fingers.radius = GM.CurrentMovementManager.Hands[0].Collider_Fingers.radius * 2f;
GM.CurrentMovementManager.Hands[0].Collider_Palm.radius = GM.CurrentMovementManager.Hands[0].Collider_Palm.radius * 2f;
GM.CurrentMovementManager.Hands[1].Collider_Fingers.radius = GM.CurrentMovementManager.Hands[1].Collider_Fingers.radius * 2f;
GM.CurrentMovementManager.Hands[1].Collider_Palm.radius = GM.CurrentMovementManager.Hands[1].Collider_Palm.radius * 2f;
disabled = true;
}
}
}
private void AxisLookAt(Transform tr_self, Vector3 lookPos, Vector3 directionAxis)
{
//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_000a: 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_0014: 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_001c: 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_0023: 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)
//IL_0029: 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_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = tr_self.rotation;
Vector3 val = lookPos - tr_self.position;
Vector3 val2 = tr_self.rotation * directionAxis;
Vector3 val3 = Vector3.Cross(val2, val);
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Angle(val2, val);
tr_self.rotation = Quaternion.AngleAxis(num, normalized) * rotation;
tr_self.localEulerAngles = new Vector3(0f, tr_self.localEulerAngles.y, 0f);
}
public void Update()
{
//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_0b91: Unknown result type (might be due to invalid IL or missing references)
//IL_0b96: Unknown result type (might be due to invalid IL or missing references)
//IL_0ac7: Unknown result type (might be due to invalid IL or missing references)
//IL_0acc: Unknown result type (might be due to invalid IL or missing references)
//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
//IL_0c19: Unknown result type (might be due to invalid IL or missing references)
//IL_0c1e: Unknown result type (might be due to invalid IL or missing references)
//IL_0c24: Unknown result type (might be due to invalid IL or missing references)
//IL_0c29: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Unknown result type (might be due to invalid IL or missing references)
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_0473: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
//IL_0614: Unknown result type (might be due to invalid IL or missing references)
//IL_0619: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_0533: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_0542: Unknown result type (might be due to invalid IL or missing references)
//IL_0556: Unknown result type (might be due to invalid IL or missing references)
//IL_055b: Unknown result type (might be due to invalid IL or missing references)
//IL_0574: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_0121: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: 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_06bb: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0707: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0876: Unknown result type (might be due to invalid IL or missing references)
//IL_0891: Unknown result type (might be due to invalid IL or missing references)
//IL_0896: Unknown result type (might be due to invalid IL or missing references)
//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
//IL_08d2: Unknown result type (might be due to invalid IL or missing references)
//IL_08f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "GreenScreenSpace")
{
GM.CurrentSceneSettings.IsSceneSavingEnabled = true;
if ((Object)(object)FlagPostRedTemp != (Object)null && (Object)(object)FlagPostGreenTemp != (Object)null)
{
if (FlagPostRedTemp.activeInHierarchy && FlagPostGreenTemp.activeInHierarchy && FlagPostRedTemp.transform.eulerAngles.y == 0f && FlagPostGreenTemp.transform.eulerAngles.y == 0f)
{
if ((Object)(object)Anchor == (Object)null)
{
Anchor = new GameObject("SpaceAnchor");
}
if ((Object)(object)AnchorGM == (Object)null)
{
AnchorGM = new GameObject("SpaceAnchorGM");
}
if ((Object)(object)Anchor != (Object)null)
{
Anchor.transform.position = (FlagPostRedTemp.transform.position + FlagPostGreenTemp.transform.position) / 2f;
AxisLookAt(Anchor.transform, FlagPostRedTemp.transform.position, Vector3.forward);
if ((Object)(object)AnchorGM != (Object)null)
{
if (!TransformAccuired)
{
AnchorGM.transform.position = ((Component)GM.CurrentMovementManager).gameObject.transform.position;
AnchorGM.transform.eulerAngles = ((Component)GM.CurrentMovementManager).gameObject.transform.eulerAngles;
AnchorGM.transform.SetParent(Anchor.transform);
if ((Object)(object)AnchorGM.transform.parent == (Object)(object)Anchor.transform)
{
pos = AnchorGM.transform.localPosition;
rot = AnchorGM.transform.localEulerAngles;
TransformAccuired = true;
}
}
if (TransformAccuired)
{
AnchorGM.transform.SetParent(Anchor.transform);
AnchorGM.transform.localPosition = new Vector3(pos.x, AnchorGM.transform.localPosition.y, pos.z);
AnchorGM.transform.localEulerAngles = rot;
((Component)GM.CurrentMovementManager).gameObject.transform.position = AnchorGM.transform.position;
((Component)GM.CurrentMovementManager).gameObject.transform.eulerAngles = AnchorGM.transform.eulerAngles;
}
}
}
}
if (!FlagPostRedTemp.activeInHierarchy || !FlagPostGreenTemp.activeInHierarchy || FlagPostRedTemp.transform.eulerAngles.y != 0f || FlagPostGreenTemp.transform.eulerAngles.y != 0f)
{
((Component)GM.CurrentMovementManager).gameObject.transform.SetParent((Transform)null);
}
}
if (SpawnFlagPosts)
{
if ((Object)(object)FlagPostRed == (Object)null && (Object)(object)FlagPostRedTemp != (Object)null)
{
FlagPostRed = FlagPostRedTemp;
}
if ((Object)(object)FlagPostGreen == (Object)null && (Object)(object)FlagPostGreenTemp != (Object)null)
{
FlagPostGreen = FlagPostGreenTemp;
}
if ((Object)(object)FlagPostRed == (Object)null && (Object)(object)FlagPostRedTemp == (Object)null)
{
ItemSpawnerID spawnerID = IM.GetSpawnerID("FlagPostRed");
FVRObject mainObject = spawnerID.MainObject;
FlagPostRed = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)GM.CurrentMovementManager).gameObject.transform.position + ((Component)GM.CurrentMovementManager).gameObject.transform.forward * 0.5f, new Quaternion(0f, GM.CurrentMovementManager.Head.rotation.y + 180f, 0f, 1f));
FlagPostRed.SetActive(false);
Logger.LogMessage((object)"RedFlag Deployed.");
}
if ((Object)(object)FlagPostGreen == (Object)null && (Object)(object)FlagPostGreenTemp == (Object)null)
{
ItemSpawnerID spawnerID2 = IM.GetSpawnerID("FlagPostGreen");
FVRObject mainObject2 = spawnerID2.MainObject;
FlagPostGreen = Object.Instantiate<GameObject>(((AnvilAsset)mainObject2).GetGameObject(), ((Component)GM.CurrentMovementManager).gameObject.transform.position + ((Component)GM.CurrentMovementManager).gameObject.transform.forward * 0.5f, new Quaternion(0f, GM.CurrentMovementManager.Head.rotation.y + 180f, 0f, 1f));
FlagPostGreen.SetActive(false);
Logger.LogMessage((object)"GreenFlag Deployed.");
}
if ((Object)(object)FlagPostPreView == (Object)null)
{
ItemSpawnerID spawnerID3 = IM.GetSpawnerID("FlagPostPreView");
FVRObject mainObject3 = spawnerID3.MainObject;
FlagPostPreView = Object.Instantiate<GameObject>(((AnvilAsset)mainObject3).GetGameObject(), ((Component)GM.CurrentMovementManager).gameObject.transform.position + ((Component)GM.CurrentMovementManager).gameObject.transform.forward * 0.5f, new Quaternion(0f, GM.CurrentMovementManager.Head.rotation.y + 180f, 0f, 1f));
FlagPostRed.SetActive(false);
Logger.LogMessage((object)"FlagPostPreView Deployed.");
}
if ((Object)(object)FlagPostPreView != (Object)null)
{
if (isTriggerHeld)
{
if (shouldsetred && (Object)(object)FlagPostRed != (Object)null)
{
FlagPostRed.SetActive(false);
FlagPostRed.transform.position = FlagPostPreView.transform.position;
}
if (!shouldsetred && (Object)(object)FlagPostGreen != (Object)null)
{
FlagPostGreen.SetActive(false);
FlagPostGreen.transform.position = FlagPostPreView.transform.position;
}
}
if (!isTriggerHeld)
{
FlagPostPreView.SetActive(false);
if (triggercd <= 0f)
{
if (shouldsetred && (Object)(object)FlagPostRed != (Object)null)
{
FlagPostRed.SetActive(true);
triggercd = 1f;
shouldsetred = false;
}
if (!shouldsetred && (Object)(object)FlagPostGreen != (Object)null)
{
FlagPostGreen.SetActive(true);
triggercd = 1f;
shouldsetred = true;
}
}
}
}
if ((Object)(object)FlagPostPreView != (Object)null)
{
if (GM.CurrentMovementManager.Hands[0].Input.TriggerFloat > 0.75f && !isRight)
{
if (!isLeft)
{
triggercd = 1f;
isLeft = true;
}
if (triggercd > 0f)
{
triggercd -= Time.deltaTime;
}
if (triggercd <= 0f)
{
triggercd = 0f;
isTriggerHeld = true;
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.position, -((Component)GM.CurrentMovementManager.Hands[0]).gameObject.transform.up, ref val, 10f, LayerMask.op_Implicit(lm)))
{
FlagPostPreView.SetActive(true);
FlagPostPreView.transform.position = ((RaycastHit)(ref val)).point;
FlagPostPreView.transform.eulerAngles = new Vector3(0f, 0f, 0f);
}
}
}
if (GM.CurrentMovementManager.Hands[1].Input.TriggerFloat > 0.75f && !isLeft)
{
if (!isRight)
{
triggercd = 1f;
isRight = true;
}
if (triggercd > 0f)
{
triggercd -= Time.deltaTime;
}
if (triggercd <= 0f)
{
triggercd = 0f;
isTriggerHeld = true;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.position, -((Component)GM.CurrentMovementManager.Hands[1]).gameObject.transform.up, ref val2, 10f, LayerMask.op_Implicit(lm)))
{
FlagPostPreView.SetActive(true);
FlagPostPreView.transform.position = ((RaycastHit)(ref val2)).point;
FlagPostPreView.transform.eulerAngles = new Vector3(0f, 0f, 0f);
}
}
}
if (GM.CurrentMovementManager.Hands[0].Input.TriggerFloat <= 0.75f && isLeft)
{
isTriggerHeld = false;
isLeft = false;
}
if (GM.CurrentMovementManager.Hands[1].Input.TriggerFloat <= 0.75f && isRight)
{
isTriggerHeld = false;
isRight = false;
}
}
}
else if (!SpawnFlagPosts)
{
pos = Vector3.zero;
rot = Vector3.zero;
shouldsetred = false;
if ((Object)(object)FlagPostRed != (Object)null)
{
Object.Destroy((Object)(object)FlagPostRed.gameObject);
}
if ((Object)(object)FlagPostGreen != (Object)null)
{
Object.Destroy((Object)(object)FlagPostGreen.gameObject);
}
if ((Object)(object)FlagPostPreView != (Object)null)
{
Object.Destroy((Object)(object)FlagPostPreView.gameObject);
}
if ((Object)(object)Anchor != (Object)null)
{
Object.Destroy((Object)(object)Anchor);
}
if ((Object)(object)AnchorGM != (Object)null)
{
Object.Destroy((Object)(object)AnchorGM);
}
TransformAccuired = false;
}
}
Scene activeScene2 = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene2)).name != "GreenScreenSpace")
{
if ((Object)(object)FlagPostRed != (Object)null)
{
Object.Destroy((Object)(object)FlagPostRed.gameObject);
}
if ((Object)(object)FlagPostGreen != (Object)null)
{
Object.Destroy((Object)(object)FlagPostGreen.gameObject);
}
if ((Object)(object)FlagPostPreView != (Object)null)
{
Object.Destroy((Object)(object)FlagPostPreView.gameObject);
}
pos = Vector3.zero;
rot = Vector3.zero;
shouldsetred = false;
}
}
}
public class FlagPostRed : MonoBehaviour
{
public FlagPostRed OtherAnchor;
public float cd = 0.25f;
public bool isRoot;
private void FixedUpdate()
{
//IL_0027: 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_0123: Unknown result type (might be due to invalid IL or missing references)
if (isRoot)
{
((Component)this).gameObject.transform.eulerAngles = new Vector3(0f, 0f, 0f);
}
if (!isRoot)
{
((Component)this).gameObject.transform.eulerAngles = new Vector3(0f, 90f, 0f);
}
if (cd > 0f)
{
cd -= Time.deltaTime;
}
if (!(cd <= 0f))
{
return;
}
cd = 0f;
if ((Object)(object)OtherAnchor == (Object)null)
{
FlagPostRed[] array = Object.FindObjectsOfType<FlagPostRed>();
if (array.Length > 0)
{
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)(object)this)
{
OtherAnchor = array[i];
}
}
}
}
if ((Object)(object)OtherAnchor != (Object)null)
{
((Component)this).gameObject.transform.position = ((Component)OtherAnchor).gameObject.transform.position;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
isRoot = true;
}
private void OnDisable()
{
isRoot = false;
cd = 0.25f;
}
}
public class GraabTransfer : MonoBehaviour
{
public FVRInteractiveObject grab;
public FVRInteractiveObject targ;
public Collider col;
private void Update()
{
if (!targ.m_isHeld)
{
grab.ForceBreakInteraction();
col.enabled = false;
}
if (targ.m_isHeld)
{
col.enabled = true;
}
}
}
public class ObjShapeChanger : MonoBehaviour
{
public enum Type
{
Capsule,
Cube,
Cylinder,
Sphere
}
public FVRObject refposID;
public GameObject SphereInst;
public FVRFireArmMagazine main;
public Type Shape;
public GameObject whole;
public GameObject up;
public GameObject down;
public GameObject uppos;
public GameObject downpos;
public GameObject refposholderout;
public GameObject refposholder;
public GameObject refpos;
public GameObject refposWorld;
public MeshRenderer Green;
public MeshRenderer White;
public MeshRenderer GreenUp;
public MeshRenderer WhiteUp;
public MeshRenderer GreenDown;
public MeshRenderer WhiteDown;
public float cd = 0f;
public FVRInteractiveObject grab;
public Collider col;
public Material GreenMat;
public Material WhiteMat;
public Material GreenMatS;
public Material WhiteMatS;
public bool refFound;
public bool noRef;
private static int s_nextRoundNumber = 0;
private static List<GameObject> s_claimedRefObjects = new List<GameObject>();
public int r;
public void Start()
{
if ((Object)(object)main != (Object)null)
{
if (main.m_numRounds <= 0)
{
main.m_numRounds = AllocateUniqueRoundNumber();
}
else if (main.m_numRounds > s_nextRoundNumber)
{
s_nextRoundNumber = main.m_numRounds;
}
}
if ((Object)(object)refposholderout != (Object)null)
{
refposholderout.transform.SetParent((Transform)null);
}
}
private int AllocateUniqueRoundNumber()
{
int i;
for (i = s_nextRoundNumber + 1; IsPersistentRoundNumberUsed(i); i++)
{
}
s_nextRoundNumber = i;
return i;
}
private bool IsPersistentRoundNumberUsed(int number)
{
FVRFireArmMagazine[] array = Object.FindObjectsOfType<FVRFireArmMagazine>();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && array[i].m_numRounds == number)
{
return true;
}
}
ObjShapeChanger[] array2 = Object.FindObjectsOfType<ObjShapeChanger>();
for (int i = 0; i < array2.Length; i++)
{
if ((Object)(object)array2[i] != (Object)null && (Object)(object)array2[i].main != (Object)null && (Object)(object)array2[i].main != (Object)(object)main && array2[i].main.m_numRounds == number)
{
return true;
}
}
return false;
}
private string GetRefObjectName()
{
if (Shape == Type.Capsule)
{
return "refCapsule(Clone)";
}
if (Shape == Type.Cube)
{
return "refCube(Clone)";
}
if (Shape == Type.Cylinder)
{
return "refCylinder(Clone)";
}
return "refSphere(Clone)";
}
private void CleanupClaimedRefObjects()
{
for (int num = s_claimedRefObjects.Count - 1; num >= 0; num--)
{
if ((Object)(object)s_claimedRefObjects[num] == (Object)null)
{
s_claimedRefObjects.RemoveAt(num);
}
}
}
private bool IsRefClaimed(GameObject obj)
{
if ((Object)(object)obj == (Object)null)
{
return false;
}
CleanupClaimedRefObjects();
return s_claimedRefObjects.Contains(obj);
}
private void ClaimRef(GameObject obj)
{
if (!((Object)(object)obj == (Object)null))
{
CleanupClaimedRefObjects();
if (!s_claimedRefObjects.Contains(obj))
{
s_claimedRefObjects.Add(obj);
}
}
}
private bool IsRefAlreadyBoundToAnotherChanger(GameObject obj)
{
if ((Object)(object)obj == (Object)null)
{
return false;
}
ObjShapeChanger[] array = Object.FindObjectsOfType<ObjShapeChanger>();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && (Object)(object)array[i] != (Object)(object)this && (Object)(object)array[i].refposWorld == (Object)(object)obj)
{
return true;
}
}
return false;
}
private void AssignNewPersistentId()
{
if (!((Object)(object)main == (Object)null))
{
main.m_numRounds = AllocateUniqueRoundNumber();
}
}
private bool TryFindRefWorld()
{
if ((Object)(object)main == (Object)null)
{
return false;
}
FVRFireArmMagazine[] array = Object.FindObjectsOfType<FVRFireArmMagazine>();
string refObjectName = GetRefObjectName();
for (int i = 0; i < array.Length; i++)
{
if (!((Object)(object)array[i] == (Object)null) && !(((Object)((Component)array[i]).gameObject).name != refObjectName) && array[i].m_numRounds == main.m_numRounds && !IsRefClaimed(((Component)array[i]).gameObject) && !IsRefAlreadyBoundToAnotherChanger(((Component)array[i]).gameObject))
{
refposWorld = ((Component)array[i]).gameObject;
FVRFireArmMagazine component = refposWorld.GetComponent<FVRFireArmMagazine>();
if ((Object)(object)component != (Object)null)
{
component.m_numRounds = main.m_numRounds;
EnsureMagazineRounds(component);
}
ClaimRef(refposWorld);
refFound = true;
noRef = false;
ApplyRefWorld();
return true;
}
}
return false;
}
private void EnsureMagazineRounds(FVRFireArmMagazine magazine)
{
if ((Object)(object)magazine == (Object)null)
{
return;
}
int num = 0;
while (magazine.LoadedRounds != null && magazine.LoadedRounds.Length < magazine.m_numRounds && num < 256)
{
int num2 = magazine.LoadedRounds.Length;
magazine.AddRound((FireArmRoundClass)1, false, false);
num++;
if (magazine.LoadedRounds == null || magazine.LoadedRounds.Length <= num2)
{
break;
}
}
}
private bool CreateRefWorld()
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: 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_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)refposID == (Object)null || (Object)(object)refposholder == (Object)null || (Object)(object)refpos == (Object)null || (Object)(object)main == (Object)null)
{
return false;
}
if (Shape == Type.Capsule)
{
ItemSpawnerID spawnerID = IM.GetSpawnerID("refCapsule");
FVRObject mainObject = spawnerID.MainObject;
refposWorld = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), refposholder.transform.position, refposholder.transform.rotation);
if ((Object)(object)refposWorld.GetComponent<FVRPhysicalObject>() != (Object)null)
{
refposWorld.GetComponent<FVRPhysicalObject>().IDSpawnedFrom = spawnerID;
}
Debug.Log((object)"refCapsule Deployed.");
}
if (Shape == Type.Cube)
{
ItemSpawnerID spawnerID2 = IM.GetSpawnerID("refCube");
FVRObject mainObject2 = spawnerID2.MainObject;
refposWorld = Object.Instantiate<GameObject>(((AnvilAsset)mainObject2).GetGameObject(), refposholder.transform.position, refposholder.transform.rotation);
if ((Object)(object)refposWorld.GetComponent<FVRPhysicalObject>() != (Object)null)
{
refposWorld.GetComponent<FVRPhysicalObject>().IDSpawnedFrom = spawnerID2;
}
Debug.Log((object)"refCube Deployed.");
}
if (Shape == Type.Cylinder)
{
ItemSpawnerID spawnerID3 = IM.GetSpawnerID("refCylinder");
FVRObject mainObject3 = spawnerID3.MainObject;
refposWorld = Object.Instantiate<GameObject>(((AnvilAsset)mainObject3).GetGameObject(), refposholder.transform.position, refposholder.transform.rotation);
if ((Object)(object)refposWorld.GetComponent<FVRPhysicalObject>() != (Object)null)
{
refposWorld.GetComponent<FVRPhysicalObject>().IDSpawnedFrom = spawnerID3;
}
Debug.Log((object)"refCylinder Deployed.");
}
if (Shape == Type.Sphere)
{
ItemSpawnerID spawnerID4 = IM.GetSpawnerID("refSphere");
FVRObject mainObject4 = spawnerID4.MainObject;
refposWorld = Object.Instantiate<GameObject>(((AnvilAsset)mainObject4).GetGameObject(), refposholder.transform.position, refposholder.transform.rotation);
if ((Object)(object)refposWorld.GetComponent<FVRPhysicalObject>() != (Object)null)
{
refposWorld.GetComponent<FVRPhysicalObject>().IDSpawnedFrom = spawnerID4;
}
Debug.Log((object)"refSphere Deployed.");
}
if ((Object)(object)refposWorld == (Object)null)
{
return false;
}
FVRFireArmMagazine component = refposWorld.GetComponent<FVRFireArmMagazine>();
if ((Object)(object)component == (Object)null)
{
Object.Destroy((Object)(object)refposWorld);
refposWorld = null;
return false;
}
component.m_numRounds = main.m_numRounds;
EnsureMagazineRounds(component);
refposWorld.transform.position = refpos.transform.position;
ClaimRef(refposWorld);
refFound = true;
noRef = false;
return true;
}
private void FindOrCreateRefWorld()
{
if ((Object)(object)refposWorld != (Object)null || (Object)(object)main == (Object)null)
{
return;
}
refFound = false;
noRef = false;
if (!TryFindRefWorld())
{
if (HasClaimedRefWithSameId())
{
AssignNewPersistentId();
}
noRef = true;
CreateRefWorld();
}
}
private bool HasClaimedRefWithSameId()
{
if ((Object)(object)main == (Object)null)
{
return false;
}
FVRFireArmMagazine[] array = Object.FindObjectsOfType<FVRFireArmMagazine>();
string refObjectName = GetRefObjectName();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && ((Object)((Component)array[i]).gameObject).name == refObjectName && array[i].m_numRounds == main.m_numRounds && (IsRefClaimed(((Component)array[i]).gameObject) || IsRefAlreadyBoundToAnotherChanger(((Component)array[i]).gameObject)))
{
return true;
}
}
return false;
}
private void ApplyRefWorld()
{
//IL_0050: 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)
//IL_0095: 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)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)refposWorld == (Object)null || (Object)(object)refpos == (Object)null || (Object)(object)main == (Object)null)
{
return;
}
refpos.transform.position = refposWorld.transform.position;
if (Shape == Type.Capsule)
{
CapsuleCollider component = ((Component)main).gameObject.GetComponent<CapsuleCollider>();
if ((Object)(object)component != (Object)null)
{
component.radius = refpos.transform.localPosition.z;
component.height = refpos.transform.localPosition.y * 2f;
}
}
else if (Shape == Type.Cube)
{
BoxCollider component2 = ((Component)main).gameObject.GetComponent<BoxCollider>();
if ((Object)(object)component2 != (Object)null)
{
component2.size = new Vector3(refpos.transform.localPosition.x * 2f, refpos.transform.localPosition.y * 2f, refpos.transform.localPosition.z * 2f);
}
}
else if (Shape == Type.Cylinder)
{
CapsuleCollider component3 = ((Component)main).gameObject.GetComponent<CapsuleCollider>();
if ((Object)(object)component3 != (Object)null)
{
component3.radius = refpos.transform.localPosition.z;
component3.height = refpos.transform.localPosition.y * 2f;
}
}
else if (Shape == Type.Sphere)
{
SphereCollider component4 = ((Component)main).gameObject.GetComponent<SphereCollider>();
if ((Object)(object)component4 != (Object)null)
{
component4.radius = refpos.transform.localPosition.z;
}
}
}
private MeshRenderer FindMeshRendererInChildren(GameObject root, int index)
{
if ((Object)(object)root == (Object)null)
{
return null;
}
MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true);
if (componentsInChildren == null || componentsInChildren.Length <= index)
{
return null;
}
return componentsInChildren[index];
}
private void SetupUpDownRenderers()
{
if ((Object)(object)up != (Object)null)
{
MeshRenderer[] componentsInChildren = up.GetComponentsInChildren<MeshRenderer>(true);
if (componentsInChildren != null)
{
if (componentsInChildren.Length > 0)
{
GreenUp = componentsInChildren[0];
}
if (componentsInChildren.Length > 1)
{
WhiteUp = componentsInChildren[1];
}
}
if ((Object)(object)up.transform.parent != (Object)null)
{
up.transform.SetParent((Transform)null);
}
}
if (!((Object)(object)down != (Object)null))
{
return;
}
MeshRenderer[] componentsInChildren2 = down.GetComponentsInChildren<MeshRenderer>(true);
if (componentsInChildren2 != null)
{
if (componentsInChildren2.Length > 0)
{
GreenDown = componentsInChildren2[0];
}
if (componentsInChildren2.Length > 1)
{
WhiteDown = componentsInChildren2[1];
}
}
if ((Object)(object)down.transform.parent != (Object)null)
{
down.transform.SetParent((Transform)null);
}
}
private void FixedUpdate()
{
if ((Object)(object)refposWorld != (Object)null && (Object)(object)refposWorld.GetComponent<FVRFireArmMagazine>() != (Object)null && refposWorld.GetComponent<FVRFireArmMagazine>().LoadedRounds.Length >= refposWorld.GetComponent<FVRFireArmMagazine>().m_numRounds)
{
for (int i = 0; i < refposWorld.GetComponent<FVRFireArmMagazine>().m_numRounds; i++)
{
if (i > 0 && refposWorld.GetComponent<FVRFireArmMagazine>().LoadedRounds[0] != null)
{
refposWorld.GetComponent<FVRFireArmMagazine>().LoadedRounds[i] = refposWorld.GetComponent<FVRFireArmMagazine>().LoadedRounds[0];
}
}
}
if (main.LoadedRounds.Length < main.m_numRounds)
{
return;
}
for (int j = 0; j < main.m_numRounds; j++)
{
if (j > 0 && main.LoadedRounds[0] != null)
{
main.LoadedRounds[j] = main.LoadedRounds[0];
}
}
}
private void Update()
{
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Expected O, but got Unknown
//IL_0061: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: 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_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_0430: Unknown result type (might be due to invalid IL or missing references)
//IL_044a: Unknown result type (might be due to invalid IL or missing references)
//IL_044f: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_046e: Unknown result type (might be due to invalid IL or missing references)
//IL_047d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0614: Unknown result type (might be due to invalid IL or missing references)
//IL_0619: Unknown result type (might be due to invalid IL or missing references)
//IL_0633: Unknown result type (might be due to invalid IL or missing references)
//IL_0638: Unknown result type (might be due to invalid IL or missing references)
//IL_0647: Unknown result type (might be due to invalid IL or missing references)
//IL_04af: Unknown result type (might be due to invalid IL or missing references)
//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0501: Unknown result type (might be due to invalid IL or missing references)
//IL_0521: Unknown result type (might be due to invalid IL or missing references)
//IL_0675: Unknown result type (might be due to invalid IL or missing references)
//IL_067a: Unknown result type (might be due to invalid IL or missing references)
//IL_0694: Unknown result type (might be due to invalid IL or missing references)
//IL_0699: Unknown result type (might be due to invalid IL or missing references)
//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0554: Unknown result type (might be due to invalid IL or missing references)
//IL_0559: Unknown result type (might be due to invalid IL or missing references)
//IL_0573: Unknown result type (might be due to invalid IL or missing references)
//IL_0578: Unknown result type (might be due to invalid IL or missing references)
//IL_0592: Unknown result type (might be due to invalid IL or missing references)
//IL_0597: Unknown result type (might be due to invalid IL or missing references)
//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0714: Unknown result type (might be due to invalid IL or missing references)
//IL_0719: Unknown result type (might be due to invalid IL or missing references)
//IL_0733: Unknown result type (might be due to invalid IL or missing references)
//IL_0738: Unknown result type (might be due to invalid IL or missing references)
//IL_0747: Unknown result type (might be due to invalid IL or missing references)
//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
//IL_097c: Unknown result type (might be due to invalid IL or missing references)
//IL_0981: Unknown result type (might be due to invalid IL or missing references)
//IL_0992: Unknown result type (might be due to invalid IL or missing references)
//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0acb: Unknown result type (might be due to invalid IL or missing references)
//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
//IL_0b4e: Unknown result type (might be due to invalid IL or missing references)
//IL_0ca7: Unknown result type (might be due to invalid IL or missing references)
//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
//IL_0d79: Unknown result type (might be due to invalid IL or missing references)
//IL_0d7e: Unknown result type (might be due to invalid IL or missing references)
//IL_0ce8: Unknown result type (might be due to invalid IL or missing references)
//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
//IL_0d07: Unknown result type (might be due to invalid IL or missing references)
//IL_0d0c: Unknown result type (might be due to invalid IL or missing references)
//IL_0d26: Unknown result type (might be due to invalid IL or missing references)
//IL_0d2b: Unknown result type (might be due to invalid IL or missing references)
//IL_0d3a: Unknown result type (might be due to invalid IL or missing references)
//IL_0bf1: Unknown result type (might be due to invalid IL or missing references)
//IL_0bf6: Unknown result type (might be due to invalid IL or missing references)
//IL_0bc0: Unknown result type (might be due to invalid IL or missing references)
//IL_0e3b: Unknown result type (might be due to invalid IL or missing references)
//IL_0e40: Unknown result type (might be due to invalid IL or missing references)
//IL_0dbf: Unknown result type (might be due to invalid IL or missing references)
//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
//IL_0ded: Unknown result type (might be due to invalid IL or missing references)
//IL_0df2: Unknown result type (might be due to invalid IL or missing references)
//IL_0c37: Unknown result type (might be due to invalid IL or missing references)
//IL_0c3c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c65: Unknown result type (might be due to invalid IL or missing references)
//IL_0c6a: Unknown result type (might be due to invalid IL or missing references)
//IL_0e81: Unknown result type (might be due to invalid IL or missing references)
//IL_0e86: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)refposWorld == (Object)null && (Object)(object)main != (Object)null)
{
FindOrCreateRefWorld();
}
if ((Object)(object)SphereInst != (Object)null)
{
if ((Object)(object)up == (Object)null)
{
up = Object.Instantiate<GameObject>(SphereInst, uppos.transform.position, uppos.transform.rotation);
}
if ((Object)(object)down == (Object)null)
{
down = Object.Instantiate<GameObject>(SphereInst, downpos.transform.position, downpos.transform.rotation);
}
SetupUpDownRenderers();
if (Shape == Type.Capsule)
{
if ((Object)(object)up != (Object)null)
{
up.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f);
up.transform.position = uppos.transform.position;
}
if ((Object)(object)down != (Object)null)
{
up.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f);
down.transform.position = downpos.transform.position;
}
}
}
if ((Object)(object)GreenMat == (Object)null)
{
GreenMat = new Material(GreenMatS);
if ((Object)(object)Green != (Object)null)
{
((Renderer)Green).material = GreenMat;
}
if ((Object)(object)GreenUp != (Object)null)
{
((Renderer)GreenUp).material = GreenMat;
}
if ((Object)(object)GreenDown != (Object)null)
{
((Renderer)GreenDown).material = GreenMat;
}
}
if ((Object)(object)WhiteMat == (Object)null)
{
WhiteMat = new Material(WhiteMatS);
if ((Object)(object)White != (Object)null)
{
((Renderer)White).material = WhiteMat;
}
if ((Object)(object)WhiteUp != (Object)null)
{
((Renderer)WhiteUp).material = WhiteMat;
}
if ((Object)(object)WhiteDown != (Object)null)
{
((Renderer)WhiteDown).material = WhiteMat;
}
}
if ((Object)(object)refpos != (Object)null && (Object)(object)refposWorld != (Object)null && (Object)(object)refpos.GetComponent<FVRFireArmMagazine>() != (Object)null && (Object)(object)refposWorld.GetComponent<FVRFireArmMagazine>() != (Object)null && refposWorld.GetComponent<FVRFireArmMagazine>().LoadedRounds.Length < refposWorld.GetComponent<FVRFireArmMagazine>().m_numRounds)
{
refposWorld.GetComponent<FVRFireArmMagazine>().AddRound((FireArmRoundClass)1, false, false);
}
if ((Object)(object)main != (Object)null && main.LoadedRounds.Length < main.m_numRounds)
{
main.AddRound((FireArmRoundClass)1, false, false);
}
if (Shape == Type.Capsule)
{
whole.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.y * 20f, refpos.transform.localPosition.z * 20f);
if ((Object)(object)up != (Object)null)
{
up.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f);
up.transform.position = uppos.transform.position;
}
if ((Object)(object)down != (Object)null)
{
down.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f);
down.transform.position = downpos.transform.position;
}
}
if (Shape == Type.Cube)
{
whole.transform.localScale = new Vector3(refpos.transform.localPosition.x * 20f, refpos.transform.localPosition.y * 20f, refpos.transform.localPosition.z * 20f);
}
if (Shape == Type.Cylinder)
{
whole.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.y * 10f, refpos.transform.localPosition.z * 20f);
}
if (Shape == Type.Sphere)
{
whole.transform.localScale = new Vector3(refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f, refpos.transform.localPosition.z * 20f);
}
if (((FVRInteractiveObject)main).m_isHeld)
{
col.enabled = false;
}
if (!((FVRInteractiveObject)main).m_isHeld)
{
if (cd >= 1f)
{
col.enabled = true;
}
if (cd < 1f)
{
col.enabled = false;
}
}
refposholderout.transform.position = ((Component)main).gameObject.transform.position;
refposholderout.transform.rotation = ((Component)main).gameObject.transform.rotation;
if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable == (Object)null && (Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable == (Object)null && GM.CurrentMovementManager.Hands[0].Input.GripPressed && GM.CurrentMovementManager.Hands[1].Input.GripPressed)
{
cd = Mathf.Lerp(cd, 5f, Time.deltaTime);
}
if ((Object)(object)GM.CurrentMovementManager.Hands[0].m_currentInteractable != (Object)null || (Object)(object)GM.CurrentMovementManager.Hands[1].m_currentInteractable != (Object)null || !GM.CurrentMovementManager.Hands[0].Input.GripPressed || !GM.CurrentMovementManager.Hands[1].Input.GripPressed)
{
if (((FVRInteractiveObject)main).m_isHeld)
{
cd = Mathf.Lerp(cd, 5f, Time.deltaTime);
}
if (!((FVRInteractiveObject)main).m_isHeld)
{
cd = Mathf.Lerp(cd, 0f, Time.deltaTime);
}
}
WhiteMat.SetColor("_Color", Color.Lerp(new Color(1f, 1f, 1f, 0f), Color.white, cd / 5f));
GreenMat.SetColor("_Color", Color.Lerp(Color.green, new Color(0f, 1f, 0f, 0f), cd / 5f));
if (cd >= 1f)
{
((FVRInteractiveObject)main).IsSimpleInteract = false;
grab.IsSimpleInteract = false;
((FVRPhysicalObject)main).DistantGrabbable = true;
}
if (cd < 1f)
{
((FVRInteractiveObject)main).ForceBreakInteraction();
((FVRInteractiveObject)main).IsSimpleInteract = true;
((FVRPhysicalObject)main).DistantGrabbable = false;
grab.ForceBreakInteraction();
grab.IsSimpleInteract = true;
}
if (!((FVRInteractiveObject)main).m_isHeld || !grab.m_isHeld)
{
if ((Object)(object)refposWorld != (Object)null)
{
refposWorld.transform.position = refpos.transform.position;
}
refposholder.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
}
if (!((FVRInteractiveObject)main).m_isHeld || !grab.m_isHeld)
{
return;
}
if ((Object)(object)refposWorld != (Object)null)
{
refpos.transform.position = refposWorld.transform.position;
refposWorld.transform.position = ((Component)((FVRInteractiveObject)main).m_hand.OtherHand).gameObject.transform.position;
}
if (Shape == Type.Capsule)
{
if ((Object)(object)up != (Object)null)
{
up.transform.position = uppos.transform.position;
}
if ((Object)(object)down != (Object)null)
{
down.transform.position = downpos.transform.position;
}
AxisLookAt(refposholder.transform, ((Component)((FVRInteractiveObject)main).m_hand.OtherHand).gameObject.transform.position, Vector3.forward);
if ((Object)(object)((Component)main).gameObject.GetComponent<CapsuleCollider>() != (Object)null)
{
((Component)main).gameObject.GetComponent<CapsuleCollider>().radius = refpos.transform.localPosition.z;
((Component)main).gameObject.GetComponent<CapsuleCollider>().height = refpos.transform.localPosition.y * 4f;
}
}
if (Shape == Type.Cube)
{
refposholder.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
if ((Object)(object)((Component)main).gameObject.GetComponent<BoxCollider>() != (Object)null)
{
((Component)main).gameObject.GetComponent<BoxCollider>().size = new Vector3(refpos.transform.localPosition.x * 2f, refpos.transform.localPosition.y * 2f, refpos.transform.localPosition.z * 2f);
}
}
if (Shape == Type.Cylinder)
{
AxisLookAt(refposholder.transform, ((Component)((FVRInteractiveObject)main).m_hand.OtherHand).gameObject.transform.position, Vector3.forward);
if ((Object)(object)((Component)main).gameObject.GetComponent<CapsuleCollider>() != (Object)null)
{
((Component)main).gameObject.GetComponent<CapsuleCollider>().radius = refpos.transform.localPosition.z;
((Component)main).gameObject.GetComponent<CapsuleCollider>().height = refpos.transform.localPosition.y * 2f;
}
}
if (Shape == Type.Sphere)
{
AxisLookAt2(refposholder.transform, ((Component)((FVRInteractiveObject)main).m_hand.OtherHand).gameObject.transform.position, Vector3.forward);
if ((Object)(object)((Component)main).gameObject.GetComponent<SphereCollider>() != (Object)null)
{
((Component)main).gameObject.GetComponent<SphereCollider>().radius = refpos.transform.localPosition.z;
}
}
}
private void AxisLookAt(Transform tr_self, Vector3 lookPos, Vector3 directionAxis)
{
//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_000a: 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_0014: 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_001c: 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_0023: 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)
//IL_0029: 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_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = tr_self.rotation;
Vector3 val = lookPos - tr_self.position;
Vector3 val2 = tr_self.rotation * directionAxis;
Vector3 val3 = Vector3.Cross(val2, val);
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Angle(val2, val);
tr_self.rotation = Quaternion.AngleAxis(num, normalized) * rotation;
tr_self.localEulerAngles = new Vector3(0f, tr_self.localEulerAngles.y, 0f);
}
private void AxisLookAt2(Transform tr_self, Vector3 lookPos, Vector3 directionAxis)
{
//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_000a: 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_0014: 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_001c: 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_0023: 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)
//IL_0029: 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_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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)
Quaternion rotation = tr_self.rotation;
Vector3 val = lookPos - tr_self.position;
Vector3 val2 = tr_self.rotation * directionAxis;
Vector3 val3 = Vector3.Cross(val2, val);
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float num = Vector3.Angle(val2, val);
tr_self.rotation = Quaternion.AngleAxis(num, normalized) * rotation;
tr_self.localEulerAngles = new Vector3(tr_self.localEulerAngles.x, tr_self.localEulerAngles.y, 0f);
}
private void OnDestroy()
{
if ((Object)(object)up != (Object)null)
{
Object.Destroy((Object)(object)up);
}
if ((Object)(object)down != (Object)null)
{
Object.Destroy((Object)(object)down);
}
if ((Object)(object)refposholderout != (Object)null)
{
Object.Destroy((Object)(object)refposholderout);
}
}
}
public class SpawnerHide : MonoBehaviour
{
public ItemSpawnerV2 spawner;
private void Update()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)spawner == (Object)null)
{
spawner = Object.FindObjectOfType<ItemSpawnerV2>();
}
if ((Object)(object)spawner != (Object)null)
{
((Component)spawner).gameObject.transform.localScale = new Vector3(0f, 0f, 0f);
}
}
}
}