mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 04:23:04 +00:00
send fire position to server
This commit is contained in:
parent
3ff374aefa
commit
0127b0d392
4 changed files with 9 additions and 5 deletions
|
@ -91,6 +91,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public Weapon CurrentWeapon { get { return m_weaponHolder.CurrentWeapon; } }
|
||||
public bool IsFiring { get { return m_weaponHolder.IsFiring; } }
|
||||
public Vector3 AimDirection { get { return m_weaponHolder.AimDirection; } set => m_weaponHolder.AimDirection = value; }
|
||||
public Vector3 FirePosition => this.CurrentWeapon != null ? this.CurrentWeapon.GetFirePos() : this.transform.position;
|
||||
public Vector3 FireDirection => this.CurrentWeapon != null ? this.CurrentWeapon.GetFireDir() : this.AimDirection;
|
||||
public bool IsAimOn { get ; set ; }
|
||||
public bool IsFireOn { get ; set ; }
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
[SyncVar(hook=nameof(Net_OnWeaponChanged))] int m_net_currentWeaponSlot;
|
||||
|
||||
[SyncVar] internal Vector3 m_net_aimDir;
|
||||
|
||||
public Vector3 NetFirePos { get; set; }
|
||||
public Vector3 NetFireDir { get; set; }
|
||||
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
if (m_ped.IsControlledByLocalPlayer || null == m_ped.PlayerOwner)
|
||||
return this.TryFire(m_weapon.GetFirePos(), m_weapon.GetFireDir());
|
||||
else // this ped is owned by remote client
|
||||
return this.TryFire(m_weapon.GetFirePos(), m_ped.NetFireDir);
|
||||
return this.TryFire(m_ped.NetFirePos, m_ped.NetFireDir);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -33,21 +33,21 @@ namespace SanAndreasUnity.Net
|
|||
}
|
||||
|
||||
public void SendInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 firePos, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
{
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading, aimDir, fireDir, isAimOn, isFireOn);
|
||||
this.CmdSendingInput(isWalkOn, isRunOn, isSprintOn, movementInput, isJumpOn, heading, aimDir, firePos, fireDir, isAimOn, isFireOn);
|
||||
}
|
||||
|
||||
public void SendInput()
|
||||
{
|
||||
Ped ped = m_ped;
|
||||
this.SendInput(ped.IsWalkOn, ped.IsRunOn, ped.IsSprintOn, ped.Movement, ped.IsJumpOn, ped.Heading,
|
||||
ped.AimDirection, ped.FireDirection, ped.IsAimOn, ped.IsFireOn);
|
||||
ped.AimDirection, ped.FirePosition, ped.FireDirection, ped.IsAimOn, ped.IsFireOn);
|
||||
}
|
||||
|
||||
[Command]
|
||||
void CmdSendingInput(bool isWalkOn, bool isRunOn, bool isSprintOn, Vector3 movementInput,
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
bool isJumpOn, Vector3 heading, Vector3 aimDir, Vector3 firePos, Vector3 fireDir, bool isAimOn, bool isFireOn)
|
||||
{
|
||||
if (null == m_ped)
|
||||
return;
|
||||
|
@ -61,6 +61,7 @@ namespace SanAndreasUnity.Net
|
|||
ped.IsJumpOn = isJumpOn;
|
||||
ped.Heading = heading;
|
||||
ped.AimDirection = aimDir;
|
||||
ped.NetFirePos = firePos;
|
||||
ped.NetFireDir = fireDir;
|
||||
ped.IsAimOn = isAimOn;
|
||||
ped.IsFireOn = isFireOn;
|
||||
|
|
Loading…
Reference in a new issue