Skip to content

Commit

Permalink
Un-hardcode the warp drive charging duration (#299)
Browse files Browse the repository at this point in the history
* Yay no more hardcoded warp drive speed

* warp drive debug
  • Loading branch information
Blackern5000 authored Apr 18, 2024
1 parent 0f4ff48 commit 3b24624
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ public sealed partial class WarpDriveComponent : Component
public int FuelPerJump = 30;

/// <summary>
/// Ships at max charge (1f) will instantly begin jumping
/// Ships will begin warping when Charge reaches ChargeNeeded
/// </summary>
[DataField, ViewVariables]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Charge;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public int ChargeNeeded = 30;

/// <summary>
/// Is this drive charging?
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ private void DriveUpdate(float frameTime)
if (!TryComp<ShuttleComponent>(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)
Expand Down Expand Up @@ -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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@
density: 100
- type: PointLight
radius: 2.5
energy: 0.5
energy: 0.5

- type: entity
id: WarpDriveDebug
name: super warp drive
description: It go fast!!
suffix: DEBUG
components:
- type: WarpDrive
ChargeNeeded: 0.1

0 comments on commit 3b24624

Please sign in to comment.