Skip to content

Commit

Permalink
Merge branch 'master' into urss
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Aug 4, 2024
2 parents 2dc3e64 + 5845725 commit 9af3c67
Show file tree
Hide file tree
Showing 433 changed files with 37,698 additions and 23,844 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ jobs:
- uses: actions/[email protected]
with:
submodules: 'recursive'

# Corvax-Secrets-Start
- name: Setup secrets
env:
SSH_KEY: ${{ secrets.SECRETS_PRIVATE_KEY }}
if: ${{ env.SSH_KEY != '' }}
run: |
mkdir ~/.ssh
echo "${{ secrets.SECRETS_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "HOST *" > ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
git clone [email protected]:corvax-nexus/secrets.git Secrets
cp -R Secrets/Resources/Prototypes Resources/Prototypes/CorvaxSecrets
cp -R Secrets/Resources/ServerPrototypes Resources/Prototypes/CorvaxSecretsServer
cp -R Secrets/Resources/Locale Resources/Locale/ru-RU/corvax-secrets
cp -R Secrets/Resources/Textures Resources/Textures/CorvaxSecrets
# Corvax-Secrets-End

- name: Setup .NET Core
uses: actions/[email protected]
with:
Expand Down
117 changes: 117 additions & 0 deletions Content.Client/ADT/RPD/AlignRPDConstruction.cs
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.ADT.RPD.Components;
using Content.Shared.ADT.RPD.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.ADT.RPD;

public sealed class AlignRPDConstruction : PlacementMode
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private readonly SharedMapSystem _mapSystem;
private readonly RPDSystem _rpdSystem;
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 RPD)
/// </summary>
public AlignRPDConstruction(PlacementManager pMan) : base(pMan)
{
IoCManager.InjectDependencies(this);
_mapSystem = _entityManager.System<SharedMapSystem>();
_rpdSystem = _entityManager.System<RPDSystem>();
_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 RPD in their active hand
if (!_entityManager.TryGetComponent<HandsComponent>(player, out var hands))
return false;

var heldEntity = hands.ActiveHand?.HeldEntity;

if (!_entityManager.TryGetComponent<RPDComponent>(heldEntity, out var rpd))
return false;

// Retrieve the map grid data for the position
if (!_rpdSystem.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 RPD operation is valid or not
if (!_rpdSystem.IsRPDOperationStillValid(heldEntity.Value, rpd, mapGridData.Value, target, player.Value, false))
return false;

return true;
}
}
77 changes: 77 additions & 0 deletions Content.Client/ADT/RPD/RPDConstructionGhostSystem.cs
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.ADT.RPD;
using Content.Shared.ADT.RPD.Components;
using Content.Shared.ADT.RPD.Systems;
using Robust.Client.Placement;
using Robust.Client.Player;
using Robust.Shared.Enums;

namespace Content.Client.ADT.RPD;

public sealed class RPDConstructionGhostSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly RPDSystem _rpdSystem = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;

private string _placementMode = typeof(AlignRPDConstruction).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 placerIsRPD = HasComp<RPDComponent>(placerEntity);

// Exit if erasing or the current placer is not an RPD (build mode is active)
if (_placementManager.Eraser || (placerEntity != null && !placerIsRPD))
return;

// Determine if player is carrying an RPD in their active hand
var player = _playerManager.LocalSession?.AttachedEntity;

if (!TryComp<HandsComponent>(player, out var hands))
return;

var heldEntity = hands.ActiveHand?.HeldEntity;

if (!TryComp<RPDComponent>(heldEntity, out var rpd))
{
// If the player was holding an RPD, but is no longer, cancel placement
if (placerIsRPD)
_placementManager.Clear();

return;
}

// Update the direction the RPD prototype based on the placer direction
if (_placementDirection != _placementManager.Direction)
{
_placementDirection = _placementManager.Direction;
RaiseNetworkEvent(new RPDConstructionGhostRotationEvent(GetNetEntity(heldEntity.Value), _placementDirection));
}

// If the placer has not changed, exit
_rpdSystem.UpdateCachedPrototype(heldEntity.Value, rpd);

if (heldEntity == placerEntity && rpd.CachedPrototype.Prototype == placerProto)
return;

// Create a new placer
var newObjInfo = new PlacementInformation
{
MobUid = heldEntity.Value,
PlacementOption = _placementMode,
EntityType = rpd.CachedPrototype.Prototype,
Range = (int) Math.Ceiling(SharedInteractionSystem.InteractionRange),
UseEditorContext = false,
};

_placementManager.Clear();
_placementManager.BeginPlacing(newObjInfo);
}
}
35 changes: 35 additions & 0 deletions Content.Client/ADT/RPD/RPDMenu.xaml
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:rpd="clr-namespace:Content.Client.RPD"
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 'rpd-component-DisposalPipe'}" TargetLayer="DisposalPipe" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/ADT/Interface/Radial/RPD/DisposalPipe.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'rpd-component-Gaspipes'}" TargetLayer="Gaspipes" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/ADT/Interface/Radial/RPD/Gaspipes.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'rpd-component-Devices'}" TargetLayer="Devices" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/ADT/Interface/Radial/RPD/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>
Loading

0 comments on commit 9af3c67

Please sign in to comment.