Cryogenic storage tweaks (#26813)
* make cryo remove crewmember's station record when going to cryo * Revert "make cryo remove crewmember's station record when going to cryo" This reverts commit 9ac9707289b5e553e3015c8c3ef88a78439977c6. * make cryo remove crewmember from station records when the mind is removed from the body * add stationwide announcement for people cryoing (remember to change pr title and desc) * minor changes * announcement actually shows job now * requested changes * get outta here derivative
This commit is contained in:
@@ -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<CryostorageComponent>(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<StationJobsComponent>(station, out var stationJobs))
|
||||
if (!TryComp<StationJobsComponent>(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<StationRecordsComponent>(station, out var stationRecords))
|
||||
return;
|
||||
|
||||
var key = new StationRecordKey(_stationRecords.GetRecordByName(station.Value, name) ?? default(uint), station.Value);
|
||||
var jobName = "Unknown";
|
||||
|
||||
if (_stationRecords.TryGetRecord<GeneralStationRecord>(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<CryostorageContainedComponent> entity)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
### Announcement
|
||||
|
||||
earlyleave-cryo-announcement = {$character} ({$job}) has entered cryogenic storage!
|
||||
earlyleave-cryo-sender = Station
|
||||
Reference in New Issue
Block a user