Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Un-hardcode the warp drive charging duration #299

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading