From 22b0f46890c72405119b1e5a91c863f4dc3b79c4 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:39:56 +0300 Subject: [PATCH] Roundleave ship clean up (#653) * cryo shuttle rework * Update entities.ftl --- .../_CP14/Cargo/CP14CargoSystem.Shuttle.cs | 58 ----------- Content.Server/_CP14/Cargo/CP14CargoSystem.cs | 4 + .../CP14RoundRemoveShuttleComponent.cs | 8 ++ .../CP14RoundRemoveShuttleSystem.cs | 95 +++++++++++++++++++ .../Locale/en-US/_CP14/roundRemove/cryo.ftl | 3 + .../en-US/_CP14/travelingStoreship/cryo.ftl | 2 - .../ru-RU/_CP14/_PROTO/entities/entities.ftl | 8 +- .../Locale/ru-RU/_CP14/roundRemove/cryo.ftl | 3 + .../ru-RU/_CP14/travelingStoreship/cryo.ftl | 2 - 9 files changed, 117 insertions(+), 66 deletions(-) create mode 100644 Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleComponent.cs create mode 100644 Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleSystem.cs create mode 100644 Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl delete mode 100644 Resources/Locale/en-US/_CP14/travelingStoreship/cryo.ftl create mode 100644 Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl delete mode 100644 Resources/Locale/ru-RU/_CP14/travelingStoreship/cryo.ftl diff --git a/Content.Server/_CP14/Cargo/CP14CargoSystem.Shuttle.cs b/Content.Server/_CP14/Cargo/CP14CargoSystem.Shuttle.cs index dc922e183f..d2d2ad30b5 100644 --- a/Content.Server/_CP14/Cargo/CP14CargoSystem.Shuttle.cs +++ b/Content.Server/_CP14/Cargo/CP14CargoSystem.Shuttle.cs @@ -1,15 +1,7 @@ -using System.Globalization; -using System.Linq; using System.Numerics; -using Content.Server.Chat.Systems; -using Content.Server.Mind; using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; -using Content.Server.Station.Systems; using Content.Shared._CP14.Cargo; -using Content.Shared.Administration.Logs; -using Content.Shared.Database; -using Content.Shared.Roles.Jobs; using Robust.Shared.Map; using Robust.Shared.Random; @@ -17,12 +9,6 @@ namespace Content.Server._CP14.Cargo; public sealed partial class CP14CargoSystem { - [Dependency] private readonly ISharedAdminLogManager _adminLog = default!; - [Dependency] private readonly ChatSystem _chatSystem = default!; - [Dependency] private readonly MindSystem _mind = default!; - [Dependency] private readonly SharedJobSystem _job = default!; - [Dependency] private readonly StationJobsSystem _stationJobs = default!; - private void InitializeShuttle() { SubscribeLocalEvent(OnFTLCompleted); @@ -102,10 +88,6 @@ public sealed partial class CP14CargoSystem { station.OnStation = false; - var b = station.Balance; - - PlayersPurgeJobs(ent); - SellingThings((ent.Comp.Station, station)); // +balance TopUpBalance((ent.Comp.Station, station)); //+balance BuyToQueue((ent.Comp.Station, station)); //-balance +buyQueue @@ -121,44 +103,4 @@ public sealed partial class CP14CargoSystem UpdateAllStores(); } - - private void PlayersPurgeJobs(Entity ent) - { - var childrens = Transform(ent).ChildEnumerator; - - HashSet toDelete = new(); - while (childrens.MoveNext(out var uid)) - { - if (!_mind.TryGetMind(uid, out var mindId, out var mindComp)) - continue; - - if (!_job.MindTryGetJob(mindId, out var jobProto)) - continue; - - _adminLog.Add(LogType.Action, - LogImpact.High, - $"{ToPrettyString(uid):player} was leave the round on traveling merchant ship"); - - _chatSystem.DispatchStationAnnouncement(ent.Comp.Station, - Loc.GetString( - "cp14-earlyleave-ship-announcement", - ("character", mindComp.CharacterName ?? "Unknown"), - ("entity", ent.Owner), // gender things for supporting downstreams with other languages - ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Loc.GetString(jobProto.Name))) - ), - Loc.GetString("cp14-ship-sender"), - playDefaultSound: false - ); - - _stationJobs.TryAdjustJobSlot(ent.Comp.Station, jobProto, 1, clamp: true); - toDelete.Add(uid); - } - - while (toDelete.Count > 0) - { - var r = toDelete.First(); - toDelete.Remove(r); - QueueDel(r); - } - } } diff --git a/Content.Server/_CP14/Cargo/CP14CargoSystem.cs b/Content.Server/_CP14/Cargo/CP14CargoSystem.cs index b5ccd4bdf0..0eb8f4b294 100644 --- a/Content.Server/_CP14/Cargo/CP14CargoSystem.cs +++ b/Content.Server/_CP14/Cargo/CP14CargoSystem.cs @@ -1,4 +1,5 @@ using Content.Server._CP14.Currency; +using Content.Server._CP14.RoundRemoveShuttle; using Content.Server.Shuttles.Systems; using Content.Server.Station.Events; using Content.Server.Station.Systems; @@ -102,6 +103,9 @@ public sealed partial class CP14CargoSystem : CP14SharedCargoSystem var member = EnsureComp(shuttle); member.Station = station; + var roundRemover = EnsureComp(shuttle); + roundRemover.Station = station; + station.Comp.NextTravelTime = _timing.CurTime + TimeSpan.FromSeconds(10f); AddRoundstartTradingPositions(station); diff --git a/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleComponent.cs b/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleComponent.cs new file mode 100644 index 0000000000..ce3199097a --- /dev/null +++ b/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server._CP14.RoundRemoveShuttle; + +[RegisterComponent] +public sealed partial class CP14RoundRemoveShuttleComponent : Component +{ + [DataField] + public EntityUid Station; +} diff --git a/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleSystem.cs b/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleSystem.cs new file mode 100644 index 0000000000..2e0b2e98d6 --- /dev/null +++ b/Content.Server/_CP14/RoundRemoveShuttle/CP14RoundRemoveShuttleSystem.cs @@ -0,0 +1,95 @@ +using System.Globalization; +using System.Linq; +using Content.Server.Chat.Systems; +using Content.Server.Mind; +using Content.Server.Shuttles.Events; +using Content.Server.Station.Systems; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; +using Content.Shared.IdentityManagement.Components; +using Content.Shared.Mind.Components; +using Content.Shared.Mobs.Systems; +using Content.Shared.Roles; +using Content.Shared.Roles.Jobs; +using Robust.Shared.Network; +using Robust.Shared.Prototypes; + +namespace Content.Server._CP14.RoundRemoveShuttle; + +public sealed partial class CP14RoundRemoveShuttleSystem : EntitySystem +{ + [Dependency] private readonly ISharedAdminLogManager _adminLog = default!; + [Dependency] private readonly ChatSystem _chatSystem = default!; + [Dependency] private readonly MindSystem _mind = default!; + [Dependency] private readonly StationJobsSystem _stationJobs = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnFTLComplete); + } + + private void OnFTLComplete(Entity ent, ref FTLCompletedEvent args) + { + var childrens = Transform(ent).ChildEnumerator; + + HashSet toDelete = new(); + while (childrens.MoveNext(out var uid)) + { + if (!_mind.TryGetMind(uid, out _, out var mindComp)) + continue; + + //Trying return all jobs roles + var userId = mindComp.UserId; + ProtoId? playerJob = null; + string? jobName = null; + if (userId is not null) + { + RestoreJobs(ent.Comp.Station, userId.Value, out playerJob); + if (_proto.TryIndex(playerJob, out var indexedJob)) + { + jobName = Loc.GetString(indexedJob.Name); + } + } + + _adminLog.Add(LogType.Action, + LogImpact.High, + $"{ToPrettyString(uid):player} was leave the round on traveling merchant ship"); + + _chatSystem.DispatchStationAnnouncement(ent.Comp.Station, + Loc.GetString( + _mobState.IsDead(uid) ? "cp14-earlyleave-ship-announcement-dead" : "cp14-earlyleave-ship-announcement", + ("character", mindComp.CharacterName ?? "Unknown"), + ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName ?? "Unknown")) + ), + Loc.GetString("cp14-ship-sender"), + playDefaultSound: false + ); + toDelete.Add(uid); + } + + while (toDelete.Count > 0) + { + var r = toDelete.First(); + toDelete.Remove(r); + QueueDel(r); + } + } + + private void RestoreJobs(EntityUid station, NetUserId userId, out ProtoId? outJob) + { + outJob = null; + if (!_stationJobs.TryGetPlayerJobs(station, userId, out var jobs)) + return; + + foreach (var job in jobs) + { + _stationJobs.TryAdjustJobSlot(station, job, 1, clamp: true); + outJob = job; + } + _stationJobs.TryRemovePlayerJobs(station, userId); + } +} diff --git a/Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl b/Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl new file mode 100644 index 0000000000..bb38542923 --- /dev/null +++ b/Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl @@ -0,0 +1,3 @@ +cp14-ship-sender = Empire +cp14-earlyleave-ship-announcement = {$character} ({$job}) leaves the settlement on a merchant ship. +cp14-earlyleave-ship-announcement-dead = body {$character} ({$job}) leaves the settlement posthumously on a merchant ship. \ No newline at end of file diff --git a/Resources/Locale/en-US/_CP14/travelingStoreship/cryo.ftl b/Resources/Locale/en-US/_CP14/travelingStoreship/cryo.ftl deleted file mode 100644 index 5367b4a95f..0000000000 --- a/Resources/Locale/en-US/_CP14/travelingStoreship/cryo.ftl +++ /dev/null @@ -1,2 +0,0 @@ -cp14-ship-sender = A very magical announcement system -cp14-earlyleave-ship-announcement = {$character} ({$job}) leaves the settlement on a merchant ship. \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_CP14/_PROTO/entities/entities.ftl b/Resources/Locale/ru-RU/_CP14/_PROTO/entities/entities.ftl index ad5fa74752..82234c8f8e 100644 --- a/Resources/Locale/ru-RU/_CP14/_PROTO/entities/entities.ftl +++ b/Resources/Locale/ru-RU/_CP14/_PROTO/entities/entities.ftl @@ -396,7 +396,7 @@ ent-CP14ClothingEyesThaumaturgyGlasses = тауматургические очк .desc = Очки, позволяющие сканировать магические предметы и существ, чтобы четко видеть количество оставшейся в них энергии. ent-CP14ClothingGlovesGirdles = железные наручи - .desc = Бронированные боевые наручи из металла. + .desc = Бронированные боевые наручи из железа. ent-CP14ClothingHeadCapellina = капеллина .desc = Защита от ударов крупными предметами по голове. @@ -449,7 +449,7 @@ ent-CP14ClothingHeadBandanaYellow = желтая бандана ent-CP14ClothingHeadBeretMercenary = берет наемника .desc = Большая красная шерстяная шляпа, украшенная пером. -ent-CP14ClothingHeadMetalHeadband = металлический обруч +ent-CP14ClothingHeadMetalHeadband = железный обруч .desc = Вероятность, что он защитит от попадания в голову, крайне мала. ent-CP14ClothingHeadTriangularHat = остроконечная шляпа @@ -807,8 +807,8 @@ ent-CP14RedBottle = красная бутылка .desc = Красная бутылка, идеально подходит для вина. .suffix = Пустая -ent-CP14MetalBeerMug = металлическая кружка - .desc = Самая обычная металлическая кружка. +ent-CP14MetalBeerMug = железная кружка + .desc = Самая обычная железная кружка. ent-CP14WoodenBeerMug = деревянная кружка .desc = Деревянная кружка для пива. diff --git a/Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl b/Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl new file mode 100644 index 0000000000..22b319246f --- /dev/null +++ b/Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl @@ -0,0 +1,3 @@ +cp14-ship-sender = Империя +cp14-earlyleave-ship-announcement = {$character} ({$job}) покидает поселение на торговом корабле. +cp14-earlyleave-ship-announcement-dead = тело {$character} ({$job}) посмертно покидает поселение на торговом корабле. \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_CP14/travelingStoreship/cryo.ftl b/Resources/Locale/ru-RU/_CP14/travelingStoreship/cryo.ftl deleted file mode 100644 index 3bb39e865f..0000000000 --- a/Resources/Locale/ru-RU/_CP14/travelingStoreship/cryo.ftl +++ /dev/null @@ -1,2 +0,0 @@ -cp14-ship-sender = Очень магическая система оповещения -cp14-earlyleave-ship-announcement = {$character} ({$job}) покидает поселение на торговом корабле. \ No newline at end of file