fix RCD ghosts not disappearing when changing hand to empty (#38622)

This commit is contained in:
slarticodefast
2025-06-27 18:39:49 +02:00
committed by GitHub
parent 5bc778d42e
commit 6be925ab91

View File

@@ -1,9 +1,7 @@
using Content.Client.Hands.Systems;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.RCD;
using Content.Shared.RCD.Components;
using Content.Shared.RCD.Systems;
using Robust.Client.Placement;
using Robust.Client.Player;
using Robust.Shared.Enums;
@@ -11,14 +9,18 @@ using Robust.Shared.Prototypes;
namespace Content.Client.RCD;
/// <summary>
/// System for handling structure ghost placement in places where RCD can create objects.
/// </summary>
public sealed class RCDConstructionGhostSystem : EntitySystem
{
private const string PlacementMode = nameof(AlignRCDConstruction);
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly HandsSystem _hands = default!;
private string _placementMode = typeof(AlignRCDConstruction).Name;
private Direction _placementDirection = default;
public override void Update(float frameTime)
@@ -38,8 +40,7 @@ public sealed class RCDConstructionGhostSystem : EntitySystem
if (_playerManager.LocalSession?.AttachedEntity is not { } player)
return;
if (!_hands.TryGetActiveItem(player, out var heldEntity))
return;
var heldEntity = _hands.GetActiveItem(player);
if (!TryComp<RCDComponent>(heldEntity, out var rcd))
{
@@ -66,7 +67,7 @@ public sealed class RCDConstructionGhostSystem : EntitySystem
var newObjInfo = new PlacementInformation
{
MobUid = heldEntity.Value,
PlacementOption = _placementMode,
PlacementOption = PlacementMode,
EntityType = prototype.Prototype,
Range = (int) Math.Ceiling(SharedInteractionSystem.InteractionRange),
IsTile = (prototype.Mode == RcdMode.ConstructTile),