From f784e9ca4e7493bd2f20d44a6b52da10ddb8f02f Mon Sep 17 00:00:00 2001 From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Sun, 7 Apr 2024 22:17:28 -0500 Subject: [PATCH] Bug fixes for RCD (#26792) Various fixes --- Content.Client/RCD/RCDMenu.xaml.cs | 43 +++++++++++++++++-- Content.Shared/RCD/Systems/RCDSystem.cs | 41 ++++++++++-------- .../en-US/rcd/components/rcd-component.ftl | 19 -------- Resources/Prototypes/RCD/rcd.yml | 18 +------- 4 files changed, 64 insertions(+), 57 deletions(-) diff --git a/Content.Client/RCD/RCDMenu.xaml.cs b/Content.Client/RCD/RCDMenu.xaml.cs index 8679e789dc..51ec66ea44 100644 --- a/Content.Client/RCD/RCDMenu.xaml.cs +++ b/Content.Client/RCD/RCDMenu.xaml.cs @@ -1,8 +1,10 @@ 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; @@ -16,17 +18,24 @@ public sealed partial class RCDMenu : RadialMenu { [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>? SendRCDSystemMessageAction; + private EntityUid _owner; + public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui) { IoCManager.InjectDependencies(this); RobustXamlLoader.Load(this); _spriteSystem = _entManager.System(); + _popup = _entManager.System(); + + _owner = owner; // Find the main radial container var main = FindControl("Main"); @@ -51,14 +60,21 @@ public sealed partial class RCDMenu : RadialMenu 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, }; @@ -120,6 +136,27 @@ public sealed partial class RCDMenu : RadialMenu 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(); }; } diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index cd1e90dc1f..bf312ee6fc 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -98,16 +98,6 @@ public class RCDSystem : EntitySystem 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) @@ -118,9 +108,18 @@ public class RCDSystem : EntitySystem // 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); } @@ -206,7 +205,7 @@ public class RCDSystem : EntitySystem // 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) { @@ -263,7 +262,7 @@ public class RCDSystem : EntitySystem 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); @@ -419,7 +418,7 @@ public class RCDSystem : EntitySystem 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 @@ -494,7 +493,7 @@ public class RCDSystem : EntitySystem #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; @@ -521,7 +520,7 @@ public class RCDSystem : EntitySystem Transform(ent).LocalRotation = Transform(uid).LocalRotation; break; case RcdRotation.User: - Transform(ent).LocalRotation = component.ConstructionDirection.ToAngle(); + Transform(ent).LocalRotation = direction.ToAngle(); break; } @@ -617,6 +616,9 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent [DataField(required: true)] public NetCoordinates Location { get; private set; } = default!; + [DataField] + public Direction Direction { get; private set; } = default!; + [DataField] public ProtoId StartingProtoId { get; private set; } = default!; @@ -628,9 +630,10 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent private RCDDoAfterEvent() { } - public RCDDoAfterEvent(NetCoordinates location, ProtoId startingProtoId, int cost, NetEntity? effect = null) + public RCDDoAfterEvent(NetCoordinates location, Direction direction, ProtoId startingProtoId, int cost, NetEntity? effect = null) { Location = location; + Direction = direction; StartingProtoId = startingProtoId; Cost = cost; Effect = effect; diff --git a/Resources/Locale/en-US/rcd/components/rcd-component.ftl b/Resources/Locale/en-US/rcd/components/rcd-component.ftl index bb65e76f3f..9741bde388 100644 --- a/Resources/Locale/en-US/rcd/components/rcd-component.ftl +++ b/Resources/Locale/en-US/rcd/components/rcd-component.ftl @@ -43,24 +43,5 @@ rcd-component-lighting = Lighting ### 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 diff --git a/Resources/Prototypes/RCD/rcd.yml b/Resources/Prototypes/RCD/rcd.yml index cb2c9ed234..bc1aa91d28 100644 --- a/Resources/Prototypes/RCD/rcd.yml +++ b/Resources/Prototypes/RCD/rcd.yml @@ -14,6 +14,7 @@ - type: rcd id: DeconstructLattice # Hidden prototype - do not add to RCDs + name: rcd-component-deconstruct mode: Deconstruct cost: 2 delay: 1 @@ -22,6 +23,7 @@ - type: rcd id: DeconstructTile # Hidden prototype - do not add to RCDs + name: rcd-component-deconstruct mode: Deconstruct cost: 4 delay: 4 @@ -59,7 +61,6 @@ - type: rcd id: Catwalk - name: rcd-component-catwalk category: WallsAndFlooring sprite: /Textures/Interface/Radial/RCD/catwalk.png mode: ConstructObject @@ -76,7 +77,6 @@ # Walls - type: rcd id: WallSolid - name: rcd-component-wall-solid category: WallsAndFlooring sprite: /Textures/Interface/Radial/RCD/solid_wall.png mode: ConstructObject @@ -89,7 +89,6 @@ - type: rcd id: Grille - name: rcd-component-grille category: WindowsAndGrilles sprite: /Textures/Interface/Radial/RCD/grille.png mode: ConstructObject @@ -103,7 +102,6 @@ # Windows - type: rcd id: Window - name: rcd-component-window category: WindowsAndGrilles sprite: /Textures/Interface/Radial/RCD/window.png mode: ConstructObject @@ -118,7 +116,6 @@ - type: rcd id: WindowDirectional - name: rcd-component-window-directional category: WindowsAndGrilles sprite: /Textures/Interface/Radial/RCD/directional.png mode: ConstructObject @@ -134,7 +131,6 @@ - type: rcd id: ReinforcedWindow - name: rcd-component-reinforced-window category: WindowsAndGrilles sprite: /Textures/Interface/Radial/RCD/window_reinforced.png mode: ConstructObject @@ -149,7 +145,6 @@ - type: rcd id: WindowReinforcedDirectional - name: rcd-component-window-reinforced-directional category: WindowsAndGrilles sprite: /Textures/Interface/Radial/RCD/directional_reinforced.png mode: ConstructObject @@ -166,7 +161,6 @@ # Airlocks - type: rcd id: Airlock - name: rcd-component-airlock category: Airlocks sprite: /Textures/Interface/Radial/RCD/airlock.png mode: ConstructObject @@ -179,7 +173,6 @@ - type: rcd id: AirlockGlass - name: rcd-component-airlock-glass category: Airlocks sprite: /Textures/Interface/Radial/RCD/glass_airlock.png mode: ConstructObject @@ -192,7 +185,6 @@ - type: rcd id: Firelock - name: rcd-component-firelock category: Airlocks sprite: /Textures/Interface/Radial/RCD/firelock.png mode: ConstructObject @@ -206,7 +198,6 @@ # Lighting - type: rcd id: TubeLight - name: rcd-component-tube-light category: Lighting sprite: /Textures/Interface/Radial/RCD/tube_light.png mode: ConstructObject @@ -220,7 +211,6 @@ - type: rcd id: BulbLight - name: rcd-component-window-bulb-light category: Lighting sprite: /Textures/Interface/Radial/RCD/bulb_light.png mode: ConstructObject @@ -235,7 +225,6 @@ # Electrical - type: rcd id: LVCable - name: rcd-component-window-lv-cable category: Electrical sprite: /Textures/Interface/Radial/RCD/lv_coil.png mode: ConstructObject @@ -250,7 +239,6 @@ - type: rcd id: MVCable - name: rcd-component-window-mv-cable category: Electrical sprite: /Textures/Interface/Radial/RCD/mv_coil.png mode: ConstructObject @@ -265,7 +253,6 @@ - type: rcd id: HVCable - name: rcd-component-window-hv-cable category: Electrical sprite: /Textures/Interface/Radial/RCD/hv_coil.png mode: ConstructObject @@ -280,7 +267,6 @@ - type: rcd id: CableTerminal - name: rcd-component-window-cable-terminal category: Electrical sprite: /Textures/Interface/Radial/RCD/cable_terminal.png mode: ConstructObject