mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-14 16:27:19 +00:00
extract function
This commit is contained in:
parent
4aaa96219b
commit
1fb28ff19a
1 changed files with 16 additions and 4 deletions
|
@ -492,16 +492,28 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
}
|
||||
|
||||
|
||||
public static void GetEffectiveFirePosAndDir(Ped ped, WeaponAttackParams weaponAttackParams, out Vector3 pos, out Vector3 dir)
|
||||
{
|
||||
if (ped.IsControlledByLocalPlayer || null == ped.PlayerOwner)
|
||||
{
|
||||
pos = ped.FirePosition;
|
||||
dir = ped.FireDirection;
|
||||
}
|
||||
else // this ped is owned by remote client
|
||||
{
|
||||
pos = ped.NetFirePos;
|
||||
dir = ped.NetFireDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryFire (Ped ped, WeaponAttackParams weaponAttackParams)
|
||||
{
|
||||
if (ped.CurrentWeapon != null)
|
||||
{
|
||||
if (Net.NetStatus.IsServer)
|
||||
{
|
||||
if (ped.IsControlledByLocalPlayer || null == ped.PlayerOwner)
|
||||
return TryFire(ped, ped.FirePosition, ped.FireDirection, weaponAttackParams);
|
||||
else // this ped is owned by remote client
|
||||
return TryFire(ped, ped.NetFirePos, ped.NetFireDir, weaponAttackParams);
|
||||
GetEffectiveFirePosAndDir(ped, weaponAttackParams, out Vector3 pos, out Vector3 dir);
|
||||
return TryFire(ped, pos, dir, weaponAttackParams);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue