Gun auto state handlers (#15186)
* battery auto state * basic entity autostate * ballistic autostate * flyby * cartridge ammo * gun * Revert "battery auto state" This reverts commit 35b7d62f303fddb0edd9eb7a922e3c26b7a5f7fb. * silly
This commit is contained in:
@@ -67,10 +67,8 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
{
|
||||
Sawmill = Logger.GetSawmill("gun");
|
||||
Sawmill.Level = LogLevel.Info;
|
||||
SubscribeLocalEvent<GunComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeAllEvent<RequestShootEvent>(OnShootRequest);
|
||||
SubscribeAllEvent<RequestStopShootEvent>(OnStopShootRequest);
|
||||
SubscribeLocalEvent<GunComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<GunComponent, MeleeAttackAttemptEvent>(OnGunMeleeAttempt);
|
||||
|
||||
// Ammo providers
|
||||
@@ -144,37 +142,6 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
StopShooting(ev.Gun, gun);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, GunComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new GunComponentState
|
||||
{
|
||||
FireRate = component.FireRate,
|
||||
CurrentAngle = component.CurrentAngle,
|
||||
MinAngle = component.MinAngle,
|
||||
MaxAngle = component.MaxAngle,
|
||||
NextFire = component.NextFire,
|
||||
ShotCounter = component.ShotCounter,
|
||||
SelectiveFire = component.SelectedMode,
|
||||
AvailableSelectiveFire = component.AvailableModes,
|
||||
};
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, GunComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not GunComponentState state)
|
||||
return;
|
||||
|
||||
Sawmill.Debug($"Handle state: setting shot count from {component.ShotCounter} to {state.ShotCounter}");
|
||||
component.FireRate = state.FireRate;
|
||||
component.CurrentAngle = state.CurrentAngle;
|
||||
component.MinAngle = state.MinAngle;
|
||||
component.MaxAngle = state.MaxAngle;
|
||||
component.NextFire = state.NextFire;
|
||||
component.ShotCounter = state.ShotCounter;
|
||||
component.SelectedMode = state.SelectiveFire;
|
||||
component.AvailableModes = state.AvailableSelectiveFire;
|
||||
}
|
||||
|
||||
public bool CanShoot(GunComponent component)
|
||||
{
|
||||
if (component.NextFire > Timing.CurTime)
|
||||
@@ -418,19 +385,6 @@ public abstract partial class SharedGunSystem : EntitySystem
|
||||
}
|
||||
protected abstract void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null);
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class GunComponentState : ComponentState
|
||||
{
|
||||
public Angle CurrentAngle;
|
||||
public Angle MinAngle;
|
||||
public Angle MaxAngle;
|
||||
public TimeSpan NextFire;
|
||||
public float FireRate;
|
||||
public int ShotCounter;
|
||||
public SelectiveFire SelectiveFire;
|
||||
public SelectiveFire AvailableSelectiveFire;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for animated effects on the client.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user