-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from SpicyDarkFox/perenos
Переезд
- Loading branch information
Showing
187 changed files
with
7,122 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
Content.Client/_LostParadise/RCDFAP/AlignRCDFAPConstruction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using System.Numerics; | ||
using Content.Client.Gameplay; | ||
using Content.Shared.Hands.Components; | ||
using Content.Shared.Interaction; | ||
using Content.Shared._LostParadise.RCDFAP.Components; | ||
using Content.Shared._LostParadise.RCDFAP.Systems; | ||
using Robust.Client.Placement; | ||
using Robust.Client.Player; | ||
using Robust.Client.State; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Map.Components; | ||
|
||
namespace Content.Client._LostParadise.RCDFAP; | ||
|
||
public sealed class AlignRCDFAPConstruction : PlacementMode | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
private readonly SharedMapSystem _mapSystem; | ||
private readonly RCDFAPSystem _rcdfapSystem; | ||
private readonly SharedTransformSystem _transformSystem; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] private readonly IStateManager _stateManager = default!; | ||
|
||
private const float SearchBoxSize = 2f; | ||
private const float PlaceColorBaseAlpha = 0.5f; | ||
|
||
private EntityCoordinates _unalignedMouseCoords = default; | ||
|
||
/// <summary> | ||
/// This placement mode is not on the engine because it is content specific (i.e., for the RCDFAP) | ||
/// </summary> | ||
public AlignRCDFAPConstruction(PlacementManager pMan) : base(pMan) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_mapSystem = _entityManager.System<SharedMapSystem>(); | ||
_rcdfapSystem = _entityManager.System<RCDFAPSystem>(); | ||
_transformSystem = _entityManager.System<SharedTransformSystem>(); | ||
|
||
ValidPlaceColor = ValidPlaceColor.WithAlpha(PlaceColorBaseAlpha); | ||
} | ||
|
||
public override void AlignPlacementMode(ScreenCoordinates mouseScreen) | ||
{ | ||
_unalignedMouseCoords = ScreenToCursorGrid(mouseScreen); | ||
MouseCoords = _unalignedMouseCoords.AlignWithClosestGridTile(SearchBoxSize, _entityManager, _mapManager); | ||
|
||
var gridId = MouseCoords.GetGridUid(_entityManager); | ||
|
||
if (!_entityManager.TryGetComponent<MapGridComponent>(gridId, out var mapGrid)) | ||
return; | ||
|
||
CurrentTile = _mapSystem.GetTileRef(gridId.Value, mapGrid, MouseCoords); | ||
|
||
float tileSize = mapGrid.TileSize; | ||
GridDistancing = tileSize; | ||
|
||
if (pManager.CurrentPermission!.IsTile) | ||
{ | ||
MouseCoords = new EntityCoordinates(MouseCoords.EntityId, new Vector2(CurrentTile.X + tileSize / 2, | ||
CurrentTile.Y + tileSize / 2)); | ||
} | ||
else | ||
{ | ||
MouseCoords = new EntityCoordinates(MouseCoords.EntityId, new Vector2(CurrentTile.X + tileSize / 2 + pManager.PlacementOffset.X, | ||
CurrentTile.Y + tileSize / 2 + pManager.PlacementOffset.Y)); | ||
} | ||
} | ||
|
||
public override bool IsValidPosition(EntityCoordinates position) | ||
{ | ||
var player = _playerManager.LocalSession?.AttachedEntity; | ||
|
||
// If the destination is out of interaction range, set the placer alpha to zero | ||
if (!_entityManager.TryGetComponent<TransformComponent>(player, out var xform)) | ||
return false; | ||
|
||
if (!xform.Coordinates.InRange(_entityManager, _transformSystem, position, SharedInteractionSystem.InteractionRange)) | ||
{ | ||
InvalidPlaceColor = InvalidPlaceColor.WithAlpha(0); | ||
return false; | ||
} | ||
|
||
// Otherwise restore the alpha value | ||
else | ||
{ | ||
InvalidPlaceColor = InvalidPlaceColor.WithAlpha(PlaceColorBaseAlpha); | ||
} | ||
|
||
// Determine if player is carrying an RCDFAP in their active hand | ||
if (!_entityManager.TryGetComponent<HandsComponent>(player, out var hands)) | ||
return false; | ||
|
||
var heldEntity = hands.ActiveHand?.HeldEntity; | ||
|
||
if (!_entityManager.TryGetComponent<RCDFAPComponent>(heldEntity, out var rcdfap)) | ||
return false; | ||
|
||
// Retrieve the map grid data for the position | ||
if (!_rcdfapSystem.TryGetMapGridData(position, out var mapGridData)) | ||
return false; | ||
|
||
// Determine if the user is hovering over a target | ||
var currentState = _stateManager.CurrentState; | ||
|
||
if (currentState is not GameplayStateBase screen) | ||
return false; | ||
|
||
var target = screen.GetClickedEntity(_unalignedMouseCoords.ToMap(_entityManager, _transformSystem)); | ||
|
||
// Determine if the RCDFAP operation is valid or not | ||
if (!_rcdfapSystem.IsRCDFAPOperationStillValid(heldEntity.Value, rcdfap, mapGridData.Value, target, player.Value, false)) | ||
return false; | ||
|
||
return true; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
Content.Client/_LostParadise/RCDFAP/RCDFAPConstructionGhostSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Content.Shared.Hands.Components; | ||
using Content.Shared.Interaction; | ||
using Content.Shared._LostParadise.RCDFAP; | ||
using Content.Shared._LostParadise.RCDFAP.Components; | ||
using Content.Shared._LostParadise.RCDFAP.Systems; | ||
using Robust.Client.Placement; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
|
||
namespace Content.Client._LostParadise.RCDFAP; | ||
|
||
public sealed class RCDFAPConstructionGhostSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] private readonly RCDFAPSystem _rcdfapSystem = default!; | ||
[Dependency] private readonly IPlacementManager _placementManager = default!; | ||
|
||
private string _placementMode = typeof(AlignRCDFAPConstruction).Name; | ||
private Direction _placementDirection = default; | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
// Get current placer data | ||
var placerEntity = _placementManager.CurrentPermission?.MobUid; | ||
var placerProto = _placementManager.CurrentPermission?.EntityType; | ||
var placerIsRCDFAP = HasComp<RCDFAPComponent>(placerEntity); | ||
|
||
// Exit if erasing or the current placer is not an RCDFAP (build mode is active) | ||
if (_placementManager.Eraser || (placerEntity != null && !placerIsRCDFAP)) | ||
return; | ||
|
||
// Determine if player is carrying an RCDFAP in their active hand | ||
var player = _playerManager.LocalSession?.AttachedEntity; | ||
|
||
if (!TryComp<HandsComponent>(player, out var hands)) | ||
return; | ||
|
||
var heldEntity = hands.ActiveHand?.HeldEntity; | ||
|
||
if (!TryComp<RCDFAPComponent>(heldEntity, out var rcdfap)) | ||
{ | ||
// If the player was holding an RCDFAP, but is no longer, cancel placement | ||
if (placerIsRCDFAP) | ||
_placementManager.Clear(); | ||
|
||
return; | ||
} | ||
|
||
// Update the direction the RCDFAP prototype based on the placer direction | ||
if (_placementDirection != _placementManager.Direction) | ||
{ | ||
_placementDirection = _placementManager.Direction; | ||
RaiseNetworkEvent(new RCDFAPConstructionGhostRotationEvent(GetNetEntity(heldEntity.Value), _placementDirection)); | ||
} | ||
|
||
// If the placer has not changed, exit | ||
_rcdfapSystem.UpdateCachedPrototype(heldEntity.Value, rcdfap); | ||
|
||
if (heldEntity == placerEntity && rcdfap.CachedPrototype.Prototype == placerProto) | ||
return; | ||
|
||
// Create a new placer | ||
var newObjInfo = new PlacementInformation | ||
{ | ||
MobUid = heldEntity.Value, | ||
PlacementOption = _placementMode, | ||
EntityType = rcdfap.CachedPrototype.Prototype, | ||
Range = (int) Math.Ceiling(SharedInteractionSystem.InteractionRange), | ||
UseEditorContext = false, | ||
}; | ||
|
||
_placementManager.Clear(); | ||
_placementManager.BeginPlacing(newObjInfo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<ui:RadialMenu xmlns="https://spacestation14.io" | ||
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:rcdfap="clr-namespace:Content.Client._LostParadise.RCDFAP" | ||
BackButtonStyleClass="RadialMenuBackButton" | ||
CloseButtonStyleClass="RadialMenuCloseButton" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" | ||
MinSize="450 450"> | ||
|
||
<!-- Note: The min size of the window just determine how close to the edge of the screen the center of the radial menu can be placed --> | ||
<!-- The radial menu will try to open so that its center is located where the player's cursor is currently --> | ||
|
||
<!-- Entry layer (shows main categories) --> | ||
<ui:RadialContainer Name="Main" VerticalExpand="True" HorizontalExpand="True" Radius="64" ReserveSpaceForHiddenChildren="False"> | ||
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'rcd-component-DisposalPipe'}" TargetLayer="DisposalPipe" Visible="False"> | ||
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/LPP/Interface/Radial/RCDFAP/DisposalPipe.png"/> | ||
</ui:RadialMenuTextureButton> | ||
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'rcd-component-Gaspipes'}" TargetLayer="Gaspipes" Visible="False"> | ||
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/LPP/Interface/Radial/RCDFAP/Gaspipes.png"/> | ||
</ui:RadialMenuTextureButton> | ||
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'rcd-component-Devices'}" TargetLayer="Devices" Visible="False"> | ||
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/LPP/Interface/Radial/RCDFAP/Devices.png"/> | ||
</ui:RadialMenuTextureButton> | ||
</ui:RadialContainer> | ||
|
||
<!-- DisposalPipe --> | ||
<ui:RadialContainer Name="DisposalPipe" VerticalExpand="True" HorizontalExpand="True" Radius="64"/> | ||
|
||
<!-- Gaspipes --> | ||
<ui:RadialContainer Name="Gaspipes" VerticalExpand="True" HorizontalExpand="True" Radius="64"/> | ||
|
||
<!-- Devices --> | ||
<ui:RadialContainer Name="Devices" VerticalExpand="True" HorizontalExpand="True" Radius="64"/> | ||
|
||
</ui:RadialMenu> |
Oops, something went wrong.