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.Linq;
using Content.Server.Administration;
using Content.Server.Cargo.Systems;
using Content.Server.EUI;
@@ -16,6 +17,11 @@ namespace Content.Server.UserInterface;
[AdminCommand(AdminFlags.Debug)]
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 Description => Loc.GetString("stat-values-desc");
public string Help => $"{Command} <cargosell / lathsell / melee>";
@@ -51,24 +57,33 @@ public sealed class StatValuesCommand : IConsoleCommand
return;
}
var euiManager = IoCManager.Resolve<EuiManager>();
var eui = new StatValuesEui();
euiManager.OpenEui(eui, pSession);
_eui.OpenEui(eui, pSession);
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()
{
// 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.
var values = new List<string[]>();
var entManager = IoCManager.Resolve<IEntityManager>();
var priceSystem = entManager.System<PricingSystem>();
var metaQuery = entManager.GetEntityQuery<MetaDataComponent>();
var priceSystem = _entManager.System<PricingSystem>();
var metaQuery = _entManager.GetEntityQuery<MetaDataComponent>();
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))
continue;
@@ -107,15 +122,13 @@ public sealed class StatValuesCommand : IConsoleCommand
private StatValuesEuiMessage GetMelee()
{
var compFactory = IoCManager.Resolve<IComponentFactory>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
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 ||
!proto.Components.TryGetValue(compFactory.GetComponentName(typeof(MeleeWeaponComponent)),
!proto.Components.TryGetValue(meleeName,
out var meleeComp))
{
continue;
@@ -153,20 +166,19 @@ public sealed class StatValuesCommand : IConsoleCommand
private StatValuesEuiMessage GetLatheMessage()
{
var values = new List<string[]>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var priceSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<PricingSystem>();
var priceSystem = _entManager.System<PricingSystem>();
foreach (var proto in protoManager.EnumeratePrototypes<LatheRecipePrototype>())
foreach (var proto in _proto.EnumeratePrototypes<LatheRecipePrototype>())
{
var cost = 0.0;
foreach (var (material, count) in proto.RequiredMaterials)
{
var materialPrice = protoManager.Index<MaterialPrototype>(material).Price;
var materialPrice = _proto.Index<MaterialPrototype>(material).Price;
cost += materialPrice * count;
}
var sell = priceSystem.GetEstimatedPrice(protoManager.Index<EntityPrototype>(proto.Result));
var sell = priceSystem.GetEstimatedPrice(_proto.Index<EntityPrototype>(proto.Result));
values.Add(new[]
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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