Fix thrusters not dealing damage (#35088)
* Fix thrusters not dealing damage * Fixes * Update * Update * Update
This commit is contained in:
@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
|
||||
[Access(typeof(ThrusterSystem))]
|
||||
public sealed partial class ThrusterComponent : Component
|
||||
{
|
||||
@@ -50,11 +50,17 @@ namespace Content.Server.Shuttles.Components
|
||||
|
||||
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
|
||||
|
||||
@@ -232,6 +232,8 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
|
||||
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
|
||||
{
|
||||
component.NextFire = _timing.CurTime + component.FireCooldown;
|
||||
|
||||
_ambient.SetAmbience(uid, false);
|
||||
|
||||
if (!component.Enabled)
|
||||
@@ -461,10 +463,13 @@ public sealed class ThrusterSystem : EntitySystem
|
||||
|
||||
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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user