Departmental Economy (#36445)
* Cargo Accounts, Request Consoles, and lock boxes * Funding Allocation Computer * final changes * test fix * remove dumb code * ScarKy0 review * first cour * second cour * Update machines.yml * review --------- Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -40,9 +41,8 @@ public sealed partial class CargoSystem
|
||||
continue;
|
||||
|
||||
// todo cannot be fucking asked to figure out device linking rn but this shouldn't just default to the first port.
|
||||
if (!TryComp<DeviceLinkSinkComponent>(uid, out var sinkComponent) ||
|
||||
sinkComponent.LinkedSources.FirstOrNull() is not { } console ||
|
||||
console != args.OrderConsole.Owner)
|
||||
if (!TryGetLinkedConsole((uid, tele), out var console) ||
|
||||
console.Value.Owner != args.OrderConsole.Owner)
|
||||
continue;
|
||||
|
||||
for (var i = 0; i < args.Order.OrderQuantity; i++)
|
||||
@@ -56,10 +56,26 @@ public sealed partial class CargoSystem
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetLinkedConsole(Entity<CargoTelepadComponent> ent,
|
||||
[NotNullWhen(true)] out Entity<CargoOrderConsoleComponent>? console)
|
||||
{
|
||||
console = null;
|
||||
if (!TryComp<DeviceLinkSinkComponent>(ent, out var sinkComponent) ||
|
||||
sinkComponent.LinkedSources.FirstOrNull() is not { } linked)
|
||||
return false;
|
||||
|
||||
if (!TryComp<CargoOrderConsoleComponent>(linked, out var consoleComp))
|
||||
return false;
|
||||
|
||||
console = (linked, consoleComp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void UpdateTelepad(float frameTime)
|
||||
{
|
||||
var query = EntityQueryEnumerator<CargoTelepadComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
var query = EntityQueryEnumerator<CargoTelepadComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp, out var xform))
|
||||
{
|
||||
// Don't EntityQuery for it as it's not required.
|
||||
TryComp<AppearanceComponent>(uid, out var appearance);
|
||||
@@ -82,15 +98,14 @@ public sealed partial class CargoSystem
|
||||
continue;
|
||||
}
|
||||
|
||||
if (comp.CurrentOrders.Count == 0)
|
||||
if (comp.CurrentOrders.Count == 0 || !TryGetLinkedConsole((uid, comp), out var console))
|
||||
{
|
||||
comp.Accumulator += comp.Delay;
|
||||
continue;
|
||||
}
|
||||
|
||||
var xform = Transform(uid);
|
||||
var currentOrder = comp.CurrentOrders.First();
|
||||
if (FulfillOrder(currentOrder, xform.Coordinates, comp.PrinterOutput))
|
||||
if (FulfillOrder(currentOrder, console.Value.Comp.Account, xform.Coordinates, comp.PrinterOutput))
|
||||
{
|
||||
_audio.PlayPvs(_audio.ResolveSound(comp.TeleportSound), uid, AudioParams.Default.WithVolume(-8f));
|
||||
|
||||
@@ -128,9 +143,12 @@ public sealed partial class CargoSystem
|
||||
!TryComp<StationDataComponent>(station, out var data))
|
||||
return;
|
||||
|
||||
if (!TryGetLinkedConsole(ent, out var console))
|
||||
return;
|
||||
|
||||
foreach (var order in ent.Comp.CurrentOrders)
|
||||
{
|
||||
TryFulfillOrder((station, data), order, db);
|
||||
TryFulfillOrder((station, data), console.Value.Comp.Account, order, db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user