Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 77 additions & 5 deletions Content.Client/RCD/RCDConstructionGhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
// Starlight Start
using Robust.Shared.Input;
using Content.Client._Starlight.RCD;
using Robust.Shared.Input.Binding;
using Content.Client.Atmos;
using Content.Shared.Input;
// Starlight End

namespace Content.Client.RCD;

Expand All @@ -15,6 +22,7 @@ namespace Content.Client.RCD;
public sealed class RCDConstructionGhostSystem : EntitySystem
{
private const string PlacementMode = nameof(AlignRCDConstruction);
private const string RpdPlacementMode = nameof(AlignRPDAtmosPipeLayers); // Starlight RPD

[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
Expand All @@ -23,6 +31,51 @@ public sealed class RCDConstructionGhostSystem : EntitySystem

private Direction _placementDirection = default;

// Starlight Start: RPD
private bool _useMirrorPrototype = false;
public event EventHandler? FlipConstructionPrototype;

public override void Initialize()
{
base.Initialize();

// bind key
CommandBinds.Builder
.Bind(ContentKeyFunctions.EditorFlipObject,
new PointerInputCmdHandler(HandleFlip, outsidePrediction: true))
.Register<RCDConstructionGhostSystem>();
}

public override void Shutdown()
{
CommandBinds.Unregister<RCDConstructionGhostSystem>();
base.Shutdown();
}

private bool HandleFlip(in PointerInputCmdHandler.PointerInputCmdArgs args)
{
if (args.State == BoundKeyState.Down)
{
if (!_placementManager.IsActive || _placementManager.Eraser)
return false;

var placerEntity = _placementManager.CurrentPermission?.MobUid;

if (!TryComp<RCDComponent>(placerEntity, out var rcd) ||
string.IsNullOrEmpty(rcd.CachedPrototype.MirrorPrototype))
return false;

_useMirrorPrototype = !rcd.UseMirrorPrototype;

// tell the server

RaiseNetworkEvent(new RCDConstructionGhostFlipEvent(GetNetEntity(placerEntity.Value), _useMirrorPrototype));
}

return true;
}
// Starlight End: RPD

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand Down Expand Up @@ -55,7 +108,20 @@ public override void Update(float frameTime)

return;
}
var prototype = _protoManager.Index(rcd.ProtoId);
// Starlight edit Start: RPD - use the mirrored prototype if the flip state is toggled on
// var prototype = _protoManager.Index(rcd.ProtoId);

// Determine if mirrored
var cachedProto = rcd.CachedPrototype;
var wantMirror = _useMirrorPrototype && !string.IsNullOrEmpty(cachedProto.MirrorPrototype);
var prototype = wantMirror ? cachedProto.MirrorPrototype : cachedProto.Prototype;

bool isLayered = rcd.IsRpd
&& _protoManager.TryIndex<RCDPrototype>(cachedProto.ID, out var rcdProto)
&& rcdProto.HasLayers;

var desiredMode = isLayered ? RpdPlacementMode : PlacementMode;
// Starlight edit End: RPD - use the mirrored prototype if the flip state is toggled on

// Update the direction the RCD prototype based on the placer direction
if (_placementDirection != _placementManager.Direction)
Expand All @@ -65,17 +131,23 @@ public override void Update(float frameTime)
}

// If the placer has not changed, exit
if (heldEntity == placerEntity && prototype.Prototype == placerProto)
// Starlight edit Start
if (heldEntity == placerEntity &&
prototype == placerProto &&
_placementManager.CurrentPermission?.PlacementOption == desiredMode)
// Starlight edit End
return;
//if (heldEntity == placerEntity && prototype.Prototype == placerProto)
// return;

// Create a new placer
var newObjInfo = new PlacementInformation
{
MobUid = heldEntity.Value,
PlacementOption = PlacementMode,
EntityType = prototype.Prototype,
PlacementOption = desiredMode, // Starlight Edit: PlacementMode -> desiredMode
EntityType = prototype, // Starlight Edit: prototype.Prototype -> prototype
Range = (int)Math.Ceiling(SharedInteractionSystem.InteractionRange),
IsTile = (prototype.Mode == RcdMode.ConstructTile),
IsTile = (cachedProto.Mode == RcdMode.ConstructTile), // Starlight Edit: prototype.Mode -> cachedProto.Mode
UseEditorContext = false,
};

Expand Down
9 changes: 9 additions & 0 deletions Content.Client/RCD/RCDMenuBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ public sealed class RCDMenuBoundUserInterface : BoundUserInterface
["Airlocks"] = ("rcd-component-airlocks", new SpriteSpecifier.Texture(new ResPath("/Textures/_DV/Interface/Radial/RCD/airlocks.png"))), // DeltaV - Path changed to new sprites reflecting Delta-V resprites
["Electrical"] = ("rcd-component-electrical", new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/Radial/RCD/multicoil.png"))),
["Lighting"] = ("rcd-component-lighting", new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/Radial/RCD/lighting.png"))),
// Starlight Start: RPD
["Piping"] = ("rpd-component-piping", new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/Radial/RPD/fourway.png"))),
["AtmosphericUtility"] = ("rpd-component-atmosphericutility", new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/Radial/RPD/port.png"))),
["PumpsValves"] = ("rpd-component-pumps", new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/Radial/RPD/pump_volume.png"))),
["Vents"] = ("rpd-component-vents", new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/Radial/RPD/vent_passive.png"))),
["SensorsMonitors"] = ("rpd-component-sensors-monitors", new SpriteSpecifier.Texture(new ResPath("/Textures/_Starlight/Interface/Radial/RPD/airalarm.png"))),
// Starlight End: RPD
};

private bool IsRpd => EntMan.TryGetComponent<RCDComponent>(Owner, out var rcd) && rcd.IsRpd; // Starlight: RPD

[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;

Expand Down
Loading
Loading