Skip to content

Commit

Permalink
Merge branch 'metastable' of https://github.com/Temoffy/frontier-stat…
Browse files Browse the repository at this point in the history
…ion-14 into metastable
  • Loading branch information
Temoffy committed Dec 27, 2024
2 parents 7924f20 + 15dca6b commit 00e590f
Show file tree
Hide file tree
Showing 109 changed files with 1,462 additions and 418 deletions.
3 changes: 2 additions & 1 deletion Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ public async Task AllComponentsOneToOneDeleteTest()
"DebrisFeaturePlacerController", // Above.
"LoadedChunk", // Worldgen chunk loading malding.
"BiomeSelection", // Whaddya know, requires config.
"ActivatableUI", // Requires enum key
"ActivatableUI", // Frontier: Requires enum key
"AlertLevel", // Frontier: requires alert set
};

// TODO TESTS
Expand Down
7 changes: 5 additions & 2 deletions Content.Server/AlertLevel/AlertLevelDisplaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
using Content.Server.Station.Systems;
using Content.Shared.AlertLevel;
using Content.Shared.Power;
using Content.Server._NF.SectorServices; // Frontier

namespace Content.Server.AlertLevel;

public sealed class AlertLevelDisplaySystem : EntitySystem
{
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SectorServiceSystem _sectorService = default!; // Frontier

public override void Initialize()
{
Expand All @@ -30,8 +32,9 @@ private void OnDisplayInit(EntityUid uid, AlertLevelDisplayComponent alertLevelD
{
if (TryComp(uid, out AppearanceComponent? appearance))
{
var stationUid = _stationSystem.GetOwningStation(uid);
if (stationUid != null && TryComp(stationUid, out AlertLevelComponent? alert))
//var stationUid = _stationSystem.GetOwningStation(uid); // Frontier: sector-wide alerts
var stationUid = _sectorService.GetServiceEntity(); // Frontier: sector-wide alerts
if (stationUid.Valid && TryComp(stationUid, out AlertLevelComponent? alert)) // Frontier: uid != null < uid.Valid
{
_appearance.SetData(uid, AlertLevelDisplay.CurrentLevel, alert.CurrentLevel, appearance);
}
Expand Down
66 changes: 56 additions & 10 deletions Content.Server/AlertLevel/AlertLevelSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Content.Server.GameTicking; // Frontier
using Robust.Shared.Player; // Frontier
using Content.Server._NF.SectorServices; // Frontier

namespace Content.Server.AlertLevel;

Expand All @@ -16,13 +19,16 @@ public sealed class AlertLevelSystem : EntitySystem
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly GameTicker _ticker = default!; // Frontier
[Dependency] private readonly SectorServiceSystem _sectorService = default!;

// Until stations are a prototype, this is how it's going to have to be.
public const string DefaultAlertLevelSet = "stationAlerts";

public override void Initialize()
{
SubscribeLocalEvent<StationInitializedEvent>(OnStationInitialize);
//SubscribeLocalEvent<StationInitializedEvent>(OnStationInitialize); // Frontier: sector-wide services
SubscribeLocalEvent<AlertLevelComponent, ComponentInit>(OnInit); // Frontier: sector-wide services
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypeReload);
}

Expand All @@ -46,6 +52,8 @@ public override void Update(float time)
}
}

// Frontier: sector-wide services
/*
private void OnStationInitialize(StationInitializedEvent args)
{
if (!TryComp<AlertLevelComponent>(args.Station, out var alertLevelComponent))
Expand All @@ -66,6 +74,26 @@ private void OnStationInitialize(StationInitializedEvent args)
SetLevel(args.Station, defaultLevel, false, false, true);
}
*/

private void OnInit(EntityUid uid, AlertLevelComponent comp, ComponentInit args)
{
if (!_prototypeManager.TryIndex(comp.AlertLevelPrototype, out AlertLevelPrototype? alerts))
{
return;
}

comp.AlertLevels = alerts;

var defaultLevel = comp.AlertLevels.DefaultLevel;
if (string.IsNullOrEmpty(defaultLevel))
{
defaultLevel = comp.AlertLevels.Levels.Keys.First();
}

SetLevel(uid, defaultLevel, false, false, true);
}
// End Frontier

private void OnPrototypeReload(PrototypesReloadedEventArgs args)
{
Expand Down Expand Up @@ -98,20 +126,30 @@ private void OnPrototypeReload(PrototypesReloadedEventArgs args)

public string GetLevel(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
{
// Frontier: sector-wide alarms
if (!TryComp(_sectorService.GetServiceEntity(), out alert))
return string.Empty;
}

// if (!Resolve(station, ref alert))
// {
// return string.Empty;
// }
// End Frontier

return alert.CurrentLevel;
}

public float GetAlertLevelDelay(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
{
// Frontier: sector-wide alarms
if (!TryComp(_sectorService.GetServiceEntity(), out alert))
return float.NaN;
}

// if (!Resolve(station, ref alert))
// {
// return float.NaN;
// }
// End Frontier

return alert.CurrentDelay;
}
Expand All @@ -128,7 +166,13 @@ public float GetAlertLevelDelay(EntityUid station, AlertLevelComponent? alert =
public void SetLevel(EntityUid station, string level, bool playSound, bool announce, bool force = false,
bool locked = false, MetaDataComponent? dataComponent = null, AlertLevelComponent? component = null)
{
if (!Resolve(station, ref component, ref dataComponent)
// Frontier: sector-wide alerts
EntityUid sectorEnt = _sectorService.GetServiceEntity();
if (!TryComp<AlertLevelComponent>(sectorEnt, out component))
return;
// End Frontier

if (!Resolve(station, ref dataComponent) // Frontier: remove component
|| component.AlertLevels == null
|| !component.AlertLevels.Levels.TryGetValue(level, out var detail)
|| component.CurrentLevel == level)
Expand Down Expand Up @@ -177,7 +221,9 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
{
if (detail.Sound != null)
{
var filter = _stationSystem.GetInOwningStation(station);
//var filter = _stationSystem.GetInOwningStation(station); // Frontier: global alerts
var filter = Filter.Empty(); // Frontier
filter.AddInMap(_ticker.DefaultMap, EntityManager); // Frontier
_audio.PlayGlobal(detail.Sound, filter, true, detail.Sound.Params);
}
else
Expand All @@ -192,7 +238,7 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
colorOverride: detail.Color, sender: stationName);
}

RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
RaiseLocalEvent(new AlertLevelChangedEvent(EntityUid.Invalid, level)); // Frontier: pass invalid, we have no station
}
}

Expand Down
23 changes: 15 additions & 8 deletions Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server._NF.SectorServices;
using Content.Server.Administration;
using Content.Server.Station.Systems;
using Content.Shared.Administration;
Expand All @@ -21,11 +22,14 @@ public override CompletionResult GetCompletion(IConsoleShell shell, string[] arg
var player = shell.Player;
if (player?.AttachedEntity != null)
{
var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
if (stationUid != null)
{
levelNames = GetStationLevelNames(stationUid.Value);
}
// Frontier: sector-wide alerts
levelNames = GetSectorLevelNames();
// var stationUid = _entitySystems.GetEntitySystem<StationSystem>().GetOwningStation(player.AttachedEntity.Value);
// if (stationUid != null)
// {
// levelNames = GetStationLevelNames(stationUid.Value);
// }
// End Frontier
}

return args.Length switch
Expand Down Expand Up @@ -68,7 +72,7 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
}

var level = args[0];
var levelNames = GetStationLevelNames(stationUid.Value);
var levelNames = GetSectorLevelNames();
if (!levelNames.Contains(level))
{
shell.WriteLine(LocalizationManager.GetString("cmd-setalertlevel-invalid-level"));
Expand All @@ -78,16 +82,19 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
_entitySystems.GetEntitySystem<AlertLevelSystem>().SetLevel(stationUid.Value, level, true, true, true, locked);
}

private string[] GetStationLevelNames(EntityUid station)
// Frontier: sector-wide alert level names
private string[] GetSectorLevelNames()
{
var sectorServiceUid = _entitySystems.GetEntitySystem<SectorServiceSystem>().GetServiceEntity();
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetComponent<AlertLevelComponent>(station, out var alertLevelComp))
if (!entityManager.TryGetComponent<AlertLevelComponent>(sectorServiceUid, out var alertLevelComp))
return new string[]{};

if (alertLevelComp.AlertLevels == null)
return new string[]{};

return alertLevelComp.AlertLevels.Levels.Keys.ToArray();
}
// End Frontier
}
}
17 changes: 10 additions & 7 deletions Content.Server/Communications/CommunicationsConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Content.Shared.Popups;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using Content.Server._NF.SectorServices; // Frontier

namespace Content.Server.Communications
{
Expand All @@ -37,6 +38,7 @@ public sealed class CommunicationsConsoleSystem : EntitySystem
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SectorServiceSystem _sectorService = default!; // Frontier: sector-wide alerts

private const float UIUpdateInterval = 5.0f;

Expand Down Expand Up @@ -110,9 +112,9 @@ private void OnAlertLevelChanged(AlertLevelChangedEvent args)
var query = EntityQueryEnumerator<CommunicationsConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
var entStation = _stationSystem.GetOwningStation(uid);
if (args.Station == entStation)
UpdateCommsConsoleInterface(uid, comp);
// var entStation = _stationSystem.GetOwningStation(uid); // Frontier: sector-wide alerts
// if (args.Station == entStation) // Frontier: sector-wide alerts
UpdateCommsConsoleInterface(uid, comp);
}
}

Expand All @@ -133,14 +135,15 @@ public void UpdateCommsConsoleInterface()
/// </summary>
public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComponent comp)
{
var stationUid = _stationSystem.GetOwningStation(uid);
//var stationUid = _stationSystem.GetOwningStation(uid); // Frontier: sector-wide alerts
var stationUid = _sectorService.GetServiceEntity(); // Frontier: sector-wide alerts
List<string>? levels = null;
string currentLevel = default!;
float currentDelay = 0;

if (stationUid != null)
if (stationUid.Valid) // Frontier: != null < .Valid
{
if (TryComp(stationUid.Value, out AlertLevelComponent? alertComp) &&
if (TryComp(stationUid, out AlertLevelComponent? alertComp) && // Frontier: stationUid.Value<stationUid
alertComp.AlertLevels != null)
{
if (alertComp.IsSelectable)
Expand All @@ -156,7 +159,7 @@ public void UpdateCommsConsoleInterface(EntityUid uid, CommunicationsConsoleComp
}

currentLevel = alertComp.CurrentLevel;
currentDelay = _alertLevelSystem.GetAlertLevelDelay(stationUid.Value, alertComp);
currentDelay = _alertLevelSystem.GetAlertLevelDelay(stationUid, alertComp); // Frontier: stationUid.Value<stationUid
}
}

Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ private bool TryTwoWayAbsorbentRefillableTransfer(
{
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", target)), user, user);
}
// Frontier: out-only refillable solutions
else if (TryComp<RefillableSolutionComponent>(refillableSoln.Owner, out var refillableSolnComp) && refillableSolnComp.PreventTransferOut)
{
}
// End Frontier
else
{
// transfer as much contaminants to refillable as will fit
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Fluids/EntitySystems/PuddleSystem.Transfers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ private void InitializeTransfers()

private void OnRefillableDragged(Entity<RefillableSolutionComponent> entity, ref DragDropDraggedEvent args)
{
// Frontier: silently prevent non-transferrable solution
if (entity.Comp.PreventTransferOut)
return;
// End Frontier

if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var solution) || solution.Volume == FixedPoint2.Zero)
{
_popups.PopupEntity(Loc.GetString("mopping-system-empty", ("used", entity.Owner)), entity, args.User);
Expand Down
16 changes: 12 additions & 4 deletions Content.Server/Light/EntitySystems/EmergencyLightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Station.Components;
using Robust.Server.GameObjects;
using Color = Robust.Shared.Maths.Color;
using Content.Server._NF.SectorServices; // Frontier: sector services

namespace Content.Server.Light.EntitySystems;

Expand All @@ -21,6 +22,7 @@ public sealed class EmergencyLightSystem : SharedEmergencyLightSystem
[Dependency] private readonly PointLightSystem _pointLight = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly SectorServiceSystem _sectorService = default!; // Frontier: sector-wide alerts

public override void Initialize()
{
Expand Down Expand Up @@ -56,8 +58,10 @@ private void OnEmergencyExamine(EntityUid uid, EmergencyLightComponent component
Loc.GetString(component.BatteryStateText[component.State]))));

// Show alert level on the light itself.
if (!TryComp<AlertLevelComponent>(_station.GetOwningStation(uid), out var alerts))
// Frontier: sector-wide alerts
if (!TryComp<AlertLevelComponent>(_sectorService.GetServiceEntity(), out var alerts))
return;
// End Frontier: sector-wide alerts

if (alerts.AlertLevels == null)
return;
Expand Down Expand Up @@ -94,17 +98,21 @@ private void OnEmergencyLightEvent(EntityUid uid, EmergencyLightComponent compon

private void OnAlertLevelChanged(AlertLevelChangedEvent ev)
{
if (!TryComp<AlertLevelComponent>(ev.Station, out var alert))
// Frontier: sector-wide alerts
// if (!TryComp<AlertLevelComponent>(ev.Station, out var alert))
// return;
if (!TryComp<AlertLevelComponent>(_sectorService.GetServiceEntity(), out var alert))
return;
// End Frontier

if (alert.AlertLevels == null || !alert.AlertLevels.Levels.TryGetValue(ev.AlertLevel, out var details))
return;

var query = EntityQueryEnumerator<EmergencyLightComponent, PointLightComponent, AppearanceComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var light, out var pointLight, out var appearance, out var xform))
{
if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != ev.Station)
continue;
// if (CompOrNull<StationMemberComponent>(xform.GridUid)?.Station != ev.Station) // Frontier: sector-wide alerts
// continue; // Frontier: sector-wide alerts

_pointLight.SetColor(uid, details.EmergencyLightColor, pointLight);
_appearance.SetData(uid, EmergencyLightVisuals.Color, details.EmergencyLightColor, appearance);
Expand Down
5 changes: 4 additions & 1 deletion Content.Server/PDA/PdaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using Content.Shared.Bank.Components; // Frontier
using Content.Shared.Shipyard.Components; // Frontier
using Content.Server.Shipyard.Systems; // Frontier
using Content.Server._NF.SectorServices; // Frontier

namespace Content.Server.PDA
{
Expand All @@ -39,6 +40,7 @@ public sealed class PdaSystem : SharedPdaSystem
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly SectorServiceSystem _sectorService = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -295,7 +297,8 @@ private void UpdateStationName(EntityUid uid, PdaComponent pda)

private void UpdateAlertLevel(EntityUid uid, PdaComponent pda)
{
var station = _station.GetOwningStation(uid);
//var station = _station.GetOwningStation(uid); // Frontier
var station = _sectorService.GetServiceEntity(); // Frontier
if (!TryComp(station, out AlertLevelComponent? alertComp) ||
alertComp.AlertLevels == null)
return;
Expand Down
Loading

0 comments on commit 00e590f

Please sign in to comment.