Roundleave ship clean up (#653)
* cryo shuttle rework * Update entities.ftl
This commit is contained in:
@@ -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<CP14TravelingStoreShipComponent, FTLCompletedEvent>(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<CP14TravelingStoreShipComponent> ent)
|
||||
{
|
||||
var childrens = Transform(ent).ChildEnumerator;
|
||||
|
||||
HashSet<EntityUid> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<StationMemberComponent>(shuttle);
|
||||
member.Station = station;
|
||||
|
||||
var roundRemover = EnsureComp<CP14RoundRemoveShuttleComponent>(shuttle);
|
||||
roundRemover.Station = station;
|
||||
|
||||
station.Comp.NextTravelTime = _timing.CurTime + TimeSpan.FromSeconds(10f);
|
||||
|
||||
AddRoundstartTradingPositions(station);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server._CP14.RoundRemoveShuttle;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CP14RoundRemoveShuttleComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public EntityUid Station;
|
||||
}
|
||||
@@ -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<CP14RoundRemoveShuttleComponent, FTLCompletedEvent>(OnFTLComplete);
|
||||
}
|
||||
|
||||
private void OnFTLComplete(Entity<CP14RoundRemoveShuttleComponent> ent, ref FTLCompletedEvent args)
|
||||
{
|
||||
var childrens = Transform(ent).ChildEnumerator;
|
||||
|
||||
HashSet<EntityUid> 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<JobPrototype>? 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<JobPrototype>? 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);
|
||||
}
|
||||
}
|
||||
3
Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl
Normal file
3
Resources/Locale/en-US/_CP14/roundRemove/cryo.ftl
Normal file
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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 = Деревянная кружка для пива.
|
||||
|
||||
3
Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl
Normal file
3
Resources/Locale/ru-RU/_CP14/roundRemove/cryo.ftl
Normal file
@@ -0,0 +1,3 @@
|
||||
cp14-ship-sender = Империя
|
||||
cp14-earlyleave-ship-announcement = {$character} ({$job}) покидает поселение на торговом корабле.
|
||||
cp14-earlyleave-ship-announcement-dead = тело {$character} ({$job}) посмертно покидает поселение на торговом корабле.
|
||||
@@ -1,2 +0,0 @@
|
||||
cp14-ship-sender = Очень магическая система оповещения
|
||||
cp14-earlyleave-ship-announcement = {$character} ({$job}) покидает поселение на торговом корабле.
|
||||
Reference in New Issue
Block a user