NPC refactor (#10122)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -154,6 +154,14 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
component.AvailableModes = state.AvailableSelectiveFire;
|
||||
}
|
||||
|
||||
public bool CanShoot(GunComponent component)
|
||||
{
|
||||
if (component.NextFire > Timing.CurTime)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public GunComponent? GetGun(EntityUid entity)
|
||||
{
|
||||
if (!_combatMode.IsInCombatMode(entity))
|
||||
@@ -180,6 +188,16 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
Dirty(gun);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to shoot at the target coordinates. Resets the shot counter after every shot.
|
||||
/// </summary>
|
||||
public void AttemptShoot(EntityUid user, GunComponent gun, EntityCoordinates toCoordinates)
|
||||
{
|
||||
gun.ShootCoordinates = toCoordinates;
|
||||
AttemptShoot(user, gun);
|
||||
gun.ShotCounter = 0;
|
||||
}
|
||||
|
||||
private void AttemptShoot(EntityUid user, GunComponent gun)
|
||||
{
|
||||
if (gun.FireRate <= 0f) return;
|
||||
@@ -349,8 +367,7 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
if (sprite == null)
|
||||
return;
|
||||
|
||||
var ev = new MuzzleFlashEvent(gun, sprite);
|
||||
|
||||
var ev = new MuzzleFlashEvent(gun, sprite, user == gun);
|
||||
CreateEffect(gun, ev, user);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user