Send crouch button event

This commit is contained in:
in0finite 2019-04-28 19:13:01 +02:00
parent 9f64097b5e
commit 669daa23be
6 changed files with 21 additions and 3 deletions

View file

@ -99,6 +99,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
{
if (m_isServer)
m_ped.SwitchState<CrouchState>();
else
base.OnCrouchButtonPressed();
}
public override void OnFlyButtonPressed ()

View file

@ -1,5 +1,6 @@
using UnityEngine;
using SanAndreasUnity.Utilities;
using SanAndreasUnity.Net;
namespace SanAndreasUnity.Behaviours.Peds.States
{
@ -16,6 +17,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
protected new Transform transform { get { return m_ped.transform; } }
public bool IsActiveState { get { return m_ped.CurrentState == this; } }
protected bool m_isServer { get { return Net.NetStatus.IsServer; } }
protected bool m_shouldSendButtonEvents { get { return !m_isServer && m_ped.IsControlledByLocalPlayer; } }
@ -229,7 +231,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public virtual void OnCrouchButtonPressed()
{
if (m_shouldSendButtonEvents)
PedSync.Local.OnCrouchButtonPressed();
}
public virtual void OnNextWeaponButtonPressed()

View file

@ -36,6 +36,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
{
if (m_isServer)
m_ped.SwitchState<StandState>();
else
base.OnCrouchButtonPressed();
}
}

View file

@ -52,6 +52,8 @@ namespace SanAndreasUnity.Behaviours.Peds.States
if (m_isServer)
m_ped.SwitchState<StandState>();
else
base.OnCrouchButtonPressed();
}
}

View file

@ -58,5 +58,14 @@ namespace SanAndreasUnity.Net
}
public void OnCrouchButtonPressed() => this.CmdOnCrouchButtonPressed();
[Command]
void CmdOnCrouchButtonPressed()
{
if (m_ped)
m_ped.OnCrouchButtonPressed();
}
}
}

View file

@ -6,9 +6,9 @@
- order of buttons in main menu
- send input to server
- adapt states:
- adapt states: jump, crouch, roll,
- send button input events to server: crouch,
- stats window