Skip to content

Commit

Permalink
More Quick Construction Recipes And Upgrades (#945)
Browse files Browse the repository at this point in the history
# Description

This PR adds a few new recipes to Quick Construction (accessed by
pressing Z on commonly used construction materials/items, such as rods,
glass, steel, plasma, etc etc). Along with simple nesting for grouping
items up under categories, akin to how the RCD works. Which allows
engineers to massively speed up pipe laying work, disposal rebuilding,
setting up the supermatter, etc etc.

First time doing UI code, apologies for the shitcode in advance :godo:

---

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/user-attachments/assets/9d540d7f-7e4f-4a43-874d-5ea069011a37

</p>
</details>

---

# Considerations

Is this powergamey? Probably. Is it fucking awesome? Hell yeah. Some
servers might question the fact that everyone can build stuff this fast
now that they dont have to deal too much with the construction menu for
the most common things... And might want to lock it behind traits or
given as a job freebie, like CPR for doctors.

Other servers might appreciate it if they are looking for more action to
happen over the round, and giving everyone the ability to deal with
breaches and repairs quicker is probably a step into that direction.
I'll be observing for feedback and adjust accordingly.

It also shouldn't invalidate any eventual RPDs, or other devices of the
kind since this is just a shortcut for construction, you still require
materials and a doafter for most of them.

---

# Changelog

:cl: Mocho
- add: Added a lot of recipes to the quick construction menus. Give it a
shot by pressing Z with different construction materials in your hand!

---------

Signed-off-by: gluesniffler <[email protected]>
Co-authored-by: VMSolidus <[email protected]>
  • Loading branch information
gluesniffler and VMSolidus committed Sep 24, 2024
1 parent 99ee312 commit 7c7619c
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 55 deletions.
95 changes: 53 additions & 42 deletions Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

// ReSharper disable InconsistentNaming

Expand All @@ -30,7 +31,6 @@ public sealed class ShortConstructionMenuBUI : BoundUserInterface
private readonly SpriteSystem _spriteSystem;

private RadialMenu? _menu;

public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_construction = _entManager.System<ConstructionSystem>();
Expand All @@ -39,8 +39,17 @@ public ShortConstructionMenuBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey

protected override void Open()
{
_menu = FormMenu();
_menu.OnClose += Close;
_menu = new RadialMenu
{
HorizontalExpand = true,
VerticalExpand = true,
BackButtonStyleClass = "RadialMenuBackButton",
CloseButtonStyleClass = "RadialMenuCloseButton"
};

if (_entManager.TryGetComponent<ShortConstructionComponent>(Owner, out var crafting))
CreateMenu(crafting.Entries);

_menu.OpenCenteredAt(_inputManager.MouseScreenPosition.Position / _displayManager.ScreenSize);
}

Expand All @@ -51,56 +60,58 @@ protected override void Dispose(bool disposing)
_menu?.Dispose();
}

private RadialMenu FormMenu()
private void CreateMenu(List<ShortConstructionEntry> entries, string? parentCategory = null)
{
var menu = new RadialMenu
{
HorizontalExpand = true,
VerticalExpand = true,
BackButtonStyleClass = "RadialMenuBackButton",
CloseButtonStyleClass = "RadialMenuCloseButton"
};

if (!_entManager.TryGetComponent<ShortConstructionComponent>(Owner, out var crafting))
return menu;
if (_menu == null)
return;

var mainContainer = new RadialContainer
var container = new RadialContainer
{
Radius = 36f / MathF.Sin(MathF.PI / 2f / crafting.Prototypes.Count)
Name = parentCategory ?? "Main",
Radius = 48f + 24f * MathF.Log(entries.Count),
};

foreach (var protoId in crafting.Prototypes)
{
if (!_protoManager.TryIndex(protoId, out var proto))
continue;
_menu.AddChild(container);

var button = new RadialMenuTextureButton
foreach (var entry in entries)
{
if (entry.Category != null)
{
ToolTip = Loc.GetString(proto.Name),
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(48f, 48f)
};

var texture = new TextureRect
var button = CreateButton(entry.Category.Name, entry.Category.Icon);
button.TargetLayer = entry.Category.Name;
CreateMenu(entry.Category.Entries, entry.Category.Name);
container.AddChild(button);
}
else if (entry.Prototype != null
&& _protoManager.TryIndex(entry.Prototype, out var proto))
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = _spriteSystem.Frame0(proto.Icon),
TextureScale = new Vector2(1.5f, 1.5f)
};
var button = CreateButton(proto.Name, proto.Icon);
button.OnButtonUp += _ => ConstructItem(proto);
container.AddChild(button);
}
}

button.AddChild(texture);
}

button.OnButtonUp += _ =>
{
ConstructItem(proto);
};
private RadialMenuTextureButton CreateButton(string name, SpriteSpecifier icon)
{
var button = new RadialMenuTextureButton
{
ToolTip = Loc.GetString(name),
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(64f, 64f),
};

mainContainer.AddChild(button);
}
var texture = new TextureRect
{
VerticalAlignment = Control.VAlignment.Center,
HorizontalAlignment = Control.HAlignment.Center,
Texture = _spriteSystem.Frame0(icon),
TextureScale = new Vector2(2f, 2f)
};

menu.AddChild(mainContainer);
return menu;
button.AddChild(texture);
return button;
}

/// <summary>
Expand All @@ -121,6 +132,6 @@ private void ConstructItem(ConstructionPrototype prototype)
}, new ConstructionPlacementHijack(_construction, prototype));

// Should only close the menu if we're placing a construction hijack.
_menu!.Close();
// Theres not much point to closing it though. _menu!.Close();
}
}
26 changes: 25 additions & 1 deletion Content.Shared/ShortConstruction/ShortConstructionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Shared.ShortConstruction;

[RegisterComponent, NetworkedComponent]
public sealed partial class ShortConstructionComponent : Component
{
[DataField(required: true)]
public List<ProtoId<ConstructionPrototype>> Prototypes = new();
public List<ShortConstructionEntry> Entries = new();
}

[DataDefinition]
public sealed partial class ShortConstructionEntry
{
[DataField]
public ProtoId<ConstructionPrototype>? Prototype { get; set; }

[DataField]
public ShortConstructionCategory? Category { get; set; }
}

[DataDefinition]
public sealed partial class ShortConstructionCategory
{
[DataField]
public string Name { get; set; } = string.Empty;

[DataField]
public SpriteSpecifier Icon { get; set; } = default!;

[DataField]
public List<ShortConstructionEntry> Entries { get; set; } = new();
}

[NetSerializable, Serializable]
Expand Down
63 changes: 59 additions & 4 deletions Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
prototypes:
- Window
entries:
- prototype: Window
- prototype: WindowDirectional
- prototype: WindowDiagonal
- prototype: SheetRGlass
- prototype: SheetPGlass
- prototype: SheetUGlass

- type: entity
parent: SheetGlass
Expand Down Expand Up @@ -193,8 +198,12 @@
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
prototypes:
- ReinforcedWindow
entries:
- prototype: SheetRPGlass1
- prototype: SheetRUGlass1
- prototype: ReinforcedWindow
- prototype: ReinforcedWindowDiagonal
- prototype: WindowReinforcedDirectional

- type: entity
parent: SheetRGlass
Expand Down Expand Up @@ -272,6 +281,18 @@
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: UserInterface
interfaces:
- key: enum.ShortConstructionUiKey.Key
type: ShortConstructionMenuBUI
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
entries:
- prototype: SheetRPGlass0
- prototype: PlasmaWindow
- prototype: PlasmaWindowDiagonal
- prototype: PlasmaWindowDirectional

- type: entity
parent: SheetPGlass
Expand Down Expand Up @@ -338,6 +359,17 @@
- ReagentId: Carbon
Quantity: 0.5
canReact: false
- type: UserInterface
interfaces:
- key: enum.ShortConstructionUiKey.Key
type: ShortConstructionMenuBUI
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
entries:
- prototype: ReinforcedPlasmaWindow
- prototype: ReinforcedPlasmaWindowDiagonal
- prototype: PlasmaReinforcedWindowDirectional

- type: entity
parent: SheetRPGlass
Expand Down Expand Up @@ -413,6 +445,18 @@
- ReagentId: Uranium
Quantity: 10
canReact: false
- type: UserInterface
interfaces:
- key: enum.ShortConstructionUiKey.Key
type: ShortConstructionMenuBUI
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
entries:
- prototype: SheetRUGlass0
- prototype: UraniumWindow
- prototype: UraniumWindowDiagonal
- prototype: UraniumWindowDirectional

- type: entity
parent: SheetUGlass
Expand Down Expand Up @@ -467,6 +511,17 @@
- ReagentId: Carbon
Quantity: 0.5
canReact: false
- type: UserInterface
interfaces:
- key: enum.ShortConstructionUiKey.Key
type: ShortConstructionMenuBUI
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
entries:
- prototype: ReinforcedUraniumWindow
- prototype: ReinforcedUraniumWindowDiagonal
- prototype: UraniumReinforcedWindowDirectional

- type: entity
parent: SheetRUGlass
Expand Down
84 changes: 78 additions & 6 deletions Resources/Prototypes/Entities/Objects/Materials/Sheets/metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,75 @@
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
prototypes:
- Girder
- MetalRod
- TileSteel
- TileWhite
- TileDark
entries:
- prototype: Girder
- prototype: MetalRod
- category:
name: Tiles
icon:
sprite: Objects/Tiles/tile.rsi
state: steel
entries:
- prototype: TileSteel
- prototype: TileWhite
- prototype: TileDark
- category:
name: Electronics
icon:
sprite: Structures/Machines/computers.rsi
state: computer-datatheory
entries:
- prototype: MachineFrame
- prototype: Computer
- prototype: Windoor
- prototype: LightTubeFixture
- prototype: APC
- prototype: AirAlarmFixture
- prototype: AirSensor
- prototype: FireAlarm
- category:
name: Atmospherics
icon:
sprite: Structures/Piping/Atmospherics/vent.rsi
state: vent_out
entries:
- prototype: GasPort
- prototype: GasOutletInjector
- prototype: GasVentScrubber
- prototype: GasPassiveVent
- prototype: GasVentPump
- prototype: GasMixer
- prototype: GasFilter
- prototype: GasVolumePump
- prototype: GasPressurePump
- prototype: GasValve
- category:
name: Piping
icon:
sprite: Structures/Piping/Atmospherics/pipe.rsi
state: pipeFourway
entries:
- prototype: HeatExchanger
- prototype: GasPipeBend
- prototype: GasPipeFourway
- prototype: GasPipeHalf
- prototype: GasPipeStraight
- prototype: GasPipeTJunction
- category:
name: Disposals
icon:
sprite: Structures/Piping/disposal.rsi
state: disposal
entries:
- prototype: DisposalPipe
- prototype: DisposalBend
- prototype: DisposalJunction
- prototype: DisposalYJunction
- prototype: DisposalRouter
- prototype: DisposalTagger
- prototype: DisposalTrunk
- prototype: DisposalUnit
- prototype: CrateGenericSteel

- type: entity
parent: SheetSteel
Expand Down Expand Up @@ -218,6 +281,15 @@
- ReagentId: Carbon
Quantity: 1
canReact: false
- type: UserInterface
interfaces:
- key: enum.ShortConstructionUiKey.Key
type: ShortConstructionMenuBUI
- type: ActivatableUI
key: enum.ShortConstructionUiKey.Key
- type: ShortConstruction
entries:
- prototype: SecureWindoor

- type: entity
parent: SheetPlasteel
Expand Down
Loading

0 comments on commit 7c7619c

Please sign in to comment.