Bug fixes for RCD (#26792)

Various fixes
This commit is contained in:
chromiumboy
2024-04-07 22:17:28 -05:00
committed by GitHub
parent 9811173a1a
commit f784e9ca4e
4 changed files with 64 additions and 57 deletions

View File

@@ -1,8 +1,10 @@
using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Controls;
using Content.Shared.Popups;
using Content.Shared.RCD; using Content.Shared.RCD;
using Content.Shared.RCD.Components; using Content.Shared.RCD.Components;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
@@ -16,17 +18,24 @@ public sealed partial class RCDMenu : RadialMenu
{ {
[Dependency] private readonly EntityManager _entManager = default!; [Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly SpriteSystem _spriteSystem; private readonly SpriteSystem _spriteSystem;
private readonly SharedPopupSystem _popup;
public event Action<ProtoId<RCDPrototype>>? SendRCDSystemMessageAction; public event Action<ProtoId<RCDPrototype>>? SendRCDSystemMessageAction;
private EntityUid _owner;
public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui) public RCDMenu(EntityUid owner, RCDMenuBoundUserInterface bui)
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
_spriteSystem = _entManager.System<SpriteSystem>(); _spriteSystem = _entManager.System<SpriteSystem>();
_popup = _entManager.System<SharedPopupSystem>();
_owner = owner;
// Find the main radial container // Find the main radial container
var main = FindControl<RadialContainer>("Main"); var main = FindControl<RadialContainer>("Main");
@@ -51,14 +60,21 @@ public sealed partial class RCDMenu : RadialMenu
if (parent == null) if (parent == null)
continue; continue;
var name = Loc.GetString(proto.SetName); var tooltip = Loc.GetString(proto.SetName);
name = char.ToUpper(name[0]) + name.Remove(0, 1);
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() var button = new RCDMenuButton()
{ {
StyleClasses = { "RadialMenuButton" }, StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(64f, 64f), SetSize = new Vector2(64f, 64f),
ToolTip = name, ToolTip = tooltip,
ProtoId = protoId, ProtoId = protoId,
}; };
@@ -120,6 +136,27 @@ public sealed partial class RCDMenu : RadialMenu
castChild.OnButtonUp += _ => castChild.OnButtonUp += _ =>
{ {
SendRCDSystemMessageAction?.Invoke(castChild.ProtoId); 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(); Close();
}; };
} }

View File

@@ -98,16 +98,6 @@ public class RCDSystem : EntitySystem
component.ProtoId = args.ProtoId; component.ProtoId = args.ProtoId;
UpdateCachedPrototype(uid, component); UpdateCachedPrototype(uid, component);
Dirty(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) private void OnExamine(EntityUid uid, RCDComponent component, ExaminedEvent args)
@@ -118,9 +108,18 @@ public class RCDSystem : EntitySystem
// Update cached prototype if required // Update cached prototype if required
UpdateCachedPrototype(uid, component); UpdateCachedPrototype(uid, component);
var msg = (component.CachedPrototype.Prototype != null) ? var msg = Loc.GetString("rcd-component-examine-mode-details", ("mode", Loc.GetString(component.CachedPrototype.SetName)));
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))); 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); args.PushMarkup(msg);
} }
@@ -206,7 +205,7 @@ public class RCDSystem : EntitySystem
// Try to start the do after // Try to start the do after
var effect = Spawn(effectPrototype, mapGridData.Value.Location); 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) var doAfterArgs = new DoAfterArgs(EntityManager, user, delay, ev, uid, target: args.Target, used: uid)
{ {
@@ -263,7 +262,7 @@ public class RCDSystem : EntitySystem
return; return;
// Finalize the operation // 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 // Play audio and consume charges
_audio.PlayPredicted(component.SuccessSound, uid, args.User); _audio.PlayPredicted(component.SuccessSound, uid, args.User);
@@ -419,7 +418,7 @@ public class RCDSystem : EntitySystem
foreach (var fixture in fixtures.Fixtures.Values) foreach (var fixture in fixtures.Fixtures.Values)
{ {
// Continue if no collision is possible // 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;
// Continue if our custom collision bounds are not intersected // Continue if our custom collision bounds are not intersected
@@ -494,7 +493,7 @@ public class RCDSystem : EntitySystem
#region Entity construction/deconstruction #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) if (!_net.IsServer)
return; return;
@@ -521,7 +520,7 @@ public class RCDSystem : EntitySystem
Transform(ent).LocalRotation = Transform(uid).LocalRotation; Transform(ent).LocalRotation = Transform(uid).LocalRotation;
break; break;
case RcdRotation.User: case RcdRotation.User:
Transform(ent).LocalRotation = component.ConstructionDirection.ToAngle(); Transform(ent).LocalRotation = direction.ToAngle();
break; break;
} }
@@ -617,6 +616,9 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent
[DataField(required: true)] [DataField(required: true)]
public NetCoordinates Location { get; private set; } = default!; public NetCoordinates Location { get; private set; } = default!;
[DataField]
public Direction Direction { get; private set; } = default!;
[DataField] [DataField]
public ProtoId<RCDPrototype> StartingProtoId { get; private set; } = default!; public ProtoId<RCDPrototype> StartingProtoId { get; private set; } = default!;
@@ -628,9 +630,10 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent
private RCDDoAfterEvent() { } 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; Location = location;
Direction = direction;
StartingProtoId = startingProtoId; StartingProtoId = startingProtoId;
Cost = cost; Cost = cost;
Effect = effect; Effect = effect;

View File

@@ -43,24 +43,5 @@ rcd-component-lighting = Lighting
### Prototype names (note: constructable items will be puralized) ### Prototype names (note: constructable items will be puralized)
rcd-component-deconstruct = deconstruct rcd-component-deconstruct = deconstruct
rcd-component-wall-solid = solid wall
rcd-component-floor-steel = steel tile rcd-component-floor-steel = steel tile
rcd-component-plating = hull plate 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

View File

@@ -14,6 +14,7 @@
- type: rcd - type: rcd
id: DeconstructLattice # Hidden prototype - do not add to RCDs id: DeconstructLattice # Hidden prototype - do not add to RCDs
name: rcd-component-deconstruct
mode: Deconstruct mode: Deconstruct
cost: 2 cost: 2
delay: 1 delay: 1
@@ -22,6 +23,7 @@
- type: rcd - type: rcd
id: DeconstructTile # Hidden prototype - do not add to RCDs id: DeconstructTile # Hidden prototype - do not add to RCDs
name: rcd-component-deconstruct
mode: Deconstruct mode: Deconstruct
cost: 4 cost: 4
delay: 4 delay: 4
@@ -59,7 +61,6 @@
- type: rcd - type: rcd
id: Catwalk id: Catwalk
name: rcd-component-catwalk
category: WallsAndFlooring category: WallsAndFlooring
sprite: /Textures/Interface/Radial/RCD/catwalk.png sprite: /Textures/Interface/Radial/RCD/catwalk.png
mode: ConstructObject mode: ConstructObject
@@ -76,7 +77,6 @@
# Walls # Walls
- type: rcd - type: rcd
id: WallSolid id: WallSolid
name: rcd-component-wall-solid
category: WallsAndFlooring category: WallsAndFlooring
sprite: /Textures/Interface/Radial/RCD/solid_wall.png sprite: /Textures/Interface/Radial/RCD/solid_wall.png
mode: ConstructObject mode: ConstructObject
@@ -89,7 +89,6 @@
- type: rcd - type: rcd
id: Grille id: Grille
name: rcd-component-grille
category: WindowsAndGrilles category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/grille.png sprite: /Textures/Interface/Radial/RCD/grille.png
mode: ConstructObject mode: ConstructObject
@@ -103,7 +102,6 @@
# Windows # Windows
- type: rcd - type: rcd
id: Window id: Window
name: rcd-component-window
category: WindowsAndGrilles category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/window.png sprite: /Textures/Interface/Radial/RCD/window.png
mode: ConstructObject mode: ConstructObject
@@ -118,7 +116,6 @@
- type: rcd - type: rcd
id: WindowDirectional id: WindowDirectional
name: rcd-component-window-directional
category: WindowsAndGrilles category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/directional.png sprite: /Textures/Interface/Radial/RCD/directional.png
mode: ConstructObject mode: ConstructObject
@@ -134,7 +131,6 @@
- type: rcd - type: rcd
id: ReinforcedWindow id: ReinforcedWindow
name: rcd-component-reinforced-window
category: WindowsAndGrilles category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/window_reinforced.png sprite: /Textures/Interface/Radial/RCD/window_reinforced.png
mode: ConstructObject mode: ConstructObject
@@ -149,7 +145,6 @@
- type: rcd - type: rcd
id: WindowReinforcedDirectional id: WindowReinforcedDirectional
name: rcd-component-window-reinforced-directional
category: WindowsAndGrilles category: WindowsAndGrilles
sprite: /Textures/Interface/Radial/RCD/directional_reinforced.png sprite: /Textures/Interface/Radial/RCD/directional_reinforced.png
mode: ConstructObject mode: ConstructObject
@@ -166,7 +161,6 @@
# Airlocks # Airlocks
- type: rcd - type: rcd
id: Airlock id: Airlock
name: rcd-component-airlock
category: Airlocks category: Airlocks
sprite: /Textures/Interface/Radial/RCD/airlock.png sprite: /Textures/Interface/Radial/RCD/airlock.png
mode: ConstructObject mode: ConstructObject
@@ -179,7 +173,6 @@
- type: rcd - type: rcd
id: AirlockGlass id: AirlockGlass
name: rcd-component-airlock-glass
category: Airlocks category: Airlocks
sprite: /Textures/Interface/Radial/RCD/glass_airlock.png sprite: /Textures/Interface/Radial/RCD/glass_airlock.png
mode: ConstructObject mode: ConstructObject
@@ -192,7 +185,6 @@
- type: rcd - type: rcd
id: Firelock id: Firelock
name: rcd-component-firelock
category: Airlocks category: Airlocks
sprite: /Textures/Interface/Radial/RCD/firelock.png sprite: /Textures/Interface/Radial/RCD/firelock.png
mode: ConstructObject mode: ConstructObject
@@ -206,7 +198,6 @@
# Lighting # Lighting
- type: rcd - type: rcd
id: TubeLight id: TubeLight
name: rcd-component-tube-light
category: Lighting category: Lighting
sprite: /Textures/Interface/Radial/RCD/tube_light.png sprite: /Textures/Interface/Radial/RCD/tube_light.png
mode: ConstructObject mode: ConstructObject
@@ -220,7 +211,6 @@
- type: rcd - type: rcd
id: BulbLight id: BulbLight
name: rcd-component-window-bulb-light
category: Lighting category: Lighting
sprite: /Textures/Interface/Radial/RCD/bulb_light.png sprite: /Textures/Interface/Radial/RCD/bulb_light.png
mode: ConstructObject mode: ConstructObject
@@ -235,7 +225,6 @@
# Electrical # Electrical
- type: rcd - type: rcd
id: LVCable id: LVCable
name: rcd-component-window-lv-cable
category: Electrical category: Electrical
sprite: /Textures/Interface/Radial/RCD/lv_coil.png sprite: /Textures/Interface/Radial/RCD/lv_coil.png
mode: ConstructObject mode: ConstructObject
@@ -250,7 +239,6 @@
- type: rcd - type: rcd
id: MVCable id: MVCable
name: rcd-component-window-mv-cable
category: Electrical category: Electrical
sprite: /Textures/Interface/Radial/RCD/mv_coil.png sprite: /Textures/Interface/Radial/RCD/mv_coil.png
mode: ConstructObject mode: ConstructObject
@@ -265,7 +253,6 @@
- type: rcd - type: rcd
id: HVCable id: HVCable
name: rcd-component-window-hv-cable
category: Electrical category: Electrical
sprite: /Textures/Interface/Radial/RCD/hv_coil.png sprite: /Textures/Interface/Radial/RCD/hv_coil.png
mode: ConstructObject mode: ConstructObject
@@ -280,7 +267,6 @@
- type: rcd - type: rcd
id: CableTerminal id: CableTerminal
name: rcd-component-window-cable-terminal
category: Electrical category: Electrical
sprite: /Textures/Interface/Radial/RCD/cable_terminal.png sprite: /Textures/Interface/Radial/RCD/cable_terminal.png
mode: ConstructObject mode: ConstructObject