]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Bug fixes for RCD (#26792)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Mon, 8 Apr 2024 03:17:28 +0000 (22:17 -0500)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2024 03:17:28 +0000 (13:17 +1000)
Various fixes

Content.Client/RCD/RCDMenu.xaml.cs
Content.Shared/RCD/Systems/RCDSystem.cs
Resources/Locale/en-US/rcd/components/rcd-component.ftl
Resources/Prototypes/RCD/rcd.yml

index 8679e789dc7db9f95b83104654a76dc316822927..51ec66ea44464737d5dab9b175483d47e696f3b2 100644 (file)
@@ -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<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");
@@ -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();
             };
         }
index cd1e90dc1ff655d1166b8b7d163ef82e6fc28b65..bf312ee6fc35a101d39ea044c3d07c94fc6d7645 100644 (file)
@@ -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<RCDPrototype> StartingProtoId { get; private set; } = default!;
 
@@ -628,9 +630,10 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent
 
     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;
index bb65e76f3f7da411385d5a0510634eac61707006..9741bde388cad7bfbdcf0a72f34739da98e7102a 100644 (file)
@@ -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
index cb2c9ed23413aa5bcba2704bcc51b3f49bae1ef6..bc1aa91d28007ff0b99dd9ab2d28976724e2cf60 100644 (file)
@@ -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
 # 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