]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Flatpacker Tweaks (#23552)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 5 Jan 2024 05:01:24 +0000 (00:01 -0500)
committerGitHub <noreply@github.com>
Fri, 5 Jan 2024 05:01:24 +0000 (21:01 -0800)
* flatpacker nerf

* stuff

Content.Client/Construction/UI/FlatpackCreatorMenu.xaml
Content.Client/Construction/UI/FlatpackCreatorMenu.xaml.cs
Content.Server/Construction/FlatpackSystem.cs
Resources/Locale/en-US/construction/components/flatpack.ftl
Resources/Prototypes/Entities/Structures/Machines/flatpacker.yml

index 5dffc5aa7fdebe1e91a1efa8388d97fe84890254..eec5c229cb532f7ce33d844fb905d22d2d7ff9ba 100644 (file)
@@ -8,20 +8,21 @@
     <BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True" Margin="10">
         <BoxContainer SizeFlagsStretchRatio="2" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
             <BoxContainer Orientation="Vertical">
-                <SpriteView Name="MachineSprite" Scale="4 4" HorizontalAlignment="Center" MinSize="128 128"/>
+                <SpriteView Name="MachineSprite" Scale="4 4" HorizontalAlignment="Center" VerticalExpand="True" MinSize="128 128"/>
                 <RichTextLabel Name="MachineNameLabel" HorizontalAlignment="Center" StyleClasses="LabelKeyText"/>
             </BoxContainer>
             <Control MinHeight="10"/>
             <Button Name="PackButton" Text="{Loc 'flatpacker-ui-pack-button'}" MaxWidth="150" Margin="0 0 0 10"/>
-            <BoxContainer Orientation="Vertical" VerticalExpand="True">
+            <BoxContainer Orientation="Vertical" VerticalExpand="True" RectClipContent="True">
                 <Label Name="CostHeaderLabel" Text="{Loc 'flatpacker-ui-cost-label'}" HorizontalAlignment="Left"/>
                 <PanelContainer VerticalExpand="True"
                                 HorizontalExpand="True">
                     <PanelContainer.PanelOverride>
                         <gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
                     </PanelContainer.PanelOverride>
-                    <BoxContainer Orientation="Vertical" VerticalExpand="True">
-                        <RichTextLabel Name="CostLabel" HorizontalAlignment="Center"/>
+                    <BoxContainer Orientation="Vertical" VerticalAlignment="Center">
+                        <RichTextLabel Name="CostLabel" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                        <RichTextLabel Name="InsertLabel" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                     </BoxContainer>
                 </PanelContainer>
             </BoxContainer>
index 8f8fec64a3948fb72381c24bac505c5b678012d0..ad19bc30f42fc7849d5a6de5822e5632d4e6e729 100644 (file)
@@ -27,6 +27,9 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
 
     private readonly EntityUid _owner;
 
+    [ValidatePrototypeId<EntityPrototype>]
+    public const string NoBoardEffectId = "FlatpackerNoBoardEffect";
+
     private EntityUid? _currentBoard = EntityUid.Invalid;
     private EntityUid? _machinePreview;
 
@@ -47,6 +50,7 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
         PackButton.OnPressed += _ => PackButtonPressed?.Invoke();
 
         MaterialStorageControl.SetOwner(uid);
+        InsertLabel.SetMarkup(Loc.GetString("flatpacker-ui-insert-board"));
     }
 
     protected override void FrameUpdate(FrameEventArgs args)
@@ -63,15 +67,15 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
             !_itemSlots.TryGetSlot(_owner, flatpacker.SlotId, out var itemSlot))
             return;
 
+        MachineBoardComponent? machineBoardComp = null;
         if (flatpacker.Packing)
         {
             PackButton.Disabled = true;
         }
         else if (_currentBoard != null)
         {
-            //todo double trycomp is kinda stinky.
             Dictionary<string, int> cost;
-            if (_entityManager.TryGetComponent<MachineBoardComponent>(_currentBoard, out var machineBoardComp) &&
+            if (_entityManager.TryGetComponent(_currentBoard, out machineBoardComp) &&
                 machineBoardComp.Prototype is not null)
                 cost = _flatpack.GetFlatpackCreationCost((_owner, flatpacker), (_currentBoard.Value, machineBoardComp));
             else
@@ -88,16 +92,17 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
 
         _currentBoard = itemSlot.Item;
         CostHeaderLabel.Visible = _currentBoard != null;
+        InsertLabel.Visible = _currentBoard == null;
 
         if (_currentBoard is not null)
         {
             string? prototype = null;
             Dictionary<string, int>? cost = null;
 
-            if (_entityManager.TryGetComponent<MachineBoardComponent>(_currentBoard, out var machineBoard))
+            if (machineBoardComp != null || _entityManager.TryGetComponent(_currentBoard, out machineBoardComp))
             {
-                prototype = machineBoard.Prototype;
-                cost = _flatpack.GetFlatpackCreationCost((_owner, flatpacker), (_currentBoard.Value, machineBoard));
+                prototype = machineBoardComp.Prototype;
+                cost = _flatpack.GetFlatpackCreationCost((_owner, flatpacker), (_currentBoard.Value, machineBoardComp));
             }
             else if (_entityManager.TryGetComponent<ComputerBoardComponent>(_currentBoard, out var computerBoard))
             {
@@ -116,22 +121,23 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
         }
         else
         {
-            _machinePreview = null;
-            MachineNameLabel.SetMessage(" ");
+            _machinePreview = _entityManager.Spawn(NoBoardEffectId);
             CostLabel.SetMessage(Loc.GetString("flatpacker-ui-no-board-label"));
+            MachineNameLabel.SetMessage(" ");
             PackButton.Disabled = true;
         }
 
         MachineSprite.SetEntity(_machinePreview);
     }
 
-    //todo beautify
     private string GetCostString(Dictionary<string, int> costs)
     {
-        var orderedCosts = costs.OrderBy(p => p.Value);
+        var orderedCosts = costs.OrderBy(p => p.Value).ToArray();
         var msg = new FormattedMessage();
-        foreach (var (mat, amount) in orderedCosts)
+        for (var i = 0; i < orderedCosts.Length; i++)
         {
+            var (mat, amount) = orderedCosts[i];
+
             var matProto = _prototypeManager.Index<MaterialPrototype>(mat);
 
             var sheetVolume = _materialStorage.GetSheetVolume(matProto);
@@ -144,9 +150,10 @@ public sealed partial class FlatpackCreatorMenu : FancyWindow
                 ("material", Loc.GetString(matProto.Name)));
 
             msg.AddMarkup(text);
-            msg.PushNewline();
+
+            if (i != orderedCosts.Length - 1)
+                msg.PushNewline();
         }
-        msg.Pop();
 
         return msg.ToMarkup();
     }
index 9cd8643cbd45fa827648ca564f5f1499d3198569..be082eba3072d261093cfe2e45e404a4b2b2a9b6 100644 (file)
@@ -5,7 +5,6 @@ using Content.Shared.Construction;
 using Content.Shared.Construction.Components;
 using Content.Shared.Containers.ItemSlots;
 using Robust.Shared.Timing;
-using YamlDotNet.Serialization.NodeTypeResolvers;
 
 namespace Content.Server.Construction;
 
@@ -37,7 +36,7 @@ public sealed class FlatpackSystem : SharedFlatpackSystem
         Dictionary<string, int>? cost = null;
         if (TryComp<MachineBoardComponent>(machineBoard, out var machineBoardComponent))
             cost = GetFlatpackCreationCost(ent, (machineBoard, machineBoardComponent));
-        if (TryComp<ComputerBoardComponent>(machineBoard, out var computerBoardComponent))
+        if (HasComp<ComputerBoardComponent>(machineBoard))
             cost = GetFlatpackCreationCost(ent);
 
         if (cost is null)
@@ -78,7 +77,7 @@ public sealed class FlatpackSystem : SharedFlatpackSystem
         Dictionary<string, int>? cost = null;
         if (TryComp<MachineBoardComponent>(machineBoard, out var machineBoardComponent))
             cost = GetFlatpackCreationCost(ent, (machineBoard, machineBoardComponent));
-        if (TryComp<ComputerBoardComponent>(machineBoard, out var computerBoardComponent))
+        if (HasComp<ComputerBoardComponent>(machineBoard))
             cost = GetFlatpackCreationCost(ent);
 
         if (cost is null)
@@ -89,6 +88,7 @@ public sealed class FlatpackSystem : SharedFlatpackSystem
 
         var flatpack = Spawn(comp.BaseFlatpackPrototype, Transform(ent).Coordinates);
         SetupFlatpack(flatpack, machineBoard);
+        Del(machineBoard);
     }
 
     public override void Update(float frameTime)
index 8449da7048a13f7ea9288933178bb19254e02c3e..0957d92f3e0790080a7a204e0081f7b3aff02ff6 100644 (file)
@@ -8,4 +8,5 @@ flatpacker-ui-title = Flatpacker 1001
 flatpacker-ui-materials-label = Materials
 flatpacker-ui-cost-label = Packing Cost
 flatpacker-ui-no-board-label = No board present!
+flatpacker-ui-insert-board = Insert a board to begin.
 flatpacker-ui-pack-button = Pack
index 69e5678f4226727d0e23cfd64161a1a30279db75..54a32db69f5311ac7de4b8e930f5eea412649729 100644 (file)
           False: { visible: false }
   - type: FlatpackCreator
     baseMachineCost:
-      Steel: 600
-      Plastic: 200
+      Steel: 750
     baseComputerCost:
-      Steel: 600
-      Plastic: 200
-      Glass: 200
+      Steel: 500
+      Glass: 250
   - type: Machine
     board: FlatpackerMachineCircuitboard
   - type: MaterialStorage
     - board_slot
   - type: StaticPrice
     price: 2000
+
+- type: entity
+  id: FlatpackerNoBoardEffect
+  categories:
+  - hideSpawnMenu
+  components:
+  - type: Sprite
+    sprite: Structures/Machines/autolathe.rsi
+    state: icon
+    color: "#222222"