NPC refactor (#10122)

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-09-06 00:28:23 +10:00
committed by GitHub
parent 138e328c04
commit 0286b88388
290 changed files with 13842 additions and 5939 deletions

View File

@@ -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);
}