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

Mirror: Cycle injector transfer amount on alt. use #178

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
3 changes: 1 addition & 2 deletions Content.Shared/Chemistry/Components/InjectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public sealed partial class InjectorComponent : Component
/// The maximum amount of solution that can be transferred at once from this solution.
/// </summary>
[DataField("maxTransferAmount")]
[ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(50);
public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(15);

/// <summary>
/// Amount to inject or draw on each usage. If the injector is inject only, it will
Expand Down
26 changes: 24 additions & 2 deletions Content.Shared/Chemistry/EntitySystems/SharedInjectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,34 @@ private void AddSetTransferVerbs(Entity<InjectorComponent> entity, ref GetVerbsE

if (!HasComp<ActorComponent>(args.User))
return;
var user = args.User;

var (_, component) = entity;

// Add specific transfer verbs according to the container's size
var min = component.MinimumTransferAmount;
var max = component.MaximumTransferAmount;
var cur = component.TransferAmount;
var toggleAmount = cur == max ? min : max;

var priority = 0;
var user = args.User;
AlternativeVerb toggleVerb = new()
{
Text = Loc.GetString("comp-solution-transfer-verb-toggle", ("amount", toggleAmount)),
Category = VerbCategory.SetTransferAmount,
Act = () =>
{
component.TransferAmount = toggleAmount;
Popup.PopupClient(Loc.GetString("comp-solution-transfer-set-amount", ("amount", toggleAmount)), user, user);
Dirty(entity);
},

Priority = priority
};
args.Verbs.Add(toggleVerb);

priority -= 1;

// Add specific transfer verbs according to the container's size
foreach (var amount in TransferAmounts)
{
if (amount < component.MinimumTransferAmount || amount > component.MaximumTransferAmount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ comp-solution-transfer-is-full = {THE($target)} is full!
## Displayed in change transfer amount verb's name
comp-solution-transfer-verb-custom-amount = Custom
comp-solution-transfer-verb-amount = {$amount}u
comp-solution-transfer-verb-toggle = Toggle to {$amount}u
## Displayed after you successfully change a solution's amount using the BUI
comp-solution-transfer-set-amount = Transfer amount set to {$amount}u.
Loading