Skip to content

Commit

Permalink
Merge branch 'master' into nfsd-detective-clothing-options-change
Browse files Browse the repository at this point in the history
  • Loading branch information
RangerXVII authored Dec 27, 2024
2 parents 5cf2d29 + f8b16a1 commit 573e90e
Show file tree
Hide file tree
Showing 291 changed files with 14,016 additions and 1,770 deletions.
30 changes: 17 additions & 13 deletions Content.Client/IconSmoothing/IconSmoothSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,25 @@ public void SetStateBase(EntityUid uid, IconSmoothComponent component, string ne

private void SetCornerLayers(SpriteComponent sprite, IconSmoothComponent component)
{
sprite.LayerMapRemove(CornerLayers.SE);
sprite.LayerMapRemove(CornerLayers.NE);
sprite.LayerMapRemove(CornerLayers.NW);
sprite.LayerMapRemove(CornerLayers.SW);

// Frontier: Allow overlays on entities using CornerLayers smoothing - don't remove layers, adjust existing ones or create new ones.
var state0 = $"{component.StateBase}0";
sprite.LayerMapSet(CornerLayers.SE, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SE, DirectionOffset.None);
sprite.LayerMapSet(CornerLayers.NE, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.NE, DirectionOffset.CounterClockwise);
sprite.LayerMapSet(CornerLayers.NW, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.NW, DirectionOffset.Flip);
sprite.LayerMapSet(CornerLayers.SW, sprite.AddLayerState(state0));
sprite.LayerSetDirOffset(CornerLayers.SW, DirectionOffset.Clockwise);
SetCornerLayerState(sprite, CornerLayers.SE, DirectionOffset.None, state0);
SetCornerLayerState(sprite, CornerLayers.NE, DirectionOffset.CounterClockwise, state0);
SetCornerLayerState(sprite, CornerLayers.NW, DirectionOffset.Flip, state0);
SetCornerLayerState(sprite, CornerLayers.SW, DirectionOffset.Clockwise, state0);
// End Frontier: Allow overlays on entities using CornerLayers smoothing - don't remove layers, adjust existing ones or create new ones.
}

// Frontier: set layer function to remove redundancy
private void SetCornerLayerState(SpriteComponent sprite, CornerLayers corner, DirectionOffset offset, string state)
{
if (sprite.LayerMapTryGet(corner, out var layer))
sprite.LayerSetState(layer, state);
else
sprite.LayerMapSet(corner, sprite.AddLayerState(state));
sprite.LayerSetDirOffset(corner, offset);
}
// End Frontier: set layer function to remove redundancy

private void OnShutdown(EntityUid uid, IconSmoothComponent component, ComponentShutdown args)
{
Expand Down
41 changes: 41 additions & 0 deletions Content.Client/Stack/StackCustomSplitBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Cherry-picked from space-station-14#32938 courtesy of Ilya246
using JetBrains.Annotations;
using Content.Shared.Stacks;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client.Stack
{
[UsedImplicitly]
public sealed class StackCustomSplitBoundUserInterface : BoundUserInterface
{
private IEntityManager _entManager;
private EntityUid _owner;
[ViewVariables]
private StackCustomSplitWindow? _window;

public StackCustomSplitBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_owner = owner;
_entManager = IoCManager.Resolve<IEntityManager>();
}

protected override void Open()
{
base.Open();
_window = this.CreateWindow<StackCustomSplitWindow>();

if (_entManager.TryGetComponent<StackComponent>(_owner, out var comp))
_window.SetMax(comp.Count);

_window.ApplyButton.OnPressed += _ =>
{
if (int.TryParse(_window.AmountLineEdit.Text, out var i))
{
SendMessage(new StackCustomSplitAmountMessage(i));
_window.Close();
}
};
}
}
}
15 changes: 15 additions & 0 deletions Content.Client/Stack/StackCustomSplitWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ui-custom-stack-split-title'}"
Resizable="False">
<!--Cherry-picked from space-station-14#32938 courtesy of Ilya246-->

<BoxContainer Orientation="Vertical" SeparationOverride="4" MinSize="240 80">
<BoxContainer Orientation="Horizontal">
<LineEdit Name="AmountLineEdit" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc 'ui-custom-stack-split-line-edit-placeholder'}"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="MaximumAmount" Access="Public" />
</BoxContainer>
<Button Name="ApplyButton" Access="Public" Text="{Loc 'ui-custom-stack-split-apply'}"/>
</BoxContainer>
</DefaultWindow>
35 changes: 35 additions & 0 deletions Content.Client/Stack/StackCustomSplitWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Cherry-picked from space-station-14#32938 courtesy of Ilya246
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Stack
{
[GenerateTypedNameReferences]
public sealed partial class StackCustomSplitWindow : DefaultWindow
{
private int _max = Int32.MaxValue;
private int _min = 1;

public StackCustomSplitWindow()
{
RobustXamlLoader.Load(this);
AmountLineEdit.OnTextChanged += OnValueChanged;
}

public void SetMax(int max)
{
_max = max;
MaximumAmount.Text = Loc.GetString("comp-stack-split-size", ("size", _max));
}

private void OnValueChanged(LineEdit.LineEditEventArgs args)
{
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount > _max || amount < _min)
ApplyButton.Disabled = true;
else
ApplyButton.Disabled = false;
}
}
}
4 changes: 2 additions & 2 deletions Content.IntegrationTests/PoolSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable

using Robust.Shared.Random;

Expand Down Expand Up @@ -93,7 +93,7 @@ public sealed class PoolSettings
/// <summary>
/// Frontier: the preset to run the game in.
/// Set to secret for upstream tests to mimic upstream behaviour.
/// If you need to check adventure game rule things, set this to Adventure.
/// If you need to check adventure game rule things, set this to nfadventure or nfpirate.
/// </summary>
public string GameLobbyDefaultPreset { get; set; } = "secret";

Expand Down
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
72 changes: 59 additions & 13 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,8 +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)
|| component.AlertLevels == null
// Frontier: sector-wide alerts
EntityUid sectorEnt = _sectorService.GetServiceEntity();
if (!TryComp<AlertLevelComponent>(sectorEnt, out component))
return;
// End Frontier

if (component.AlertLevels == null // Frontier: remove component, resolve station to data component later
|| !component.AlertLevels.Levels.TryGetValue(level, out var detail)
|| component.CurrentLevel == level)
{
Expand All @@ -152,7 +195,7 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
component.CurrentLevel = level;
component.IsLevelLocked = locked;

var stationName = dataComponent.EntityName;
//var stationName = dataComponent.EntityName; // Frontier: remove station name

var name = level.ToLower();

Expand All @@ -177,7 +220,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 @@ -186,13 +231,14 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou
}
}

if (announce)
if (announce && Resolve(station, ref dataComponent)) // Frontier: add Resolve for dataComponent
{
var stationName = dataComponent.EntityName; // Frontier: moved down
_chatSystem.DispatchStationAnnouncement(station, announcementFull, playDefaultSound: playDefault,
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
}
}
Loading

0 comments on commit 573e90e

Please sign in to comment.