Skip to content

Commit

Permalink
Merge pull request #4 from SpicyDarkFox/perenos
Browse files Browse the repository at this point in the history
Переезд
  • Loading branch information
Evgencheg authored Aug 12, 2024
2 parents d26f880 + 239c67a commit 2792de9
Show file tree
Hide file tree
Showing 187 changed files with 7,122 additions and 13 deletions.
19 changes: 17 additions & 2 deletions Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Chat;
using Content.Shared.Chat;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.Corvax.TTS;
using Robust.Client.Audio;
Expand All @@ -9,6 +9,7 @@
using Robust.Shared.ContentPack;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using Content.Client.Language.Systems;

namespace Content.Client.Corvax.TTS;

Expand All @@ -21,6 +22,8 @@ public sealed class TTSSystem : EntitySystem
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
[Dependency] private readonly LanguageSystem _language = default!;

private ISawmill _sawmill = default!;
private readonly MemoryContentRoot _contentRoot = new();
Expand Down Expand Up @@ -71,7 +74,19 @@ private void OnPlayTTS(PlayTTSEvent ev)
var volume = AdjustVolume(ev.IsWhisper);

var filePath = new ResPath($"{_fileIdx++}.ogg");
_contentRoot.AddOrUpdateFile(filePath, ev.Data);
//_contentRoot.AddOrUpdateFile(filePath, ev.Data);
// Languages TTS support start
var player = _playerManager.LocalSession?.AttachedEntity;
if (player != null)
{
if (_language.UnderstoodLanguages.Contains(ev.LanguageProtoId))
_contentRoot.AddOrUpdateFile(filePath, ev.Data);
else
_contentRoot.AddOrUpdateFile(filePath, ev.LanguageData);
}
else
_contentRoot.AddOrUpdateFile(filePath, ev.Data);
// Languages TTS support end

var audioParams = AudioParams.Default.WithVolume(volume);
var soundPath = new SoundPathSpecifier(Prefix / filePath, audioParams);
Expand Down
117 changes: 117 additions & 0 deletions Content.Client/_LostParadise/RCDFAP/AlignRCDFAPConstruction.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._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;
}
}
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);
}
}
35 changes: 35 additions & 0 deletions Content.Client/_LostParadise/RCDFAP/RCDFAPMenu.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: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>
Loading

0 comments on commit 2792de9

Please sign in to comment.