using Content.Client.UserInterface.Controls;
+using Content.Shared.Popups;
using Content.Shared.RCD;
using Content.Shared.RCD.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
+using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
{
[Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
+ [Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly SpriteSystem _spriteSystem;
+ private readonly SharedPopupSystem _popup;
public event Action<ProtoId<RCDPrototype>>? SendRCDSystemMessageAction;
+ private EntityUid _owner;
+
public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
_spriteSystem = _entManager.System<SpriteSystem>();
+ _popup = _entManager.System<SharedPopupSystem>();
+
+ _owner = owner;
// Find the main radial container
var main = FindControl<RadialContainer>("Main");
if (parent == null)
continue;
- var name = Loc.GetString(proto.SetName);
- name = char.ToUpper(name[0]) + name.Remove(0, 1);
+ var tooltip = Loc.GetString(proto.SetName);
+
+ if ((proto.Mode == RcdMode.ConstructTile || proto.Mode == RcdMode.ConstructObject) &&
+ proto.Prototype != null && _protoManager.TryIndex(proto.Prototype, out var entProto))
+ {
+ tooltip = Loc.GetString(entProto.Name);
+ }
+
+ tooltip = char.ToUpper(tooltip[0]) + tooltip.Remove(0, 1);
var button = new RCDMenuButton()
{
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(64f, 64f),
- ToolTip = name,
+ ToolTip = tooltip,
ProtoId = protoId,
};
castChild.OnButtonUp += _ =>
{
SendRCDSystemMessageAction?.Invoke(castChild.ProtoId);
+
+ if (_playerManager.LocalSession?.AttachedEntity != null &&
+ _protoManager.TryIndex(castChild.ProtoId, out var proto))
+ {
+ var msg = Loc.GetString("rcd-component-change-mode", ("mode", Loc.GetString(proto.SetName)));
+
+ if (proto.Mode == RcdMode.ConstructTile || proto.Mode == RcdMode.ConstructObject)
+ {
+ var name = Loc.GetString(proto.SetName);
+
+ if (proto.Prototype != null &&
+ _protoManager.TryIndex(proto.Prototype, out var entProto))
+ name = entProto.Name;
+
+ msg = Loc.GetString("rcd-component-change-build-mode", ("name", name));
+ }
+
+ // Popup message
+ _popup.PopupClient(msg, _owner, _playerManager.LocalSession.AttachedEntity);
+ }
+
Close();
};
}
component.ProtoId = args.ProtoId;
UpdateCachedPrototype(uid, component);
Dirty(uid, component);
-
- if (args.Session.AttachedEntity != null)
- {
- // Popup message
- var msg = (component.CachedPrototype.Prototype != null) ?
- Loc.GetString("rcd-component-change-build-mode", ("name", Loc.GetString(component.CachedPrototype.SetName))) :
- Loc.GetString("rcd-component-change-mode", ("mode", Loc.GetString(component.CachedPrototype.SetName)));
-
- _popup.PopupClient(msg, uid, args.Session.AttachedEntity.Value);
- }
}
private void OnExamine(EntityUid uid, RCDComponent component, ExaminedEvent args)
// Update cached prototype if required
UpdateCachedPrototype(uid, component);
- var msg = (component.CachedPrototype.Prototype != null) ?
- Loc.GetString("rcd-component-examine-build-details", ("name", Loc.GetString(component.CachedPrototype.SetName))) :
- Loc.GetString("rcd-component-examine-mode-details", ("mode", Loc.GetString(component.CachedPrototype.SetName)));
+ var msg = Loc.GetString("rcd-component-examine-mode-details", ("mode", Loc.GetString(component.CachedPrototype.SetName)));
+
+ if (component.CachedPrototype.Mode == RcdMode.ConstructTile || component.CachedPrototype.Mode == RcdMode.ConstructObject)
+ {
+ var name = Loc.GetString(component.CachedPrototype.SetName);
+
+ if (component.CachedPrototype.Prototype != null &&
+ _protoManager.TryIndex(component.CachedPrototype.Prototype, out var proto))
+ name = proto.Name;
+
+ msg = Loc.GetString("rcd-component-examine-build-details", ("name", name));
+ }
args.PushMarkup(msg);
}
// Try to start the do after
var effect = Spawn(effectPrototype, mapGridData.Value.Location);
- var ev = new RCDDoAfterEvent(GetNetCoordinates(mapGridData.Value.Location), component.ProtoId, cost, EntityManager.GetNetEntity(effect));
+ var ev = new RCDDoAfterEvent(GetNetCoordinates(mapGridData.Value.Location), component.ConstructionDirection, component.ProtoId, cost, EntityManager.GetNetEntity(effect));
var doAfterArgs = new DoAfterArgs(EntityManager, user, delay, ev, uid, target: args.Target, used: uid)
{
return;
// Finalize the operation
- FinalizeRCDOperation(uid, component, mapGridData.Value, args.Target, args.User);
+ FinalizeRCDOperation(uid, component, mapGridData.Value, args.Direction, args.Target, args.User);
// Play audio and consume charges
_audio.PlayPredicted(component.SuccessSound, uid, args.User);
foreach (var fixture in fixtures.Fixtures.Values)
{
// Continue if no collision is possible
- if (fixture.CollisionLayer <= 0 || (fixture.CollisionLayer & (int) component.CachedPrototype.CollisionMask) == 0)
+ if (!fixture.Hard || fixture.CollisionLayer <= 0 || (fixture.CollisionLayer & (int) component.CachedPrototype.CollisionMask) == 0)
continue;
// Continue if our custom collision bounds are not intersected
#region Entity construction/deconstruction
- private void FinalizeRCDOperation(EntityUid uid, RCDComponent component, MapGridData mapGridData, EntityUid? target, EntityUid user)
+ private void FinalizeRCDOperation(EntityUid uid, RCDComponent component, MapGridData mapGridData, Direction direction, EntityUid? target, EntityUid user)
{
if (!_net.IsServer)
return;
Transform(ent).LocalRotation = Transform(uid).LocalRotation;
break;
case RcdRotation.User:
- Transform(ent).LocalRotation = component.ConstructionDirection.ToAngle();
+ Transform(ent).LocalRotation = direction.ToAngle();
break;
}
[DataField(required: true)]
public NetCoordinates Location { get; private set; } = default!;
+ [DataField]
+ public Direction Direction { get; private set; } = default!;
+
[DataField]
public ProtoId<RCDPrototype> StartingProtoId { get; private set; } = default!;
private RCDDoAfterEvent() { }
- public RCDDoAfterEvent(NetCoordinates location, ProtoId<RCDPrototype> startingProtoId, int cost, NetEntity? effect = null)
+ public RCDDoAfterEvent(NetCoordinates location, Direction direction, ProtoId<RCDPrototype> startingProtoId, int cost, NetEntity? effect = null)
{
Location = location;
+ Direction = direction;
StartingProtoId = startingProtoId;
Cost = cost;
Effect = effect;
### Prototype names (note: constructable items will be puralized)
rcd-component-deconstruct = deconstruct
-rcd-component-wall-solid = solid wall
rcd-component-floor-steel = steel tile
rcd-component-plating = hull plate
-rcd-component-catwalk = catwalk
-rcd-component-wall-reinforced = reinforced wall
-rcd-component-grille = grille
-rcd-component-window = window
-rcd-component-window-directional = directional window
-rcd-component-window-reinforced-directional = directional reinforced window
-rcd-component-reinforced-window = reinforced window
-rcd-component-airlock = standard airlock
-rcd-component-airlock-glass = glass airlock
-rcd-component-firelock = firelock
-rcd-component-computer-frame = computer frame
-rcd-component-machine-frame = machine frame
-rcd-component-tube-light = light
-rcd-component-window-bulb-light = small light
-rcd-component-window-lv-cable = LV cable
-rcd-component-window-mv-cable = MV cable
-rcd-component-window-hv-cable = HV cable
-rcd-component-window-cable-terminal = cable terminal
- type: rcd
id: DeconstructLattice # Hidden prototype - do not add to RCDs
+ name: rcd-component-deconstruct
mode: Deconstruct
cost: 2
delay: 1
- type: rcd
id: DeconstructTile # Hidden prototype - do not add to RCDs
+ name: rcd-component-deconstruct
mode: Deconstruct
cost: 4
delay: 4
- type: rcd
id: Catwalk
- name: rcd-component-catwalk
category: WallsAndFlooring
sprite: /Textures/Interface/Radial/RCD/catwalk.png
mode: ConstructObject
# Walls
- type: rcd
id: WallSolid
- name: rcd-component-wall-solid
category: WallsAndFlooring
sprite: /Textures/Interface/Radial/RCD/solid_wall.png
mode: ConstructObject
- type: rcd
id: Grille
- name: rcd-component-grille
category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/grille.png
mode: ConstructObject
# Windows
- type: rcd
id: Window
- name: rcd-component-window
category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/window.png
mode: ConstructObject
- type: rcd
id: WindowDirectional
- name: rcd-component-window-directional
category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/directional.png
mode: ConstructObject
- type: rcd
id: ReinforcedWindow
- name: rcd-component-reinforced-window
category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/window_reinforced.png
mode: ConstructObject
- type: rcd
id: WindowReinforcedDirectional
- name: rcd-component-window-reinforced-directional
category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/directional_reinforced.png
mode: ConstructObject
# Airlocks
- type: rcd
id: Airlock
- name: rcd-component-airlock
category: Airlocks
sprite: /Textures/Interface/Radial/RCD/airlock.png
mode: ConstructObject
- type: rcd
id: AirlockGlass
- name: rcd-component-airlock-glass
category: Airlocks
sprite: /Textures/Interface/Radial/RCD/glass_airlock.png
mode: ConstructObject
- type: rcd
id: Firelock
- name: rcd-component-firelock
category: Airlocks
sprite: /Textures/Interface/Radial/RCD/firelock.png
mode: ConstructObject
# Lighting
- type: rcd
id: TubeLight
- name: rcd-component-tube-light
category: Lighting
sprite: /Textures/Interface/Radial/RCD/tube_light.png
mode: ConstructObject
- type: rcd
id: BulbLight
- name: rcd-component-window-bulb-light
category: Lighting
sprite: /Textures/Interface/Radial/RCD/bulb_light.png
mode: ConstructObject
# Electrical
- type: rcd
id: LVCable
- name: rcd-component-window-lv-cable
category: Electrical
sprite: /Textures/Interface/Radial/RCD/lv_coil.png
mode: ConstructObject
- type: rcd
id: MVCable
- name: rcd-component-window-mv-cable
category: Electrical
sprite: /Textures/Interface/Radial/RCD/mv_coil.png
mode: ConstructObject
- type: rcd
id: HVCable
- name: rcd-component-window-hv-cable
category: Electrical
sprite: /Textures/Interface/Radial/RCD/hv_coil.png
mode: ConstructObject
- type: rcd
id: CableTerminal
- name: rcd-component-window-cable-terminal
category: Electrical
sprite: /Textures/Interface/Radial/RCD/cable_terminal.png
mode: ConstructObject