From 0c4e8f6b86ab09090e3cd8b6619d916d8278bcac Mon Sep 17 00:00:00 2001
From: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Date: Thu, 13 Feb 2025 22:27:33 +0300
Subject: [PATCH] Fix thrusters not dealing damage (#35088)
* Fix thrusters not dealing damage
* Fixes
* Update
* Update
* Update
---
.../Shuttles/Components/ThrusterComponent.cs | 12 +++++++++---
Content.Server/Shuttles/Systems/ThrusterSystem.cs | 9 +++++++--
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/Content.Server/Shuttles/Components/ThrusterComponent.cs b/Content.Server/Shuttles/Components/ThrusterComponent.cs
index 3bba9b5a7f..20f020743d 100644
--- a/Content.Server/Shuttles/Components/ThrusterComponent.cs
+++ b/Content.Server/Shuttles/Components/ThrusterComponent.cs
@@ -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;
+ ///
+ /// How often thruster deals damage.
+ ///
+ [DataField]
+ public TimeSpan FireCooldown = TimeSpan.FromSeconds(2);
+
///
/// Next time we tick damage for anyone colliding.
///
- [ViewVariables(VVAccess.ReadWrite), DataField("nextFire", customTypeSerializer:typeof(TimeOffsetSerializer))]
- public TimeSpan NextFire;
+ [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+ public TimeSpan NextFire = TimeSpan.Zero;
}
public enum ThrusterType
diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs
index f5e8f7823e..a75ddc911a 100644
--- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs
+++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs
@@ -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())
{
--
2.51.2