Cargo 1984 (#15579)

This commit is contained in:
metalgearsloth
2023-04-29 14:59:24 +10:00
committed by GitHub
parent dfc5bcdc12
commit 4975eef5bd
7 changed files with 32 additions and 26 deletions

View File

@@ -1,4 +1,5 @@
using System.Globalization; using System.Globalization;
using System.Linq;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Cargo.Systems; using Content.Server.Cargo.Systems;
using Content.Server.EUI; using Content.Server.EUI;
@@ -16,6 +17,11 @@ namespace Content.Server.UserInterface;
[AdminCommand(AdminFlags.Debug)] [AdminCommand(AdminFlags.Debug)]
public sealed class StatValuesCommand : IConsoleCommand public sealed class StatValuesCommand : IConsoleCommand
{ {
[Dependency] private readonly EuiManager _eui = default!;
[Dependency] private readonly IComponentFactory _factory = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
public string Command => "showvalues"; public string Command => "showvalues";
public string Description => Loc.GetString("stat-values-desc"); public string Description => Loc.GetString("stat-values-desc");
public string Help => $"{Command} <cargosell / lathsell / melee>"; public string Help => $"{Command} <cargosell / lathsell / melee>";
@@ -51,24 +57,33 @@ public sealed class StatValuesCommand : IConsoleCommand
return; return;
} }
var euiManager = IoCManager.Resolve<EuiManager>();
var eui = new StatValuesEui(); var eui = new StatValuesEui();
euiManager.OpenEui(eui, pSession); _eui.OpenEui(eui, pSession);
eui.SendMessage(message); eui.SendMessage(message);
} }
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromOptions(new[] { "cargosell", "lathesell", "melee" });
}
return CompletionResult.Empty;
}
private StatValuesEuiMessage GetCargo() private StatValuesEuiMessage GetCargo()
{ {
// Okay so there's no easy way to do this with how pricing works // Okay so there's no easy way to do this with how pricing works
// So we'll just get the first value for each prototype ID which is probably good enough for the majority. // So we'll just get the first value for each prototype ID which is probably good enough for the majority.
var values = new List<string[]>(); var values = new List<string[]>();
var entManager = IoCManager.Resolve<IEntityManager>(); var priceSystem = _entManager.System<PricingSystem>();
var priceSystem = entManager.System<PricingSystem>(); var metaQuery = _entManager.GetEntityQuery<MetaDataComponent>();
var metaQuery = entManager.GetEntityQuery<MetaDataComponent>();
var prices = new HashSet<string>(256); var prices = new HashSet<string>(256);
var ents = _entManager.GetEntities().ToArray();
foreach (var entity in entManager.GetEntities()) foreach (var entity in ents)
{ {
if (!metaQuery.TryGetComponent(entity, out var meta)) if (!metaQuery.TryGetComponent(entity, out var meta))
continue; continue;
@@ -107,15 +122,13 @@ public sealed class StatValuesCommand : IConsoleCommand
private StatValuesEuiMessage GetMelee() private StatValuesEuiMessage GetMelee()
{ {
var compFactory = IoCManager.Resolve<IComponentFactory>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var values = new List<string[]>(); var values = new List<string[]>();
var meleeName = _factory.GetComponentName(typeof(MeleeWeaponComponent));
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in _proto.EnumeratePrototypes<EntityPrototype>())
{ {
if (proto.Abstract || if (proto.Abstract ||
!proto.Components.TryGetValue(compFactory.GetComponentName(typeof(MeleeWeaponComponent)), !proto.Components.TryGetValue(meleeName,
out var meleeComp)) out var meleeComp))
{ {
continue; continue;
@@ -153,20 +166,19 @@ public sealed class StatValuesCommand : IConsoleCommand
private StatValuesEuiMessage GetLatheMessage() private StatValuesEuiMessage GetLatheMessage()
{ {
var values = new List<string[]>(); var values = new List<string[]>();
var protoManager = IoCManager.Resolve<IPrototypeManager>(); var priceSystem = _entManager.System<PricingSystem>();
var priceSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<PricingSystem>();
foreach (var proto in protoManager.EnumeratePrototypes<LatheRecipePrototype>()) foreach (var proto in _proto.EnumeratePrototypes<LatheRecipePrototype>())
{ {
var cost = 0.0; var cost = 0.0;
foreach (var (material, count) in proto.RequiredMaterials) foreach (var (material, count) in proto.RequiredMaterials)
{ {
var materialPrice = protoManager.Index<MaterialPrototype>(material).Price; var materialPrice = _proto.Index<MaterialPrototype>(material).Price;
cost += materialPrice * count; cost += materialPrice * count;
} }
var sell = priceSystem.GetEstimatedPrice(protoManager.Index<EntityPrototype>(proto.Result)); var sell = priceSystem.GetEstimatedPrice(_proto.Index<EntityPrototype>(proto.Result));
values.Add(new[] values.Add(new[]
{ {

View File

@@ -56,5 +56,3 @@
containers: containers:
board: !type:Container board: !type:Container
ents: [] ents: []
- type: StaticPrice
price: 400

View File

@@ -72,7 +72,7 @@
- type: SentienceTarget - type: SentienceTarget
flavorKind: station-event-random-sentience-flavor-mechanical flavorKind: station-event-random-sentience-flavor-mechanical
- type: StaticPrice - type: StaticPrice
price: 200 price: 100
- type: Appearance - type: Appearance
- type: WiresVisuals - type: WiresVisuals

View File

@@ -16,8 +16,6 @@
nodeGroupID: Pipe nodeGroupID: Pipe
pipeDirection: South pipeDirection: South
- type: CollideOnAnchor - type: CollideOnAnchor
- type: StaticPrice
price: 200
- type: entity - type: entity
parent: GasUnaryBase parent: GasUnaryBase
@@ -254,8 +252,6 @@
!type:PipeNode !type:PipeNode
nodeGroupID: Pipe nodeGroupID: Pipe
pipeDirection: South pipeDirection: South
- type: StaticPrice
price: 500
- type: Transform - type: Transform
noRot: false noRot: false

View File

@@ -38,7 +38,7 @@
- !type:DoActsBehavior - !type:DoActsBehavior
acts: ["Destruction"] acts: ["Destruction"]
- type: StaticPrice - type: StaticPrice
price: 1000 price: 300
placement: placement:
mode: SnapgridCenter mode: SnapgridCenter

View File

@@ -65,6 +65,8 @@
entity_storage: !type:Container entity_storage: !type:Container
paper_label: !type:ContainerSlot paper_label: !type:ContainerSlot
- type: ItemSlots - type: ItemSlots
- type: StaticPrice
price: 50
- type: Construction - type: Construction
graph: CrateGenericSteel graph: CrateGenericSteel
node: crategenericsteel node: crategenericsteel

View File

@@ -53,8 +53,6 @@
- MidImpassable - MidImpassable
- LowImpassable - LowImpassable
- type: Anchorable - type: Anchorable
- type: StaticPrice
price: 50
- type: Tag - type: Tag
id: Structure id: Structure