Skip to content

Commit

Permalink
Merge pull request #1626 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Dec 11, 2023
2 parents e771d8e + f74957c commit 5e1f077
Show file tree
Hide file tree
Showing 499 changed files with 131,085 additions and 298,674 deletions.
11 changes: 7 additions & 4 deletions Content.Client/Audio/BackgroundAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace Content.Client.Audio;
[UsedImplicitly]
public sealed class BackgroundAudioSystem : EntitySystem
{
/*
* TODO: Nuke this system and merge into contentaudiosystem
*/
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
Expand All @@ -22,7 +25,7 @@ public sealed class BackgroundAudioSystem : EntitySystem

private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);

private EntityUid? _lobbyStream;
public EntityUid? LobbyStream;

public override void Initialize()
{
Expand Down Expand Up @@ -109,7 +112,7 @@ public void RestartLobbyMusic()

public void StartLobbyMusic()
{
if (_lobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
if (LobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
return;

var file = _gameTicker.LobbySong;
Expand All @@ -118,12 +121,12 @@ public void StartLobbyMusic()
return;
}

_lobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
LobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume))))?.Entity;
}

private void EndLobbyMusic()
{
_lobbyStream = _audio.Stop(_lobbyStream);
LobbyStream = _audio.Stop(LobbyStream);
}
}
2 changes: 1 addition & 1 deletion Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void UpdateAmbientMusic()
// Update still runs in lobby so just ignore it.
if (_state.CurrentState is not GameplayState)
{
FadeOut(_ambientMusicStream);
Audio.Stop(_ambientMusicStream);
_ambientMusicStream = null;
_musicProto = null;
return;
Expand Down
19 changes: 19 additions & 0 deletions Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Audio;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Shared;
using Robust.Shared.Audio;
Expand Down Expand Up @@ -38,6 +39,24 @@ public override void Initialize()
base.Initialize();
UpdatesOutsidePrediction = true;
InitializeAmbientMusic();
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundCleanup);
}

private void OnRoundCleanup(RoundRestartCleanupEvent ev)
{
_fadingOut.Clear();

// Preserve lobby music but everything else should get dumped.
var lobbyStream = EntityManager.System<BackgroundAudioSystem>().LobbyStream;
TryComp(lobbyStream, out AudioComponent? audioComp);
var oldGain = audioComp?.Gain;

SilenceAudio();

if (oldGain != null)
{
Audio.SetGain(lobbyStream, oldGain.Value, audioComp);
}
}

public override void Shutdown()
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Eye/Blinding/BlurryVisionOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected override void Draw(in OverlayDrawArgs args)
// Maybe gradually shrink the view-size?
// Make the effect only apply to the edge of the viewport?
// Actually make it blurry??
var opacity = 0.75f * _magnitude / BlurryVisionComponent.MaxMagnitude;
var opacity = 1f * _magnitude / BlurryVisionComponent.MaxMagnitude;
var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
Expand Down
9 changes: 3 additions & 6 deletions Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,17 +706,14 @@ public void SendMessage(ChatBox box, ChatSelectChannel channel)

private void OnDamageForceSay(DamageForceSayEvent ev, EntitySessionEventArgs _)
{
if (UIManager.ActiveScreen?.GetWidget<ChatBox>() is not { } chatBox)
return;

var chatBox = UIManager.ActiveScreen?.GetWidget<ChatBox>() ?? UIManager.ActiveScreen?.GetWidget<ResizableChatBox>();
// Don't send on OOC/LOOC obviously!
if (chatBox.SelectedChannel is not
(ChatSelectChannel.Local or
if (chatBox?.SelectedChannel is not (ChatSelectChannel.Local or
ChatSelectChannel.Radio or
ChatSelectChannel.Whisper))
return;

if (_player.LocalPlayer?.ControlledEntity is not { } ent
if (_player.LocalSession?.AttachedEntity is not { } ent
|| !EntityManager.TryGetComponent<DamageForceSayComponent>(ent, out var forceSay))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public sealed class HandsContainer : ItemSlotUIContainer<HandButton>
public int ColumnLimit { get => _grid.Columns; set => _grid.Columns = value; }
public int MaxButtonCount { get; set; } = 0;

public int MaxButtonsPerRow { get; set; }= 6;

/// <summary>
/// Indexer. This is used to reference a HandsContainer from the
/// controller.
Expand All @@ -36,6 +38,7 @@ public HandsContainer()
_grid.AddChild(newButton);
}

_grid.Columns = Math.Min(_grid.ChildCount, MaxButtonsPerRow);
return base.AddButton(newButton);
}

Expand Down
67 changes: 37 additions & 30 deletions Content.Client/UserInterface/Systems/Hotbar/Widgets/HotbarGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,46 @@
Visible="False"/>
</BoxContainer>
</Control>
<inventory:ItemSlotButtonContainer
Name="InventoryHotbar"
Access="Public"
Visible="False"
Columns="10"
SlotGroup="Default"
ExpandBackwards="True"
VerticalExpand="True"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
/>
<BoxContainer Orientation="Horizontal" Name="Hotbar">
<BoxContainer Orientation="Vertical">
<inventory:ItemSlotButtonContainer
Name="SecondHotbar"
SlotGroup="SecondHotbar"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
VerticalExpand="False"
Columns="6"
HorizontalExpand="True"/>
<hands:HandsContainer
Name="HandContainer"
Name="InventoryHotbar"
Access="Public"
Visible="False"
Columns="10"
SlotGroup="Default"
ExpandBackwards="True"
VerticalExpand="True"
HorizontalAlignment="Center"
ColumnLimit="6" />
<inventory:ItemSlotButtonContainer
Name="MainHotbar"
SlotGroup="MainHotbar"
VerticalExpand="False"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
HorizontalExpand="True"
Columns="6"
/>
Margin="0 0 0 4"
/>
<BoxContainer Orientation="Horizontal" Name="Hotbar" HorizontalAlignment="Center">
<inventory:ItemSlotButtonContainer
Name="SecondHotbar"
SlotGroup="SecondHotbar"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
VerticalExpand="False"
ExpandBackwards="True"
Columns="6"
HorizontalExpand="False"/>
<hands:HandsContainer
Name="HandContainer"
Access="Public"
HorizontalAlignment="Center"
HorizontalExpand="False"
ColumnLimit="6"
Margin="4 0 4 0"/>
<inventory:ItemSlotButtonContainer
Name="MainHotbar"
SlotGroup="MainHotbar"
VerticalExpand="False"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
HorizontalExpand="False"
ExpandBackwards="True"
Columns="6"
/>
</BoxContainer>
</BoxContainer>
</widgets:HotbarGui>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public bool TryAddButton(SlotControl control)
{
if (!Children.Contains(newButton) && newButton.Parent == null && newButton.SlotName != "")
AddChild(newButton);
Columns = ChildCount;
return AddButtonToDict(newButton);
}

Expand Down
1 change: 0 additions & 1 deletion Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public sealed class PostMapInitTest
"Saltern",
"Core",
"Marathon",
"Kettle",
"Gemini",
"MeteorArena",
"Atlas"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
using Microsoft.EntityFrameworkCore;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.UnitTesting;

namespace Content.IntegrationTests.Tests.Preferences
{
Expand Down Expand Up @@ -70,20 +72,22 @@ private static HumanoidCharacterProfile CharlieCharlieson()
);
}

private static ServerDbSqlite GetDb(IConfigurationManager cfgManager)
private static ServerDbSqlite GetDb(RobustIntegrationTest.ServerIntegrationInstance server)
{
var cfg = server.ResolveDependency<IConfigurationManager>();
var opsLog = server.ResolveDependency<ILogManager>().GetSawmill("db.ops");
var builder = new DbContextOptionsBuilder<SqliteServerDbContext>();
var conn = new SqliteConnection("Data Source=:memory:");
conn.Open();
builder.UseSqlite(conn);
return new ServerDbSqlite(() => builder.Options, true, cfgManager, true);
return new ServerDbSqlite(() => builder.Options, true, cfg, true, opsLog);
}

[Test]
public async Task TestUserDoesNotExist()
{
var pair = await PoolManager.GetServerClient();
var db = GetDb(pair.Server.ResolveDependency<IConfigurationManager>());
var db = GetDb(pair.Server);
// Database should be empty so a new GUID should do it.
Assert.Null(await db.GetPlayerPreferencesAsync(NewUserId()));

Expand All @@ -94,7 +98,7 @@ public async Task TestUserDoesNotExist()
public async Task TestInitPrefs()
{
var pair = await PoolManager.GetServerClient();
var db = GetDb(pair.Server.ResolveDependency<IConfigurationManager>());
var db = GetDb(pair.Server);
var username = new NetUserId(new Guid("640bd619-fc8d-4fe2-bf3c-4a5fb17d6ddd"));
const int slot = 0;
var originalProfile = CharlieCharlieson();
Expand All @@ -109,7 +113,7 @@ public async Task TestDeleteCharacter()
{
var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var db = GetDb(server.ResolveDependency<IConfigurationManager>());
var db = GetDb(server);
var username = new NetUserId(new Guid("640bd619-fc8d-4fe2-bf3c-4a5fb17d6ddd"));
await db.InitPrefsAsync(username, new HumanoidCharacterProfile());
await db.SaveCharacterSlotAsync(username, CharlieCharlieson(), 1);
Expand Down
25 changes: 12 additions & 13 deletions Content.Server/Animals/Components/EggLayerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using Content.Shared.Storage;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Animals.Components;

/// <summary>
/// This component handles animals which lay eggs (or some other item) on a timer, using up hunger to do so.
/// It also grants an action to players who are controlling these entities, allowing them to do it manually.
/// </summary>

[RegisterComponent]
public sealed partial class EggLayerComponent : Component
{
[DataField("eggLayAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string EggLayAction = "ActionAnimalLayEgg";
[DataField]
public EntProtoId EggLayAction = "ActionAnimalLayEgg";

[ViewVariables(VVAccess.ReadWrite)]
[DataField("hungerUsage")]
/// <summary>
/// The amount of nutrient consumed on update.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float HungerUsage = 60f;

/// <summary>
/// Minimum cooldown used for the automatic egg laying.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("eggLayCooldownMin")]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float EggLayCooldownMin = 60f;

/// <summary>
/// Maximum cooldown used for the automatic egg laying.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("eggLayCooldownMax")]
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float EggLayCooldownMax = 120f;

/// <summary>
Expand All @@ -39,14 +39,13 @@ public sealed partial class EggLayerComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
public float CurrentEggLayCooldown;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("eggSpawn", required: true)]
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public List<EntitySpawnEntry> EggSpawn = default!;

[DataField("eggLaySound")]
[DataField]
public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");

[DataField("accumulatedFrametime")]
[DataField]
public float AccumulatedFrametime;

[DataField] public EntityUid? Action;
Expand Down
Loading

0 comments on commit 5e1f077

Please sign in to comment.