From c609ad49ab545432c9a20cf0b98ecbd899cdc859 Mon Sep 17 00:00:00 2001 From: SkaldetSkaeg Date: Sun, 12 Jan 2025 21:11:33 +0700 Subject: [PATCH] SacrMind removed, added new event on cryo --- .../Bed/Cryostorage/CryostorageSystem.cs | 5 ++++ .../Bed/Cryostorage/BeingCryoDeletedEvent.cs | 7 +++++ .../SacraficialReplacementEvent.cs | 4 +-- .../SacraficialReplacementSystem.cs | 27 ++++++++++++------- .../Rules/Components/CultYoggRuleComponent.cs | 2 -- .../GameTicking/Rules/CultYoggRuleSystem.cs | 20 +++----------- .../CultYoggSacrificialMindComponent.cs | 15 ----------- 7 files changed, 34 insertions(+), 46 deletions(-) create mode 100644 Content.Server/SS220/Bed/Cryostorage/BeingCryoDeletedEvent.cs delete mode 100644 Content.Shared/SS220/CultYogg/Sacraficials/CultYoggSacrificialMindComponent.cs diff --git a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs index 646f4694ffa5..2edc4541f8f3 100644 --- a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs +++ b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs @@ -31,6 +31,7 @@ using Robust.Shared.Utility; using Content.Shared.Roles; // SS220 Cryostorage ghost role fix using Robust.Shared.Prototypes; // SS220 Cryostorage ghost role fix +using Content.Server.SS220.Bed.Cryostorage; //SS220 Cult_hotfix_4 namespace Content.Server.Bed.Cryostorage; @@ -222,6 +223,10 @@ public void HandleEnterCryostorage(Entity ent, Ne } comp.AllowReEnteringBody = false; + //SS220 start Cult_hotfix_4 + var ev = new BeingCryoDeletedEvent(); + RaiseLocalEvent(ent, ref ev); + //SS220 end Cult_hotfix_4 _transform.SetParent(ent, PausedMap.Value); cryostorageComponent.StoredPlayers.Add(ent); Dirty(ent, comp); diff --git a/Content.Server/SS220/Bed/Cryostorage/BeingCryoDeletedEvent.cs b/Content.Server/SS220/Bed/Cryostorage/BeingCryoDeletedEvent.cs new file mode 100644 index 000000000000..37dbd11ecc04 --- /dev/null +++ b/Content.Server/SS220/Bed/Cryostorage/BeingCryoDeletedEvent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.SS220.Bed.Cryostorage; + +/// +/// Raised before body will deleted by a cryostorages +/// +[ByRefEvent] +public readonly record struct BeingCryoDeletedEvent(); diff --git a/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementEvent.cs b/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementEvent.cs index 3cb0b1576a96..069dd1b4442c 100644 --- a/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementEvent.cs +++ b/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementEvent.cs @@ -7,11 +7,9 @@ namespace Content.Server.SS220.CultYogg.Sacraficials; public sealed class SacraficialReplacementEvent : EntityEventArgs { public readonly EntityUid Entity; - public readonly NetUserId Player; - public SacraficialReplacementEvent(EntityUid entity, NetUserId player) + public SacraficialReplacementEvent(EntityUid entity) { Entity = entity; - Player = player; } } diff --git a/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementSystem.cs b/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementSystem.cs index ccb967302187..53fbf2cd0841 100644 --- a/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementSystem.cs +++ b/Content.Server/SS220/CultYogg/Sacraficials/SacraficialReplacementSystem.cs @@ -6,6 +6,7 @@ using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Timing; +using Content.Server.SS220.Bed.Cryostorage; namespace Content.Server.SS220.CultYogg.Sacraficials; @@ -13,9 +14,10 @@ public sealed partial class SacraficialReplacementSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; + //dictionary of sacraficials uids and time when they left body by gibbing/ghosting/leaving anything - private Dictionary<(EntityUid, NetUserId), TimeSpan> _replaceSacrSchedule = new(); - private Dictionary<(EntityUid, NetUserId), TimeSpan> _announceSchedule = new(); + private Dictionary _replaceSacrSchedule = []; + private Dictionary _announceSchedule = []; //Count down the moment when sacraficial will be raplaced private TimeSpan _beforeReplacementCooldown = TimeSpan.FromSeconds(900); @@ -31,6 +33,7 @@ public override void Initialize() SubscribeLocalEvent(OnRemove); SubscribeLocalEvent(OnPlayerAttached); SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnCryoDeleted); } private void OnInit(Entity ent, ref ComponentInit args) { @@ -52,8 +55,8 @@ private void OnRemove(Entity ent, ref ComponentRem } private void OnPlayerAttached(Entity ent, ref PlayerAttachedEvent args) { - _replaceSacrSchedule.Remove((ent, args.Player.UserId)); - _announceSchedule.Remove((ent, args.Player.UserId)); + _replaceSacrSchedule.Remove(ent); + _announceSchedule.Remove(ent); var meta = MetaData(ent); @@ -63,8 +66,14 @@ private void OnPlayerAttached(Entity ent, ref Play private void OnPlayerDetached(Entity ent, ref PlayerDetachedEvent args) { - _replaceSacrSchedule.Add((ent, args.Player.UserId), _timing.CurTime); - _announceSchedule.Add((ent, args.Player.UserId), _timing.CurTime); + _replaceSacrSchedule.Add(ent, _timing.CurTime); + _announceSchedule.Add(ent, _timing.CurTime); + } + + private void OnCryoDeleted(Entity ent, ref BeingCryoDeletedEvent args) + { + var ev = new SacraficialReplacementEvent(ent); + RaiseLocalEvent(ent, ref ev, true); } private void ReplacamantStatusAnnounce(EntityUid uid) @@ -86,8 +95,8 @@ public override void Update(float frameTime) if (_timing.CurTime < pair.Value + _beforeReplacementCooldown) continue; - var ev = new SacraficialReplacementEvent(pair.Key.Item1, pair.Key.Item2); - RaiseLocalEvent(pair.Key.Item1, ref ev, true); + var ev = new SacraficialReplacementEvent(pair.Key); + RaiseLocalEvent(pair.Key, ref ev, true); _replaceSacrSchedule.Remove(pair.Key); } @@ -97,7 +106,7 @@ public override void Update(float frameTime) if (_timing.CurTime < pair.Value + _announceReplacementCooldown) continue; - ReplacamantStatusAnnounce(pair.Key.Item1); + ReplacamantStatusAnnounce(pair.Key); _announceSchedule.Remove(pair.Key); } diff --git a/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs b/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs index f5747b00b50b..7860abcc2399 100644 --- a/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs +++ b/Content.Server/SS220/GameTicking/Rules/Components/CultYoggRuleComponent.cs @@ -41,8 +41,6 @@ public sealed partial class CultYoggRuleComponent : Component /// /// Storage for a sacraficials /// - public readonly List SacraficialsList = []; - public readonly int[] TierOfSacraficials = [1, 2, 3];//trying to save tier in target, so they might be replaced with the same lvl target /// diff --git a/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs b/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs index 2d2975af411b..4d6bf721a60a 100644 --- a/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs +++ b/Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs @@ -193,9 +193,6 @@ private void SetSacraficials(CultYoggRuleComponent component) if (!_job.MindTryGetJob(mind, out var prototype)) continue; - if (HasComp(mind))//shouldn't be already a target - continue; - if (_sacraficialTiers[tier].Contains(prototype.ID)) allSuitable.Add(mind); } @@ -227,13 +224,9 @@ private void SetSacraficeTarget(CultYoggRuleComponent component, EntityUid? uid, //_adminLogger.Add(LogType.EventRan, LogImpact.High, $"CultYogg person {meta.EntityName} where picked for a tier: {tier}"); - EnsureComp(uid.Value); //ToDo figure out do i need this? - var sacrComp = EnsureComp(mind.Session.AttachedEntity.Value); sacrComp.Tier = tier; - - component.SacraficialsList.Add(uid.Value); } private List GetAliveNoneCultHumans()//maybe add here sacraficials and cultists filter @@ -252,6 +245,9 @@ private List GetAliveNoneCultHumans()//maybe add here sacraficials an if (HasComp(uid)) continue; + if (HasComp(uid)) + continue; + // the player has to be alive if (_mobState.IsAlive(uid, mobState)) allHumans.Add(mc.Mind.Value); @@ -299,19 +295,9 @@ private void SacraficialReplacement(ref SacraficialReplacementEvent args) RemComp(args.Entity); - if (!_mind.TryGetMind(args.Player, out var mindUid, out var mind)) - return; - - if (mindUid == null) - return; - var meta = MetaData(args.Entity); var ev = new CultYoggAnouncementEvent(args.Entity, Loc.GetString("cult-yogg-migo-can-replace", ("name", meta.EntityName))); RaiseLocalEvent(args.Entity, ref ev, true); - - cultRuleComp.SacraficialsList.Remove(mindUid.Value); - - RemComp(mindUid.Value); } private void SetNewSacraficial(CultYoggRuleComponent comp, int tier) { diff --git a/Content.Shared/SS220/CultYogg/Sacraficials/CultYoggSacrificialMindComponent.cs b/Content.Shared/SS220/CultYogg/Sacraficials/CultYoggSacrificialMindComponent.cs deleted file mode 100644 index 18988d6ae61a..000000000000 --- a/Content.Shared/SS220/CultYogg/Sacraficials/CultYoggSacrificialMindComponent.cs +++ /dev/null @@ -1,15 +0,0 @@ -// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt - -using Content.Shared.StatusIcon; -using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; - -namespace Content.Shared.SS220.CultYogg.Sacraficials; - -/// -/// Used to markup cult's sacrificials minds -/// -[RegisterComponent, NetworkedComponent] -public sealed partial class CultYoggSacrificialMindComponent : Component -{ -}