namespace Content.Server.Shuttles.Components
{
- [RegisterComponent, NetworkedComponent]
+ [RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
[Access(typeof(ThrusterSystem))]
public sealed partial class ThrusterComponent : Component
{
public bool Firing = false;
+ /// <summary>
+ /// How often thruster deals damage.
+ /// </summary>
+ [DataField]
+ public TimeSpan FireCooldown = TimeSpan.FromSeconds(2);
+
/// <summary>
/// Next time we tick damage for anyone colliding.
/// </summary>
- [ViewVariables(VVAccess.ReadWrite), DataField("nextFire", customTypeSerializer:typeof(TimeOffsetSerializer))]
- public TimeSpan NextFire;
+ [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+ public TimeSpan NextFire = TimeSpan.Zero;
}
public enum ThrusterType
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
{
+ component.NextFire = _timing.CurTime + component.FireCooldown;
+
_ambient.SetAmbience(uid, false);
if (!component.Enabled)
while (query.MoveNext(out var comp))
{
- if (!comp.Firing || comp.Colliding.Count == 0 || comp.Damage == null || comp.NextFire < curTime)
+ if (comp.NextFire > curTime)
continue;
- comp.NextFire += TimeSpan.FromSeconds(1);
+ comp.NextFire += comp.FireCooldown;
+
+ if (!comp.Firing || comp.Colliding.Count == 0 || comp.Damage == null)
+ continue;
foreach (var uid in comp.Colliding.ToArray())
{