mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Propper game events
Ragdoll body parts grab
This commit is contained in:
parent
8bead6a764
commit
84c255660e
12 changed files with 279 additions and 20 deletions
50
ml_prm/RemoteGestureHandler.cs
Normal file
50
ml_prm/RemoteGestureHandler.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using ABI_RC.Core.Networking.IO.Social;
|
||||
using ABI_RC.Core.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ml_prm
|
||||
{
|
||||
class RemoteGestureHandler : MonoBehaviour
|
||||
{
|
||||
internal class GestureEvent<T1, T2, T3>
|
||||
{
|
||||
event Action<T1, T2, T3> m_action;
|
||||
public void AddHandler(Action<T1, T2, T3> p_listener) => m_action += p_listener;
|
||||
public void RemoveHandler(Action<T1, T2, T3> p_listener) => m_action -= p_listener;
|
||||
public void Invoke(T1 p_objA, T2 p_objB, T3 p_objC) => m_action?.Invoke(p_objA, p_objB, p_objC);
|
||||
}
|
||||
|
||||
public static readonly GestureEvent<PuppetMaster, bool, bool> OnGestureState = new GestureEvent<PuppetMaster, bool, bool>();
|
||||
|
||||
PuppetMaster m_puppetMaster = null;
|
||||
bool m_stateLeft = false;
|
||||
bool m_stateRight = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_puppetMaster = this.GetComponent<PuppetMaster>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
bool l_state = Mathf.Approximately(m_puppetMaster.PlayerAvatarMovementDataInput.AnimatorGestureLeft, 1f);
|
||||
if(m_stateLeft != l_state)
|
||||
{
|
||||
m_stateLeft = l_state;
|
||||
if(!Settings.FriendsGrab || Friends.FriendsWith(m_puppetMaster.CVRPlayerEntity.PlayerDescriptor.ownerId))
|
||||
OnGestureState.Invoke(m_puppetMaster, true, m_stateLeft);
|
||||
}
|
||||
|
||||
l_state = Mathf.Approximately(m_puppetMaster.PlayerAvatarMovementDataInput.AnimatorGestureRight, 1f);
|
||||
if(m_stateRight != l_state)
|
||||
{
|
||||
m_stateRight = l_state;
|
||||
if(!Settings.FriendsGrab || Friends.FriendsWith(m_puppetMaster.CVRPlayerEntity.PlayerDescriptor.ownerId))
|
||||
OnGestureState.Invoke(m_puppetMaster, false, m_stateRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue