From 3b246240cbb37bd12ecdc0a2918d0e5911cdf6d0 Mon Sep 17 00:00:00 2001
From: Alzore <140123969+Blackern5000@users.noreply.github.com>
Date: Thu, 18 Apr 2024 05:52:52 -0500
Subject: [PATCH] Un-hardcode the warp drive charging duration (#299)
* Yay no more hardcoded warp drive speed
* warp drive debug
---
.../_FTL/FTLPoints/Components/WarpDriveComponent.cs | 7 +++++--
.../FTLPoints/Systems/FtlPointsSystem.WarpDrive.cs | 10 +++++-----
.../_FTL/Entities/Structures/Machines/warp-drive.yml | 11 ++++++++++-
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/Content.Server/_FTL/FTLPoints/Components/WarpDriveComponent.cs b/Content.Server/_FTL/FTLPoints/Components/WarpDriveComponent.cs
index da422c9142..c5b7f8f948 100644
--- a/Content.Server/_FTL/FTLPoints/Components/WarpDriveComponent.cs
+++ b/Content.Server/_FTL/FTLPoints/Components/WarpDriveComponent.cs
@@ -19,11 +19,14 @@ public sealed partial class WarpDriveComponent : Component
public int FuelPerJump = 30;
///
- /// Ships at max charge (1f) will instantly begin jumping
+ /// Ships will begin warping when Charge reaches ChargeNeeded
///
- [DataField, ViewVariables]
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
public float Charge;
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public int ChargeNeeded = 30;
+
///
/// Is this drive charging?
///
diff --git a/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.WarpDrive.cs b/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.WarpDrive.cs
index 255a2320e5..b20221b71b 100644
--- a/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.WarpDrive.cs
+++ b/Content.Server/_FTL/FTLPoints/Systems/FtlPointsSystem.WarpDrive.cs
@@ -59,10 +59,10 @@ private void DriveUpdate(float frameTime)
if (!TryComp(grid, out var shuttleComponent))
return;
- if (component is { Charging: true, Charge: < 1 })
- component.Charge += frameTime / 30;
+ if (component.Charging && component.Charge < component.ChargeNeeded)
+ component.Charge += frameTime;
- if (!(component.Charge >= 1))
+ if (component.Charge < component.ChargeNeeded)
continue;
if (!warpingShipComponent.TargetMap.HasValue)
@@ -90,13 +90,13 @@ private void OnDriveExamineEvent(EntityUid uid, WarpDriveComponent component, Ex
return;
}
- if (component.Charge >= 1)
+ if (component.Charge >= component.ChargeNeeded)
{
args.PushMarkup(Loc.GetString("drive-examined-ready"));
return;
}
args.PushMarkup(Loc.GetString("drive-examined", ("charging", component.Charging), ("charge",
- $"{(component.Charge * 100):F}"), ("destination", warpingShipComponent.TargetMap != null)));
+ $"{(component.Charge / component.ChargeNeeded * 100):F}"), ("destination", warpingShipComponent.TargetMap != null)));
}
}
diff --git a/Resources/Prototypes/_FTL/Entities/Structures/Machines/warp-drive.yml b/Resources/Prototypes/_FTL/Entities/Structures/Machines/warp-drive.yml
index d9e7dc47bd..f76b0c4ff3 100644
--- a/Resources/Prototypes/_FTL/Entities/Structures/Machines/warp-drive.yml
+++ b/Resources/Prototypes/_FTL/Entities/Structures/Machines/warp-drive.yml
@@ -27,4 +27,13 @@
density: 100
- type: PointLight
radius: 2.5
- energy: 0.5
\ No newline at end of file
+ energy: 0.5
+
+- type: entity
+ id: WarpDriveDebug
+ name: super warp drive
+ description: It go fast!!
+ suffix: DEBUG
+ components:
+ - type: WarpDrive
+ ChargeNeeded: 0.1