Check for props game settings and world restrictions

Combat system integration
Additional measure for unsafe worlds
This commit is contained in:
SDraw 2023-04-12 21:33:25 +03:00
parent 5185c00fb1
commit 912b37c87f
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
9 changed files with 186 additions and 57 deletions

View file

@ -1,11 +1,16 @@
using ABI.CCK.Components;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.MovementSystem;
using System.Reflection;
using UnityEngine;
namespace ml_prm
{
static class Utils
{
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
static readonly FieldInfo ms_grounded = typeof(MovementSystem).GetField("_isGrounded", BindingFlags.NonPublic | BindingFlags.Instance);
public static bool IsInVR() => ((CheckVR.Instance != null) && CheckVR.Instance.hasVrDeviceLoaded);
public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
public static float GetWorldFlyMultiplier()
{
@ -15,6 +20,8 @@ namespace ml_prm
return l_result;
}
public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_grounded.GetValue(p_instance);
public static void CopyGlobal(this Transform p_source, Transform p_target)
{
p_target.position = p_source.position;