@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
if (i != orderedCosts.Length - 1)
|
||||
msg.PushNewline();
|
||||
}
|
||||
msg.Pop();
|
||||
|
||||
return msg.ToMarkup();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -32,12 +32,10 @@
|
||||
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
|
||||
@@ -85,3 +83,13 @@
|
||||
- board_slot
|
||||
- type: StaticPrice
|
||||
price: 2000
|
||||
|
||||
- type: entity
|
||||
id: FlatpackerNoBoardEffect
|
||||
categories:
|
||||
- hideSpawnMenu
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Structures/Machines/autolathe.rsi
|
||||
state: icon
|
||||
color: "#222222"
|
||||
|
||||
Reference in New Issue
Block a user