From 297cfd23ad287c5d189a86e1670778654d0f4ff8 Mon Sep 17 00:00:00 2001 From: Remuchi Date: Sat, 30 Mar 2024 11:33:13 +0700 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=20=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VoiceMask/VoiceMaskBoundUserInterface.cs | 4 +- .../Administration/Managers/AdminManager.cs | 3 +- Content.Server/Bed/Sleep/SleepingSystem.cs | 1 - .../Body/Systems/RespiratorSystem.cs | 2 +- Content.Server/Chat/Managers/IChatManager.cs | 2 +- .../_White/AspectsSystem/Base/AspectSystem.cs | 333 ++++++------------ .../Systems/TorchCultistsProviderSystem.cs | 16 +- .../Supermatter/Systems/SupermatterSystem.cs | 5 +- 8 files changed, 123 insertions(+), 243 deletions(-) diff --git a/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs b/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs index 2b4a20098d..906792475b 100644 --- a/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs +++ b/Content.Client/VoiceMask/VoiceMaskBoundUserInterface.cs @@ -39,7 +39,7 @@ public sealed class VoiceMaskBoundUserInterface : BoundUserInterface return; } - _window.UpdateState(cast.Name, cast.Verb); + _window.UpdateState(cast.Name, cast.Voice, cast.Verb); } protected override void Dispose(bool disposing) @@ -48,4 +48,4 @@ public sealed class VoiceMaskBoundUserInterface : BoundUserInterface _window?.Close(); } -} +} \ No newline at end of file diff --git a/Content.Server/Administration/Managers/AdminManager.cs b/Content.Server/Administration/Managers/AdminManager.cs index 39cbe98222..c03569c95f 100644 --- a/Content.Server/Administration/Managers/AdminManager.cs +++ b/Content.Server/Administration/Managers/AdminManager.cs @@ -122,8 +122,7 @@ namespace Content.Server.Administration.Managers else { _chat.DispatchServerMessage(session, Loc.GetString("admin-manager-stealthed-message")); - _chat.SendAdminAnnouncement(Loc.GetString("admin-manager-self-re-admin-message", - ("newAdminName", session.Name)), flagWhitelist: AdminFlags.Stealth); + _chat.SendAdminAnnouncement(Loc.GetString("admin-manager-self-re-admin-message", ("newAdminName", session.Name))); } SendPermsChangedEvent(session); diff --git a/Content.Server/Bed/Sleep/SleepingSystem.cs b/Content.Server/Bed/Sleep/SleepingSystem.cs index 8628b313d9..2b3ec89dd4 100644 --- a/Content.Server/Bed/Sleep/SleepingSystem.cs +++ b/Content.Server/Bed/Sleep/SleepingSystem.cs @@ -75,7 +75,6 @@ namespace Content.Server.Bed.Sleep } emitSound.MinInterval = sleepSound.Interval; emitSound.MaxInterval = sleepSound.MaxInterval; - emitSound.PopUp = sleepSound.PopUp; } return; diff --git a/Content.Server/Body/Systems/RespiratorSystem.cs b/Content.Server/Body/Systems/RespiratorSystem.cs index 95738c829e..135e13799f 100644 --- a/Content.Server/Body/Systems/RespiratorSystem.cs +++ b/Content.Server/Body/Systems/RespiratorSystem.cs @@ -111,7 +111,7 @@ public sealed class RespiratorSystem : EntitySystem if (TryComp(uid, out VoidAdaptationComponent? voidAdaptation)) { voidAdaptation.ChemMultiplier = 0.75f; - StopSuffocation(uid, respirator); + StopSuffocation((uid, respirator)); respirator.SuffocationCycles = 0; continue; } diff --git a/Content.Server/Chat/Managers/IChatManager.cs b/Content.Server/Chat/Managers/IChatManager.cs index bd5cf637ba..5efa2f1792 100644 --- a/Content.Server/Chat/Managers/IChatManager.cs +++ b/Content.Server/Chat/Managers/IChatManager.cs @@ -28,7 +28,7 @@ namespace Content.Server.Chat.Managers bool TrySendNewMessage(ICommonSession session, string newMessage, bool checkLength = false); // WD-EDIT - void SendAdminAnnouncement(string message, AdminFlags? flagBlacklist = null, AdminFlags? flagWhitelist = null); + void SendAdminAnnouncement(string message); void SendAdminAlert(string message); void SendAdminAlert(EntityUid player, string message); diff --git a/Content.Server/_White/AspectsSystem/Base/AspectSystem.cs b/Content.Server/_White/AspectsSystem/Base/AspectSystem.cs index 6888aa3d22..f8385eda02 100644 --- a/Content.Server/_White/AspectsSystem/Base/AspectSystem.cs +++ b/Content.Server/_White/AspectsSystem/Base/AspectSystem.cs @@ -1,262 +1,143 @@ using System.Diagnostics.CodeAnalysis; -using System.Linq; using Content.Server.Administration.Logs; -using Content.Server.Atmos.EntitySystems; using Content.Server.Chat.Systems; using Content.Server.GameTicking.Rules; using Content.Server.GameTicking.Rules.Components; using Content.Server.Station.Components; using Content.Shared.Database; -using Content.Shared.Physics; -using Robust.Server.GameObjects; using Robust.Shared.Audio.Systems; -using Robust.Shared.Collections; -using Robust.Shared.Map; -using Robust.Shared.Map.Components; -using Robust.Shared.Physics; -using Robust.Shared.Physics.Components; using Robust.Shared.Player; -using Robust.Shared.Random; using Robust.Shared.Timing; -namespace Content.Server._White.AspectsSystem.Base +namespace Content.Server._White.AspectsSystem.Base; + +/// +/// Base class for aspect systems. +/// +/// The type of component to which the system is applied. +public abstract class AspectSystem : GameRuleSystem where T : Component { - /// - /// Base class for aspect systems. - /// - /// The type of component to which the system is applied. - public abstract class AspectSystem : GameRuleSystem where T : Component + [Dependency] private readonly IAdminLogManager _adminLogManager = default!; + [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly ChatSystem _chatSystem = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + + protected ISawmill Sawmill = default!; + + public override void Initialize() { - [Dependency] private readonly IAdminLogManager _adminLogManager = default!; - [Dependency] private readonly IGameTiming _timing = default!; - [Dependency] private readonly ChatSystem _chatSystem = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly IRobustRandom _robustRandom = default!; - [Dependency] private readonly AtmosphereSystem _atmosphere = default!; - [Dependency] private readonly TransformSystem _transform = default!; + base.Initialize(); - protected ISawmill Sawmill = default!; + Sawmill = Logger.GetSawmill("aspects"); + } - public override void Initialize() + /// + /// Called every tick when this aspect is running. + /// + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var aspect, out var ruleData)) { - base.Initialize(); + if (!GameTicker.IsGameRuleAdded(uid, ruleData)) + continue; - Sawmill = Logger.GetSawmill("aspects"); - } - - /// - /// Called every tick when this aspect is running. - /// - public override void Update(float frameTime) - { - base.Update(frameTime); - - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var aspect, out var ruleData)) + if (!GameTicker.IsGameRuleActive(uid, ruleData) && _timing.CurTime >= aspect.StartTime) { - if (!GameTicker.IsGameRuleAdded(uid, ruleData)) - continue; - - if (!GameTicker.IsGameRuleActive(uid, ruleData) && _timing.CurTime >= aspect.StartTime) - { - GameTicker.StartGameRule(uid, ruleData); - } + GameTicker.StartGameRule(uid, ruleData); } } + } - /// - /// Called when an aspect is added to an entity. - /// - protected override void Added(EntityUid uid, T component, GameRuleComponent gameRule, GameRuleAddedEvent args) + /// + /// Called when an aspect is added to an entity. + /// + protected override void Added(EntityUid uid, T component, GameRuleComponent gameRule, GameRuleAddedEvent args) + { + base.Added(uid, component, gameRule, args); + + if (!TryComp(uid, out var aspect)) + return; + + _adminLogManager.Add(LogType.AspectAnnounced, $"Aspect added {ToPrettyString(uid)}"); + + if (aspect is { Description: not null, IsHidden: false }) { - base.Added(uid, component, gameRule, args); - - if (!TryComp(uid, out var aspect)) - return; - - _adminLogManager.Add(LogType.AspectAnnounced, $"Aspect added {ToPrettyString(uid)}"); - - if (aspect is { Description: not null, IsHidden: false }) - { - _chatSystem.DispatchGlobalAnnouncement(aspect.Description, playSound: false, - colorOverride: Color.Aquamarine); - } - - _audio.PlayGlobal(aspect.StartAudio, Filter.Broadcast(), true); - aspect.StartTime = _timing.CurTime + aspect.StartDelay; + _chatSystem.DispatchGlobalAnnouncement(aspect.Description, playSound: false, + colorOverride: Color.Aquamarine); } - /// - /// Called when an aspect is started. - /// - protected override void Started( - EntityUid uid, - T component, - GameRuleComponent gameRule, - GameRuleStartedEvent args) + _audio.PlayGlobal(aspect.StartAudio, Filter.Broadcast(), true); + aspect.StartTime = _timing.CurTime + aspect.StartDelay; + } + + /// + /// Called when an aspect is started. + /// + protected override void Started( + EntityUid uid, + T component, + GameRuleComponent gameRule, + GameRuleStartedEvent args) + { + base.Started(uid, component, gameRule, args); + + if (!TryComp(uid, out _)) + return; + + _adminLogManager.Add(LogType.AspectStarted, LogImpact.High, $"Aspect started: {ToPrettyString(uid)}"); + } + + /// + /// Called when an aspect is ended. + /// + protected override void Ended(EntityUid uid, T component, GameRuleComponent gameRule, GameRuleEndedEvent args) + { + base.Ended(uid, component, gameRule, args); + + if (!TryComp(uid, out var aspect)) + return; + + _adminLogManager.Add(LogType.AspectStopped, $"Aspect ended: {ToPrettyString(uid)}"); + + if (aspect is { Name: not null, IsHidden: false }) { - base.Started(uid, component, gameRule, args); - - if (!TryComp(uid, out _)) - return; - - _adminLogManager.Add(LogType.AspectStarted, LogImpact.High, $"Aspect started: {ToPrettyString(uid)}"); + _chatSystem.DispatchGlobalAnnouncement($"Именем аспекта являлось: {aspect.Name}", playSound: false, + colorOverride: Color.Aquamarine); } - /// - /// Called when an aspect is ended. - /// - protected override void Ended(EntityUid uid, T component, GameRuleComponent gameRule, GameRuleEndedEvent args) - { - base.Ended(uid, component, gameRule, args); - - if (!TryComp(uid, out var aspect)) - return; - - _adminLogManager.Add(LogType.AspectStopped, $"Aspect ended: {ToPrettyString(uid)}"); - - if (aspect is { Name: not null, IsHidden: false }) - { - _chatSystem.DispatchGlobalAnnouncement($"Именем аспекта являлось: {aspect.Name}", playSound: false, - colorOverride: Color.Aquamarine); - } - - _audio.PlayGlobal(aspect.EndAudio, Filter.Broadcast(), true); - } + _audio.PlayGlobal(aspect.EndAudio, Filter.Broadcast(), true); + } #region Helpers - /// - /// Forces this aspect to end prematurely. - /// - /// The entity UID on which the aspect is being performed. - /// The game rule component associated with this aspect (optional). - protected void ForceEndSelf(EntityUid uid, GameRuleComponent? component = null) + /// + /// Forces this aspect to end prematurely. + /// + /// The entity UID on which the aspect is being performed. + /// The game rule component associated with this aspect (optional). + protected void ForceEndSelf(EntityUid uid, GameRuleComponent? component = null) + { + GameTicker.EndGameRule(uid, component); + } + + protected bool TryGetStationGrids( + [NotNullWhen(true)] out EntityUid? targetStation, + [NotNullWhen(true)] out HashSet? grids) + { + if (!TryGetRandomStation(out targetStation)) { - GameTicker.EndGameRule(uid, component); + targetStation = EntityUid.Invalid; + grids = null; + return false; } - protected bool TryGetRandomStation( - [NotNullWhen(true)] out EntityUid? station, - Func? filter = null) - { - var stations = new ValueList(); + grids = Comp(targetStation.Value).Grids; - if (filter == null) - { - var stationCount = Count(); - if (stationCount > 0) - { - stations.EnsureCapacity(stationCount); - } - } - - filter ??= _ => true; - var query = AllEntityQuery(); - - while (query.MoveNext(out var uid, out _)) - { - if (!filter(uid)) - continue; - - stations.Add(uid); - } - - if (stations.Count == 0) - { - station = null; - return false; - } - - station = stations[_robustRandom.Next(stations.Count)]; - return true; - } - - protected bool TryGetStationGrids( - [NotNullWhen(true)] out EntityUid? targetStation, - [NotNullWhen(true)] out HashSet? grids) - { - if (!TryGetRandomStation(out targetStation)) - { - targetStation = EntityUid.Invalid; - grids = null; - return false; - } - - grids = Comp(targetStation.Value).Grids; - - return grids.Count > 0; - } - - protected bool TryFindRandomTile( - out Vector2i tile, - [NotNullWhen(true)] out EntityUid? targetStation, - out EntityUid targetGrid, - out EntityCoordinates targetCoords) - { - tile = default; - - targetCoords = EntityCoordinates.Invalid; - - if (!TryGetStationGrids(out targetStation, out var possibleTargets)) - { - targetGrid = EntityUid.Invalid; - return false; - } - - targetGrid = _robustRandom.Pick(possibleTargets); - foreach (var target in possibleTargets.Where(HasComp)) - { - targetGrid = target; - break; - } - - if (!TryComp(targetGrid, out var gridComp)) - return false; - - var found = false; - var gridBounds = gridComp.LocalAABB.Scale(0.6f); - - for (var i = 0; i < 10; i++) - { - var randomX = _robustRandom.Next((int) gridBounds.Left, (int) gridBounds.Right); - var randomY = _robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top); - - tile = new Vector2i(randomX, randomY); - if (_atmosphere.IsTileSpace(targetGrid, Transform(targetGrid).MapUid, tile, - mapGridComp: gridComp) - || _atmosphere.IsTileAirBlocked(targetGrid, tile, mapGridComp: gridComp)) - { - continue; - } - - var physQuery = GetEntityQuery(); - var valid = true; - foreach (var ent in gridComp.GetAnchoredEntities(tile)) - { - if (!physQuery.TryGetComponent(ent, out var body)) - continue; - - if (body.BodyType != BodyType.Static || - !body.Hard || - (body.CollisionLayer & (int) CollisionGroup.Impassable) == 0) - continue; - - valid = false; - break; - } - - if (!valid) - continue; - - found = true; - targetCoords = gridComp.GridTileToLocal(tile); - break; - } - - return found; - } + return grids.Count > 0; + } #endregion - } -} +} \ No newline at end of file diff --git a/Content.Server/_White/Cult/Items/Systems/TorchCultistsProviderSystem.cs b/Content.Server/_White/Cult/Items/Systems/TorchCultistsProviderSystem.cs index 01865c34c9..b67399947c 100644 --- a/Content.Server/_White/Cult/Items/Systems/TorchCultistsProviderSystem.cs +++ b/Content.Server/_White/Cult/Items/Systems/TorchCultistsProviderSystem.cs @@ -190,8 +190,8 @@ public sealed class TorchCultistsProviderSystem : EntitySystem var ownerTransform = Transform(args.User); if (_station.GetStationInMap(ownerTransform.MapID) is not { } station || - !TryComp(station, out var data) || - _station.GetLargestGrid(data) is not { } grid) + !TryComp(station, out var stationData) || + _station.GetLargestGrid(stationData) is not { } grid) { if (ownerTransform.GridUid == null) return; @@ -199,13 +199,13 @@ public sealed class TorchCultistsProviderSystem : EntitySystem grid = ownerTransform.GridUid.Value; } - if (!TryComp(grid, out var gridComp)) + if (!TryComp(grid, out var mapGrid)) { return; } var gridTransform = Transform(grid); - var gridBounds = gridComp.LocalAABB.Scale(0.7f); // чтобы не заспавнить на самом краю станции + var gridBounds = mapGrid.LocalAABB.Scale(0.7f); // чтобы не заспавнить на самом краю станции var targetCoords = gridTransform.Coordinates; @@ -217,8 +217,8 @@ public sealed class TorchCultistsProviderSystem : EntitySystem var tile = new Vector2i(randomX, randomY); // no air-blocked areas. - if (_atmosphere.IsTileSpace(grid, gridTransform.MapUid, tile, mapGridComp: gridComp) || - _atmosphere.IsTileAirBlocked(grid, tile, mapGridComp: gridComp)) + if (_atmosphere.IsTileSpace(grid, gridTransform.MapUid, tile) || + _atmosphere.IsTileAirBlocked(grid, tile, mapGridComp: mapGrid)) { continue; } @@ -226,7 +226,7 @@ public sealed class TorchCultistsProviderSystem : EntitySystem // don't spawn inside of solid objects var physQuery = GetEntityQuery(); var valid = true; - foreach (var ent in _map.GetAnchoredEntities(grid, gridComp, tile)) + foreach (var ent in _map.GetAnchoredEntities(grid, mapGrid, tile)) { if (!physQuery.TryGetComponent(ent, out var body)) continue; @@ -243,7 +243,7 @@ public sealed class TorchCultistsProviderSystem : EntitySystem if (!valid) continue; - targetCoords = _map.GridTileToLocal(grid, gridComp, tile); + targetCoords = _map.GridTileToLocal(grid, mapGrid, tile); break; } diff --git a/Content.Server/_White/Supermatter/Systems/SupermatterSystem.cs b/Content.Server/_White/Supermatter/Systems/SupermatterSystem.cs index be06763001..682cfdcae9 100644 --- a/Content.Server/_White/Supermatter/Systems/SupermatterSystem.cs +++ b/Content.Server/_White/Supermatter/Systems/SupermatterSystem.cs @@ -321,9 +321,10 @@ namespace Content.Server._White.Supermatter.Systems //if there are space tiles next to SM //TODO: change moles out for checking if adjacent tiles exist - foreach (var ind in _atmosphere.GetAdjacentTileMixtures(xform.GridUid.Value, indices)) + var query = _atmosphere.GetAdjacentTileMixtures(xform.GridUid.Value, indices); + while(query.MoveNext(out var mix)) { - if (ind.TotalMoles != 0) + if (mix.TotalMoles != 0) continue; var integrity = GetIntegrity(sMcomponent.Damage, sMcomponent.ExplosionPoint);