]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cargo 1984 (#15579)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 29 Apr 2023 04:59:24 +0000 (14:59 +1000)
committerGitHub <noreply@github.com>
Sat, 29 Apr 2023 04:59:24 +0000 (14:59 +1000)
Content.Server/UserInterface/StatValuesCommand.cs
Resources/Prototypes/Entities/Structures/Machines/Computers/base_structurecomputers.yml
Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml
Resources/Prototypes/Entities/Structures/Piping/Atmospherics/unary.yml
Resources/Prototypes/Entities/Structures/Shuttles/thrusters.yml
Resources/Prototypes/Entities/Structures/Storage/Crates/base_structurecrates.yml
Resources/Prototypes/Entities/Structures/base_structure.yml

index 7ca39fce26773337b419000d7aac6192780a3d26..7356a0204a0772046da35a53247674d1bb5d5232 100644 (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[]
             {
index 4f1ab73fec2eb482e41756ab16bd5a1cadef9335..6d90c0f2b8c68caec989a4a6f79d9bd130503d27 100644 (file)
@@ -56,5 +56,3 @@
     containers:
       board: !type:Container
         ents: []
-  - type: StaticPrice
-    price: 400
index d4a34c954876a399b2e814d9850260115360b212..2fb7f3c064cf7d7a782b659cec8aaa13882f8d9b 100644 (file)
@@ -72,7 +72,7 @@
   - type: SentienceTarget
     flavorKind: station-event-random-sentience-flavor-mechanical
   - type: StaticPrice
-    price: 200
+    price: 100
   - type: Appearance
   - type: WiresVisuals
 
index 11d2b9a1f89a8094b57a669ffc0119dae741ea56..6c3bf09eecb16ac18e8c83be748e305f17e707f2 100644 (file)
@@ -16,8 +16,6 @@
           nodeGroupID: Pipe
           pipeDirection: South
     - type: CollideOnAnchor
-    - type: StaticPrice
-      price: 200
 
 - type: entity
   parent: GasUnaryBase
           !type:PipeNode
           nodeGroupID: Pipe
           pipeDirection: South
-    - type: StaticPrice
-      price: 500
     - type: Transform
       noRot: false
 
index a17037220a140c556f05219cbc12f641e88a3855..eab60098558574e62128cdbb80e1623d8d24a3e6 100644 (file)
@@ -38,7 +38,7 @@
           - !type:DoActsBehavior
             acts: ["Destruction"]
     - type: StaticPrice
-      price: 1000
+      price: 300
   placement:
     mode: SnapgridCenter
 
index ab435b1976c891c27250180248a3520d21b6c6c8..a38cbe66b8e9c1db63976ec42310e196b6bffa03 100644 (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
index eb3bac465be7a414c372fa2c9ee06c79cec1a8f2..44fc1156e4505e1800b76e5e8f950e27e1c99ec7 100644 (file)
@@ -53,8 +53,6 @@
       - MidImpassable
       - LowImpassable
   - type: Anchorable
-  - type: StaticPrice
-    price: 50
 
 - type: Tag
   id: Structure