Cycle injector transfer amount on alt. use (#25566)

* Add toggle verb for injector transfer amount

* Fix injector verb priority scalability

---------

Co-authored-by: veprolet <>
This commit is contained in:
veprolet
2024-03-13 11:00:45 +01:00
committed by GitHub
parent a773182e3e
commit ad6ac73f6f
3 changed files with 26 additions and 3 deletions

View File

@@ -39,12 +39,34 @@ public abstract class SharedInjectorSystem : EntitySystem
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)