Merge remote-tracking branch 'upstream/master' into fucking-upstream

This commit is contained in:
Jabak
2024-08-24 13:13:56 +03:00
2222 changed files with 247186 additions and 50848 deletions

View File

@@ -40,14 +40,21 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
/// <summary>
/// Countdown audio stream.
/// </summary>
[DataField, AutoNetworkedField]
public EntityUid? Stream = null;
/// <summary>
/// Sound that plays when the mission end is imminent.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("sound")]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Misc/tension_session.ogg")
[ViewVariables(VVAccess.ReadWrite), DataField]
public SoundSpecifier Sound = new SoundCollectionSpecifier("ExpeditionEnd")
{
Params = AudioParams.Default.WithVolume(-5),
};
/// <summary>
/// Song selected on MapInit so we can predict the audio countdown properly.
/// </summary>
[DataField]
public SoundPathSpecifier SelectedSong;
}

View File

@@ -56,7 +56,7 @@ public sealed partial class SalvageSystem
if (station != component.Owner)
continue;
_ui.TrySetUiState(uid, SalvageConsoleUiKey.Expedition, state, ui: uiComp);
_ui.SetUiState((uid, uiComp), SalvageConsoleUiKey.Expedition, state);
}
}
@@ -74,6 +74,6 @@ public sealed partial class SalvageSystem
state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, 0, new List<SalvageMissionParams>());
}
_ui.TrySetUiState(component, SalvageConsoleUiKey.Expedition, state);
_ui.SetUiState(component.Owner, SalvageConsoleUiKey.Expedition, state);
}
}

View File

@@ -4,7 +4,9 @@ using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Random.Helpers;
using Content.Shared.Salvage.Expeditions;
using Robust.Shared.Audio;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.CPUJob.JobQueues.Queues;
using Robust.Shared.GameStates;
@@ -34,6 +36,7 @@ public sealed partial class SalvageSystem
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, EntParentChangedMessage>(OnSalvageConsoleParent);
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, ClaimSalvageMessage>(OnSalvageClaimMessage);
SubscribeLocalEvent<SalvageExpeditionComponent, MapInitEvent>(OnExpeditionMapInit);
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentShutdown>(OnExpeditionShutdown);
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentGetState>(OnExpeditionGetState);
@@ -66,6 +69,12 @@ public sealed partial class SalvageSystem
_cooldown = obj;
}
private void OnExpeditionMapInit(EntityUid uid, SalvageExpeditionComponent component, MapInitEvent args)
{
var selectedFile = _audio.GetSound(component.Sound);
component.SelectedSong = new SoundPathSpecifier(selectedFile, component.Sound.Params);
}
private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
{
component.Stream = _audio.Stop(component.Stream);
@@ -168,6 +177,7 @@ public sealed partial class SalvageSystem
_dungeon,
_metaData,
_transform,
_mapSystem,
station,
coordinatesDisk,
missionParams,

View File

@@ -35,11 +35,6 @@ public sealed partial class SalvageSystem
private void OnMagnetClaim(EntityUid uid, SalvageMagnetComponent component, ref MagnetClaimOfferEvent args)
{
var player = args.Session.AttachedEntity;
if (player is null)
return;
var station = _station.GetOwningStation(uid);
if (!TryComp(station, out SalvageMagnetDataComponent? dataComp) ||
@@ -177,12 +172,12 @@ public sealed partial class SalvageSystem
// Fuck with the seed to mix wrecks and asteroids.
seed = (int) (seed / 10f) * 10;
if (i >= data.Comp.OfferCount / 2)
{
seed++;
}
data.Comp.Offered.Add(seed);
}
@@ -216,7 +211,7 @@ public sealed partial class SalvageSystem
if (!TryComp(station, out SalvageMagnetDataComponent? dataComp))
return;
_ui.TrySetUiState(entity, SalvageMagnetUiKey.Key,
_ui.SetUiState(entity.Owner, SalvageMagnetUiKey.Key,
new SalvageMagnetBoundUserInterfaceState(dataComp.Offered)
{
Cooldown = dataComp.OfferCooldown,
@@ -238,7 +233,7 @@ public sealed partial class SalvageSystem
if (station != data.Owner)
continue;
_ui.TrySetUiState(magnetUid, SalvageMagnetUiKey.Key,
_ui.SetUiState(magnetUid, SalvageMagnetUiKey.Key,
new SalvageMagnetBoundUserInterfaceState(data.Comp.Offered)
{
Cooldown = data.Comp.OfferCooldown,

View File

@@ -1,9 +1,7 @@
using System.Numerics;
using Content.Server.Salvage.Expeditions;
using Content.Server.Salvage.Expeditions.Structure;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Components;
using Content.Shared.Chat;
using Content.Shared.Humanoid;
@@ -13,7 +11,6 @@ using Content.Shared.Salvage.Expeditions;
using Content.Shared.Shuttles.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.Salvage;
@@ -144,6 +141,7 @@ public sealed partial class SalvageSystem
while (query.MoveNext(out var uid, out var comp))
{
var remaining = comp.EndTime - _timing.CurTime;
var audioLength = _audio.GetAudioLength(comp.SelectedSong.Path.ToString());
if (comp.Stage < ExpeditionStage.FinalCountdown && remaining < TimeSpan.FromSeconds(45))
{
@@ -151,13 +149,14 @@ public sealed partial class SalvageSystem
Dirty(uid, comp);
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-seconds", ("duration", TimeSpan.FromSeconds(45).Seconds)));
}
else if (comp.Stage < ExpeditionStage.MusicCountdown && remaining < TimeSpan.FromMinutes(2))
else if (comp.Stream == null && remaining < audioLength)
{
// TODO: Some way to play audio attached to a map for players.
comp.Stream = _audio.PlayGlobal(comp.Sound, Filter.BroadcastMap(Comp<MapComponent>(uid).MapId), true).Value.Entity;
var audio = _audio.PlayPvs(comp.Sound, uid).Value;
comp.Stream = audio.Entity;
_audio.SetMapAudio(audio);
comp.Stage = ExpeditionStage.MusicCountdown;
Dirty(uid, comp);
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(2).Minutes)));
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", audioLength.Minutes)));
}
else if (comp.Stage < ExpeditionStage.Countdown && remaining < TimeSpan.FromMinutes(4))
{
@@ -166,16 +165,16 @@ public sealed partial class SalvageSystem
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(5).Minutes)));
}
// Auto-FTL out any shuttles
else if (remaining < TimeSpan.FromSeconds(ShuttleSystem.DefaultStartupTime) + TimeSpan.FromSeconds(0.5))
else if (remaining < TimeSpan.FromSeconds(_shuttle.DefaultStartupTime) + TimeSpan.FromSeconds(0.5))
{
var ftlTime = (float) remaining.TotalSeconds;
if (remaining < TimeSpan.FromSeconds(ShuttleSystem.DefaultStartupTime))
if (remaining < TimeSpan.FromSeconds(_shuttle.DefaultStartupTime))
{
ftlTime = MathF.Max(0, (float) remaining.TotalSeconds - 0.5f);
}
ftlTime = MathF.Min(ftlTime, ShuttleSystem.DefaultStartupTime);
ftlTime = MathF.Min(ftlTime, _shuttle.DefaultStartupTime);
var shuttleQuery = AllEntityQuery<ShuttleComponent, TransformComponent>();
if (TryComp<StationDataComponent>(comp.Station, out var data))

View File

@@ -40,7 +40,6 @@ namespace Content.Server.Salvage
{
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
@@ -56,6 +55,7 @@ namespace Content.Server.Salvage
[Dependency] private readonly RadioSystem _radioSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly ShuttleSystem _shuttle = default!;
[Dependency] private readonly ShuttleConsoleSystem _shuttleConsoles = default!;
[Dependency] private readonly StationSystem _station = default!;

View File

@@ -35,8 +35,6 @@ using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Server.Shuttles.Components;
using Content.Shared.Coordinates;
using Content.Shared.Shuttles.Components;
namespace Content.Server.Salvage;
@@ -51,6 +49,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
private readonly DungeonSystem _dungeon;
private readonly MetaDataSystem _metaData;
private readonly SharedTransformSystem _xforms;
private readonly SharedMapSystem _map;
public readonly EntityUid Station;
public readonly EntityUid? CoordinatesDisk;
@@ -70,6 +69,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
DungeonSystem dungeon,
MetaDataSystem metaData,
SharedTransformSystem xform,
SharedMapSystem map,
EntityUid station,
EntityUid? coordinatesDisk,
SalvageMissionParams missionParams,
@@ -84,6 +84,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
_dungeon = dungeon;
_metaData = metaData;
_xforms = xform;
_map = map;
Station = station;
CoordinatesDisk = coordinatesDisk;
_missionParams = missionParams;
@@ -96,9 +97,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
protected override async Task<bool> Process()
{
_sawmill.Debug("salvage", $"Spawning salvage mission with seed {_missionParams.Seed}");
var mapId = _mapManager.CreateMap();
var mapUid = _mapManager.GetMapEntityId(mapId);
_mapManager.AddUninitializedMap(mapId);
var mapUid = _map.CreateMap(out var mapId, runMapInit: false);
MetaDataComponent? metadata = null;
var grid = _entManager.EnsureComponent<MapGridComponent>(mapUid);
var random = new Random(_missionParams.Seed);