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