Minor cleanup

This commit is contained in:
SDraw 2023-12-25 02:02:45 +03:00
parent 6a671d0da6
commit 9e841cef1c
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
15 changed files with 142 additions and 171 deletions

View file

@ -2,7 +2,6 @@
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using ABI_RC.Systems.MovementSystem; using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK; using RootMotion.FinalIK;
using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;

View file

@ -1,6 +1,5 @@
using ABI_RC.Core.UI; using ABI_RC.Core.UI;
using System.Reflection; using System.Reflection;
using UnityEngine;
namespace ml_asl namespace ml_asl
{ {

View file

@ -13,8 +13,8 @@ namespace ml_lme
"leapmotion_hands.asset" "leapmotion_hands.asset"
}; };
static Dictionary<string, AssetBundle> ms_loadedAssets = new Dictionary<string, AssetBundle>(); static readonly Dictionary<string, AssetBundle> ms_loadedAssets = new Dictionary<string, AssetBundle>();
static Dictionary<string, GameObject> ms_loadedObjects = new Dictionary<string, GameObject>(); static readonly Dictionary<string, GameObject> ms_loadedObjects = new Dictionary<string, GameObject>();
public static void Load() public static void Load()
{ {

View file

@ -283,7 +283,7 @@ namespace ml_lme
{ {
float l_strength = l_data.m_leftHand.m_grabStrength; float l_strength = l_data.m_leftHand.m_grabStrength;
float l_interactValue = 0f; float l_interactValue;
if(m_gripToGrab) if(m_gripToGrab)
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength)); l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength));
else else
@ -311,7 +311,7 @@ namespace ml_lme
{ {
float l_strength = l_data.m_rightHand.m_grabStrength; float l_strength = l_data.m_rightHand.m_grabStrength;
float l_interactValue = 0f; float l_interactValue;
if(m_gripToGrab) if(m_gripToGrab)
l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength)); l_interactValue = Mathf.Clamp01(Mathf.InverseLerp(Mathf.Min(Settings.GripThreadhold, Settings.InteractThreadhold), Mathf.Max(Settings.GripThreadhold, Settings.InteractThreadhold), l_strength));
else else

View file

@ -1,5 +1,4 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Systems.IK.SubSystems;
using System.Collections; using System.Collections;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;

View file

@ -1,9 +1,5 @@
using System; using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ml_lme namespace ml_lme
{ {

View file

@ -4,17 +4,14 @@ namespace ml_lme
{ {
class VisualHand class VisualHand
{ {
Transform m_root = null; readonly Transform m_wrist = null;
Transform m_wrist = null; readonly Transform[] m_fingers = null;
Transform[] m_fingers = null;
public VisualHand(Transform p_root, bool p_left) public VisualHand(Transform p_root, bool p_left)
{ {
m_root = p_root; if(p_root != null)
if(m_root != null)
{ {
m_wrist = m_root.Find(p_left ? "LeftHand/Wrist" : "RightHand/Wrist"); m_wrist = p_root.Find(p_left ? "LeftHand/Wrist" : "RightHand/Wrist");
if(m_wrist != null) if(m_wrist != null)
{ {
m_fingers = new Transform[20]; m_fingers = new Transform[20];

View file

@ -59,12 +59,7 @@ namespace ml_pin
l_notify |= (Settings.FriendsAlways && l_isFriend); l_notify |= (Settings.FriendsAlways && l_isFriend);
if(l_notify) if(l_notify)
{ m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin);
if(l_isFriend)
m_soundManager?.PlaySound(SoundManager.SoundType.FriendJoin);
else
m_soundManager?.PlaySound(SoundManager.SoundType.PlayerJoin);
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -93,12 +88,7 @@ namespace ml_pin
l_notify |= (Settings.FriendsAlways && l_isFriend); l_notify |= (Settings.FriendsAlways && l_isFriend);
if(l_notify) if(l_notify)
{ m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave);
if(l_isFriend)
m_soundManager?.PlaySound(SoundManager.SoundType.FriendLeave);
else
m_soundManager?.PlaySound(SoundManager.SoundType.PlayerLeave);
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -108,9 +98,9 @@ namespace ml_pin
bool ShouldNotifyInCurrentInstance() bool ShouldNotifyInCurrentInstance()
{ {
bool l_isInPublic = Settings.NotifyInPublic && MetaPort.Instance.CurrentInstancePrivacy.Contains("Public"); bool l_isInPublic = (Settings.NotifyInPublic && MetaPort.Instance.CurrentInstancePrivacy.Contains("Public"));
bool l_isInFriends = Settings.NotifyInFriends && MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends"); bool l_isInFriends = (Settings.NotifyInFriends && MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends"));
bool l_isInPrivate = Settings.NotifyInPrivate && MetaPort.Instance.CurrentInstancePrivacy.Contains("invite"); bool l_isInPrivate = (Settings.NotifyInPrivate && MetaPort.Instance.CurrentInstancePrivacy.Contains("invite"));
return (l_isInPublic || l_isInFriends || l_isInPrivate); return (l_isInPublic || l_isInFriends || l_isInPrivate);
} }
} }

View file

@ -1,5 +1,4 @@
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.IK; using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
@ -81,8 +80,8 @@ namespace ml_pmc
CVRInputManager.Instance.individualFingerTracking = true; CVRInputManager.Instance.individualFingerTracking = true;
IKSystem.Instance.FingerSystem.controlActive = true; IKSystem.Instance.FingerSystem.controlActive = true;
ref float[] l_curls = ref m_puppetParser.GetFingerCurls(); ref readonly float[] l_curls = ref m_puppetParser.GetFingerCurls();
ref float[] l_spreads = ref m_puppetParser.GetFingerSpreads(); ref readonly float[] l_spreads = ref m_puppetParser.GetFingerSpreads();
CVRInputManager.Instance.fingerCurlLeftThumb = l_curls[l_mirror ? 5 : 0]; CVRInputManager.Instance.fingerCurlLeftThumb = l_curls[l_mirror ? 5 : 0];
CVRInputManager.Instance.fingerCurlLeftIndex = l_curls[l_mirror ? 6 : 1]; CVRInputManager.Instance.fingerCurlLeftIndex = l_curls[l_mirror ? 6 : 1];

View file

@ -20,8 +20,8 @@ namespace ml_pmc
float m_leftGesture = 0f; float m_leftGesture = 0f;
float m_rightGesture = 0f; float m_rightGesture = 0f;
bool m_fingerTracking = false; bool m_fingerTracking = false;
float[] m_fingerCurls = null; readonly float[] m_fingerCurls = null;
float[] m_fingerSpreads = null; readonly float[] m_fingerSpreads = null;
internal PuppetParser() internal PuppetParser()
{ {
@ -102,7 +102,7 @@ namespace ml_pmc
public float GetLeftGesture() => m_leftGesture; public float GetLeftGesture() => m_leftGesture;
public float GetRightGesture() => m_rightGesture; public float GetRightGesture() => m_rightGesture;
public bool HasFingerTracking() => m_fingerTracking; public bool HasFingerTracking() => m_fingerTracking;
public ref float[] GetFingerCurls() => ref m_fingerCurls; public ref readonly float[] GetFingerCurls() => ref m_fingerCurls;
public ref float[] GetFingerSpreads() => ref m_fingerSpreads; public ref readonly float[] GetFingerSpreads() => ref m_fingerSpreads;
} }
} }

View file

@ -1,9 +1,6 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI_RC.Systems.InputManagement; using ABI_RC.Systems.InputManagement;
using System.Linq;
using System.Reflection;
using UnityEngine; using UnityEngine;
namespace ml_pmc namespace ml_pmc

View file

@ -1,7 +1,6 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.InteractionSystem; using ABI_RC.Core.InteractionSystem;
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior;
using ABI_RC.Systems.Camera; using ABI_RC.Systems.Camera;
using ABI_RC.Systems.IK; using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems; using ABI_RC.Systems.IK.SubSystems;
@ -22,7 +21,6 @@ namespace ml_prm
public static RagdollController Instance { get; private set; } = null; public static RagdollController Instance { get; private set; } = null;
bool m_inVr = false;
VRIK m_vrIK = null; VRIK m_vrIK = null;
bool m_applyHipsPosition = false; bool m_applyHipsPosition = false;
bool m_applyHipsRotation = false; bool m_applyHipsRotation = false;
@ -69,8 +67,6 @@ namespace ml_prm
if(Instance == null) if(Instance == null)
Instance = this; Instance = this;
m_inVr = Utils.IsInVR();
m_physicsMaterial = new PhysicMaterial("Ragdoll"); m_physicsMaterial = new PhysicMaterial("Ragdoll");
m_physicsMaterial.dynamicFriction = c_defaultFriction; m_physicsMaterial.dynamicFriction = c_defaultFriction;
m_physicsMaterial.staticFriction = c_defaultFriction; m_physicsMaterial.staticFriction = c_defaultFriction;
@ -241,8 +237,6 @@ namespace ml_prm
internal void OnAvatarSetup() internal void OnAvatarSetup()
{ {
m_inVr = Utils.IsInVR();
if(PlayerSetup.Instance._animator.isHuman) if(PlayerSetup.Instance._animator.isHuman)
{ {
BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator); BipedRagdollReferences l_avatarReferences = BipedRagdollReferences.FromAvatar(PlayerSetup.Instance._animator);

View file

@ -1,108 +1,108 @@
using ABI.CCK.Components; using ABI.CCK.Components;
using ABI_RC.Core.Player; using ABI_RC.Core.Player;
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using UnityEngine; using UnityEngine;
namespace ml_prm namespace ml_prm
{ {
[DisallowMultipleComponent] [DisallowMultipleComponent]
class RagdollTrigger : MonoBehaviour class RagdollTrigger : MonoBehaviour
{ {
const string c_ragdollPointerType = "ragdoll"; const string c_ragdollPointerType = "ragdoll";
Collider m_collider = null; Collider m_collider = null;
Collider m_lastColliderTrigger = null; Collider m_lastColliderTrigger = null;
ParticleSystem m_lastParticleSystemTrigger = null; ParticleSystem m_lastParticleSystemTrigger = null;
bool m_triggered = false; bool m_triggered = false;
void Start() void Start()
{ {
m_collider = this.GetComponent<Collider>(); m_collider = this.GetComponent<Collider>();
CVRParticlePointerManager.volumes.Add(new RagdollTriggerVolume(m_collider, this)); CVRParticlePointerManager.volumes.Add(new RagdollTriggerVolume(m_collider, this));
CVRParticlePointerManager.UpdateParticleSystems(); CVRParticlePointerManager.UpdateParticleSystems();
} }
void OnDestroy() void OnDestroy()
{ {
if(m_collider != null) if(m_collider != null)
CVRParticlePointerManager.RemoveTrigger(m_collider); CVRParticlePointerManager.RemoveTrigger(m_collider);
m_collider = null; m_collider = null;
m_lastColliderTrigger = null; m_lastColliderTrigger = null;
m_lastParticleSystemTrigger = null; m_lastParticleSystemTrigger = null;
} }
void Update() void Update()
{ {
if(!ReferenceEquals(m_lastColliderTrigger, null)) if(!ReferenceEquals(m_lastColliderTrigger, null))
{ {
if(m_lastColliderTrigger != null) if(m_lastColliderTrigger != null)
{ {
if(!m_collider.bounds.Intersects(m_lastColliderTrigger.bounds)) if(!m_collider.bounds.Intersects(m_lastColliderTrigger.bounds))
m_lastColliderTrigger = null; m_lastColliderTrigger = null;
} }
else else
m_lastColliderTrigger = null; m_lastColliderTrigger = null;
} }
if(!ReferenceEquals(m_lastParticleSystemTrigger, null)) if(!ReferenceEquals(m_lastParticleSystemTrigger, null))
{ {
if(m_lastParticleSystemTrigger != null) if(m_lastParticleSystemTrigger != null)
{ {
if(m_lastParticleSystemTrigger.particleCount == 0) if(m_lastParticleSystemTrigger.particleCount == 0)
m_lastParticleSystemTrigger = null; m_lastParticleSystemTrigger = null;
} }
else else
m_lastParticleSystemTrigger = null; m_lastParticleSystemTrigger = null;
} }
} }
void OnTriggerEnter(Collider p_other) void OnTriggerEnter(Collider p_other)
{ {
CVRPointer l_pointer = p_other.GetComponent<CVRPointer>(); CVRPointer l_pointer = p_other.GetComponent<CVRPointer>();
if((l_pointer != null) && (l_pointer.type == c_ragdollPointerType) && !IsIgnored(l_pointer.transform) && (m_lastColliderTrigger != p_other)) if((l_pointer != null) && (l_pointer.type == c_ragdollPointerType) && !IsIgnored(l_pointer.transform) && (m_lastColliderTrigger != p_other))
{ {
m_lastColliderTrigger = p_other; m_lastColliderTrigger = p_other;
m_triggered = true; m_triggered = true;
} }
} }
void OnTriggerExit(Collider p_other) void OnTriggerExit(Collider p_other)
{ {
if(m_lastColliderTrigger == p_other) if(m_lastColliderTrigger == p_other)
m_lastColliderTrigger = null; m_lastColliderTrigger = null;
} }
public void OnPointerParticleEnter(CVRPointer p_pointer) public void OnPointerParticleEnter(CVRPointer p_pointer)
{ {
if(!this.gameObject.activeInHierarchy) if(!this.gameObject.activeInHierarchy)
return; return;
if((p_pointer.type == c_ragdollPointerType) && !IsIgnored(p_pointer.transform) && (m_lastParticleSystemTrigger != p_pointer.particleSystem)) if((p_pointer.type == c_ragdollPointerType) && !IsIgnored(p_pointer.transform) && (m_lastParticleSystemTrigger != p_pointer.particleSystem))
{ {
m_lastParticleSystemTrigger = p_pointer.particleSystem; m_lastParticleSystemTrigger = p_pointer.particleSystem;
m_triggered = true; m_triggered = true;
} }
} }
public void OnPointerParticleExit(CVRPointer p_pointer) public void OnPointerParticleExit(CVRPointer p_pointer)
{ {
// This seems to be very unreliable, and it's causing weird behavior // This seems to be very unreliable, and it's causing weird behavior
// if (!gameObject.activeInHierarchy) return; // if (!gameObject.activeInHierarchy) return;
// if(m_lastParticleSystemTrigger == p_pointer.particleSystem) // if(m_lastParticleSystemTrigger == p_pointer.particleSystem)
// m_lastParticleSystemTrigger = null; // m_lastParticleSystemTrigger = null;
} }
public bool GetStateWithReset() public bool GetStateWithReset()
{ {
bool l_state = m_triggered; bool l_state = m_triggered;
m_triggered = false; m_triggered = false;
return l_state; return l_state;
} }
static bool IsIgnored(Transform p_transform) static bool IsIgnored(Transform p_transform)
{ {
return (Settings.IgnoreLocal && (p_transform.root == PlayerSetup.Instance.transform)); return (Settings.IgnoreLocal && (p_transform.root == PlayerSetup.Instance.transform));
} }
} }
} }

View file

@ -1,22 +1,22 @@
using ABI_RC.Core.Savior; using ABI_RC.Core.Savior;
using ABI.CCK.Components; using ABI.CCK.Components;
using UnityEngine; using UnityEngine;
namespace ml_prm namespace ml_prm
{ {
class RagdollTriggerVolume : CVRTriggerVolume class RagdollTriggerVolume : CVRTriggerVolume
{ {
readonly RagdollTrigger m_trigger = null; readonly RagdollTrigger m_trigger = null;
public Collider collider { get; set; } public Collider collider { get; set; }
internal RagdollTriggerVolume(Collider p_collider, RagdollTrigger p_trigger) internal RagdollTriggerVolume(Collider p_collider, RagdollTrigger p_trigger)
{ {
collider = p_collider; collider = p_collider;
m_trigger = p_trigger; m_trigger = p_trigger;
} }
public void TriggerEnter(CVRPointer pointer) => m_trigger.OnPointerParticleEnter(pointer); public void TriggerEnter(CVRPointer pointer) => m_trigger.OnPointerParticleEnter(pointer);
public void TriggerExit(CVRPointer pointer) => m_trigger.OnPointerParticleExit(pointer); public void TriggerExit(CVRPointer pointer) => m_trigger.OnPointerParticleExit(pointer);
} }
} }

View file

@ -88,7 +88,8 @@ namespace ml_vei
{ {
GripTrigger = bool.Parse(p_value); GripTrigger = bool.Parse(p_value);
GripTriggerChange?.Invoke(GripTrigger); GripTriggerChange?.Invoke(GripTrigger);
} break; }
break;
} }
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value); ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);