Skip to content

Commit

Permalink
Merge pull request space-syndicate#1787 from space-syndicate/upstream…
Browse files Browse the repository at this point in the history
…-sync

Upstream sync
  • Loading branch information
Morb0 authored Jan 21, 2024
2 parents df6f9e1 + eeb399f commit 0814705
Show file tree
Hide file tree
Showing 439 changed files with 19,193 additions and 15,509 deletions.
18 changes: 10 additions & 8 deletions Content.Client/Audio/AmbientSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
{
[Dependency] private readonly AmbientSoundTreeSystem _treeSys = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
Expand Down Expand Up @@ -172,7 +173,7 @@ public override void Update(float frameTime)

_targetTime = _gameTiming.CurTime+TimeSpan.FromSeconds(_cooldown);

var player = _playerManager.LocalPlayer?.ControlledEntity;
var player = _playerManager.LocalEntity;
if (!EntityManager.TryGetComponent(player, out TransformComponent? xform))
{
ClearSounds();
Expand All @@ -198,13 +199,13 @@ private readonly struct QueryState
public readonly Dictionary<string, List<(float Importance, AmbientSoundComponent)>> SourceDict = new();
public readonly Vector2 MapPos;
public readonly TransformComponent Player;
public readonly EntityQuery<TransformComponent> Query;
public readonly SharedTransformSystem TransformSystem;

public QueryState(Vector2 mapPos, TransformComponent player, EntityQuery<TransformComponent> query)
public QueryState(Vector2 mapPos, TransformComponent player, SharedTransformSystem transformSystem)
{
MapPos = mapPos;
Player = player;
Query = query;
TransformSystem = transformSystem;
}
}

Expand All @@ -218,7 +219,7 @@ private static bool Callback(

var delta = xform.ParentUid == state.Player.ParentUid
? xform.LocalPosition - state.Player.LocalPosition
: xform.WorldPosition - state.MapPos;
: state.TransformSystem.GetWorldPosition(xform) - state.MapPos;

var range = delta.Length();
if (range >= ambientComp.Range)
Expand All @@ -244,7 +245,7 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
{
var query = GetEntityQuery<TransformComponent>();
var metaQuery = GetEntityQuery<MetaDataComponent>();
var mapPos = playerXform.MapPosition;
var mapPos = _xformSystem.GetMapCoordinates(playerXform);

// Remove out-of-range ambiences
foreach (var (comp, sound) in _playingSounds)
Expand All @@ -258,9 +259,10 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
xform.MapID == playerXform.MapID &&
!metaQuery.GetComponent(entity).EntityPaused)
{
// TODO: This is just trydistance for coordinates.
var distance = (xform.ParentUid == playerXform.ParentUid)
? xform.LocalPosition - playerXform.LocalPosition
: xform.WorldPosition - mapPos.Position;
: _xformSystem.GetWorldPosition(xform) - mapPos.Position;

if (distance.LengthSquared() < comp.Range * comp.Range)
continue;
Expand All @@ -277,7 +279,7 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
return;

var pos = mapPos.Position;
var state = new QueryState(pos, playerXform, query);
var state = new QueryState(pos, playerXform, _xformSystem);
var worldAabb = new Box2(pos - MaxAmbientVector, pos + MaxAmbientVector);
_treeSys.QueryAabb(ref state, Callback, mapPos.MapId, worldAabb);

Expand Down
21 changes: 21 additions & 0 deletions Content.Client/Audio/BackgroundAudioSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Client.GameTicking.Managers;
using Content.Client.Lobby;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Client;
using Robust.Client.State;
Expand Down Expand Up @@ -39,6 +40,8 @@ public override void Initialize()
_client.PlayerLeaveServer += OnLeave;

_gameTicker.LobbySongUpdated += LobbySongUpdated;

SubscribeNetworkEvent<RoundRestartCleanupEvent>(PlayRestartSound);
}

public override void Shutdown()
Expand Down Expand Up @@ -129,4 +132,22 @@ private void EndLobbyMusic()
{
LobbyStream = _audio.Stop(LobbyStream);
}

private void PlayRestartSound(RoundRestartCleanupEvent ev)
{
if (!_configManager.GetCVar(CCVars.LobbyMusicEnabled))
return;

var file = _gameTicker.RestartSound;
if (string.IsNullOrEmpty(file))
{
return;
}

var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
SharedAudioSystem.GainToVolume(
_configManager.GetCVar(CCVars.LobbyMusicVolume)));

_audio.PlayGlobal(file, Filter.Local(), false, volume);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ protected override void Open()
base.Open();

var spriteSystem = EntMan.System<SpriteSystem>();
_menu = new CargoConsoleMenu(IoCManager.Resolve<IPrototypeManager>(), spriteSystem);
var localPlayer = IoCManager.Resolve<IPlayerManager>()?.LocalPlayer?.ControlledEntity;
var dependencies = IoCManager.Instance!;
_menu = new CargoConsoleMenu(Owner, EntMan, dependencies.Resolve<IPrototypeManager>(), spriteSystem);
var localPlayer = dependencies.Resolve<IPlayerManager>().LocalEntity;
var description = new FormattedMessage();

string orderRequester;
Expand Down
25 changes: 22 additions & 3 deletions Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using Content.Client.UserInterface.Controls;
using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using Content.Shared.Cargo.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
Expand All @@ -14,8 +15,10 @@ namespace Content.Client.Cargo.UI
[GenerateTypedNameReferences]
public sealed partial class CargoConsoleMenu : FancyWindow
{
private IEntityManager _entityManager;
private IPrototypeManager _protoManager;
private SpriteSystem _spriteSystem;
private EntityUid _owner;

public event Action<ButtonEventArgs>? OnItemSelected;
public event Action<ButtonEventArgs>? OnOrderApproved;
Expand All @@ -24,11 +27,13 @@ public sealed partial class CargoConsoleMenu : FancyWindow
private readonly List<string> _categoryStrings = new();
private string? _category;

public CargoConsoleMenu(IPrototypeManager protoManager, SpriteSystem spriteSystem)
public CargoConsoleMenu(EntityUid owner, IEntityManager entMan, IPrototypeManager protoManager, SpriteSystem spriteSystem)
{
RobustXamlLoader.Load(this);
_entityManager = entMan;
_protoManager = protoManager;
_spriteSystem = spriteSystem;
_owner = owner;

Title = Loc.GetString("cargo-console-menu-title");

Expand All @@ -53,7 +58,21 @@ private void SetCategoryText(int id)
Categories.SelectId(id);
}

public IEnumerable<CargoProductPrototype> ProductPrototypes => _protoManager.EnumeratePrototypes<CargoProductPrototype>();
public IEnumerable<CargoProductPrototype> ProductPrototypes
{
get
{
var allowedGroups = _entityManager.GetComponentOrNull<CargoOrderConsoleComponent>(_owner)?.AllowedGroups;

foreach (var cargoPrototype in _protoManager.EnumeratePrototypes<CargoProductPrototype>())
{
if (!allowedGroups?.Contains(cargoPrototype.Group) ?? false)
continue;

yield return cargoPrototype;
}
}
}

/// <summary>
/// Populates the list of products that will actually be shown, using the current filters.
Expand All @@ -80,7 +99,7 @@ public void PopulateProducts()
Product = prototype,
ProductName = { Text = prototype.Name },
MainButton = { ToolTip = prototype.Description },
PointCost = { Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", prototype.PointCost.ToString())) },
PointCost = { Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", prototype.Cost.ToString())) },
Icon = { Texture = _spriteSystem.Frame0(prototype.Icon) },
};
button.MainButton.OnPressed += args =>
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Cargo/UI/CargoPalletMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="300 150"
MinSize="300 150">
<BoxContainer Orientation="Vertical">
MinSize="300 150"
Title="{Loc 'cargo-pallet-console-menu-title'}">
<BoxContainer Orientation="Vertical" Margin="5">
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'cargo-pallet-menu-appraisal-label'}"
StyleClasses="LabelKeyText" />
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Cargo/UI/CargoPalletMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public CargoPalletMenu()
RobustXamlLoader.Load(this);
SellButton.OnPressed += OnSellPressed;
AppraiseButton.OnPressed += OnAppraisePressed;
Title = Loc.GetString("cargo-pallet-console-menu-title");
}

public void SetAppraisal(int amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private List<List<EntityUid>> GroupEntities(IEnumerable<EntityUid> entities, int
{
if (GroupingContextMenuType == 0)
{
var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager) + (_entityManager.GetComponent<MetaDataComponent>(e).EntityPrototype?.ID ?? string.Empty)).ToList();
var newEntities = entities.GroupBy(e => Identity.Name(e, _entityManager)).ToList();
return newEntities.Select(grp => grp.ToList()).ToList();
}
else
Expand Down
6 changes: 5 additions & 1 deletion Content.Client/ContextMenu/UI/EntityMenuUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Client.Verbs.UI;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Input;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -91,7 +92,10 @@ public void OpenRootMenu(List<EntityUid> entities)

var entitySpriteStates = GroupEntities(entities);
var orderedStates = entitySpriteStates.ToList();
orderedStates.Sort((x, y) => string.CompareOrdinal(_entityManager.GetComponent<MetaDataComponent>(x.First()).EntityPrototype?.Name, _entityManager.GetComponent<MetaDataComponent>(y.First()).EntityPrototype?.Name));
orderedStates.Sort((x, y) => string.Compare(
Identity.Name(x.First(), _entityManager),
Identity.Name(y.First(), _entityManager),
StringComparison.CurrentCulture));
Elements.Clear();
AddToUI(orderedStates);

Expand Down
2 changes: 2 additions & 0 deletions Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public sealed class ClientGameTicker : SharedGameTicker
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? LobbySong { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; }
Expand Down Expand Up @@ -151,6 +152,7 @@ private void RoundEnd(RoundEndMessageEvent message)
{
// Force an update in the event of this song being the same as the last.
SetLobbySong(message.LobbySong, true);
RestartSound = message.RestartSound;

// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Lathe/UI/LatheBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ protected override void UpdateState(BoundUserInterfaceState state)
case LatheUpdateState msg:
if (_menu != null)
_menu.Recipes = msg.Recipes;
_menu?.PopulateRecipes(Owner);
_menu?.PopulateRecipes();
_menu?.UpdateCategories();
_menu?.PopulateQueueList(msg.Queue);
_menu?.SetQueueInfo(msg.CurrentlyProducing);
break;
Expand Down
12 changes: 4 additions & 8 deletions Content.Client/Lathe/UI/LatheMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
PlaceHolder="{Loc 'lathe-menu-search-designs'}"
HorizontalExpand="True">
</LineEdit>
<Button
Name="FilterButton"
Text="{Loc 'lathe-menu-search-filter'}"
TextAlign="Center"
Margin="5 0 0 0"
Disabled="True"
StyleClasses="ButtonSquare">
</Button>
<OptionButton
Name="FilterOption"
MinWidth="100"
StyleClasses="ButtonSquare"/>
</BoxContainer>
<BoxContainer Orientation="Vertical"
MinHeight="225"
Expand Down
Loading

0 comments on commit 0814705

Please sign in to comment.