diff --git a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs index a3b7fb8d67..bb2ab4099d 100644 --- a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs +++ b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs @@ -1,11 +1,16 @@ +using System.Globalization; using System.Linq; using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.Hands.Systems; using Content.Server.Inventory; using Content.Server.Popups; +using Content.Server.Chat.Systems; using Content.Server.Station.Components; using Content.Server.Station.Systems; +using Content.Server.StationRecords; +using Content.Server.StationRecords.Systems; +using Content.Shared.StationRecords; using Content.Shared.UserInterface; using Content.Shared.Access.Systems; using Content.Shared.Bed.Cryostorage; @@ -32,6 +37,7 @@ public sealed class CryostorageSystem : SharedCryostorageSystem [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly AccessReaderSystem _accessReader = default!; + [Dependency] private readonly ChatSystem _chatSystem = default!; [Dependency] private readonly ClimbSystem _climb = default!; [Dependency] private readonly ContainerSystem _container = default!; [Dependency] private readonly GameTicker _gameTicker = default!; @@ -40,6 +46,7 @@ public sealed class CryostorageSystem : SharedCryostorageSystem [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly StationJobsSystem _stationJobs = default!; + [Dependency] private readonly StationRecordsSystem _stationRecords = default!; [Dependency] private readonly TransformSystem _transform = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; @@ -163,26 +170,30 @@ public sealed class CryostorageSystem : SharedCryostorageSystem { var comp = ent.Comp; var cryostorageEnt = ent.Comp.Cryostorage; + + var station = _station.GetOwningStation(ent); + var name = Name(ent.Owner); + if (!TryComp(cryostorageEnt, out var cryostorageComponent)) return; // if we have a session, we use that to add back in all the job slots the player had. if (userId != null) { - foreach (var station in _station.GetStationsSet()) + foreach (var uniqueStation in _station.GetStationsSet()) { - if (!TryComp(station, out var stationJobs)) + if (!TryComp(uniqueStation, out var stationJobs)) continue; - if (!_stationJobs.TryGetPlayerJobs(station, userId.Value, out var jobs, stationJobs)) + if (!_stationJobs.TryGetPlayerJobs(uniqueStation, userId.Value, out var jobs, stationJobs)) continue; foreach (var job in jobs) { - _stationJobs.TryAdjustJobSlot(station, job, 1, clamp: true); + _stationJobs.TryAdjustJobSlot(uniqueStation, job, 1, clamp: true); } - _stationJobs.TryRemovePlayerJobs(station, userId.Value, stationJobs); + _stationJobs.TryRemovePlayerJobs(uniqueStation, userId.Value, stationJobs); } } @@ -203,12 +214,33 @@ public sealed class CryostorageSystem : SharedCryostorageSystem _gameTicker.OnGhostAttempt(mind.Value, false); } } + comp.AllowReEnteringBody = false; _transform.SetParent(ent, PausedMap.Value); cryostorageComponent.StoredPlayers.Add(ent); Dirty(ent, comp); UpdateCryostorageUIState((cryostorageEnt.Value, cryostorageComponent)); AdminLog.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(ent):player} was entered into cryostorage inside of {ToPrettyString(cryostorageEnt.Value)}"); + + if (!TryComp(station, out var stationRecords)) + return; + + var key = new StationRecordKey(_stationRecords.GetRecordByName(station.Value, name) ?? default(uint), station.Value); + var jobName = "Unknown"; + + if (_stationRecords.TryGetRecord(key, out var entry, stationRecords)) + jobName = entry.JobTitle; + + _stationRecords.RemoveRecord(key, stationRecords); + + _chatSystem.DispatchStationAnnouncement(station.Value, + Loc.GetString( + "earlyleave-cryo-announcement", + ("character", name), + ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName)) + ), Loc.GetString("earlyleave-cryo-sender"), + playDefaultSound: false + ); } private void HandleCryostorageReconnection(Entity entity) diff --git a/Resources/Locale/en-US/bed/cryostorage/cryogenic-storage.ftl b/Resources/Locale/en-US/bed/cryostorage/cryogenic-storage.ftl new file mode 100644 index 0000000000..8de5f9019b --- /dev/null +++ b/Resources/Locale/en-US/bed/cryostorage/cryogenic-storage.ftl @@ -0,0 +1,5 @@ + +### Announcement + +earlyleave-cryo-announcement = {$character} ({$job}) has entered cryogenic storage! +earlyleave-cryo-sender = Station