Skip to content

Commit

Permalink
SacrMind removed, added new event on cryo
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Jan 12, 2025

Verified

This commit was signed with the committer’s verified signature.
1 parent bd9ecaa commit c609ad4
Showing 7 changed files with 34 additions and 46 deletions.
5 changes: 5 additions & 0 deletions Content.Server/Bed/Cryostorage/CryostorageSystem.cs
Original file line number Diff line number Diff line change
@@ -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<CryostorageContainedComponent> 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);
7 changes: 7 additions & 0 deletions Content.Server/SS220/Bed/Cryostorage/BeingCryoDeletedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.SS220.Bed.Cryostorage;

/// <summary>
/// Raised before body will deleted by a cryostorages
/// </summary>
[ByRefEvent]
public readonly record struct BeingCryoDeletedEvent();
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -6,16 +6,18 @@
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Content.Server.SS220.Bed.Cryostorage;

namespace Content.Server.SS220.CultYogg.Sacraficials;

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<EntityUid, TimeSpan> _replaceSacrSchedule = [];
private Dictionary<EntityUid, TimeSpan> _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<CultYoggSacrificialComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<CultYoggSacrificialComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<CultYoggSacrificialComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<CultYoggSacrificialComponent, BeingCryoDeletedEvent>(OnCryoDeleted);
}
private void OnInit(Entity<CultYoggSacrificialComponent> ent, ref ComponentInit args)
{
@@ -52,8 +55,8 @@ private void OnRemove(Entity<CultYoggSacrificialComponent> ent, ref ComponentRem
}
private void OnPlayerAttached(Entity<CultYoggSacrificialComponent> 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<CultYoggSacrificialComponent> ent, ref Play

private void OnPlayerDetached(Entity<CultYoggSacrificialComponent> 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<CultYoggSacrificialComponent> 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);
}
Original file line number Diff line number Diff line change
@@ -41,8 +41,6 @@ public sealed partial class CultYoggRuleComponent : Component
/// <summary>
/// Storage for a sacraficials
/// </summary>
public readonly List<EntityUid> SacraficialsList = [];

public readonly int[] TierOfSacraficials = [1, 2, 3];//trying to save tier in target, so they might be replaced with the same lvl target

/// <summary>
20 changes: 3 additions & 17 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
@@ -193,9 +193,6 @@ private void SetSacraficials(CultYoggRuleComponent component)
if (!_job.MindTryGetJob(mind, out var prototype))
continue;

if (HasComp<CultYoggSacrificialMindComponent>(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<CultYoggSacrificialMindComponent>(uid.Value); //ToDo figure out do i need this?

var sacrComp = EnsureComp<CultYoggSacrificialComponent>(mind.Session.AttachedEntity.Value);

sacrComp.Tier = tier;

component.SacraficialsList.Add(uid.Value);
}

private List<EntityUid> GetAliveNoneCultHumans()//maybe add here sacraficials and cultists filter
@@ -252,6 +245,9 @@ private List<EntityUid> GetAliveNoneCultHumans()//maybe add here sacraficials an
if (HasComp<CultYoggComponent>(uid))
continue;

if (HasComp<CultYoggSacrificialComponent>(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<CultYoggSacrificialComponent>(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<CultYoggSacrificialMindComponent>(mindUid.Value);
}
private void SetNewSacraficial(CultYoggRuleComponent comp, int tier)
{

This file was deleted.

0 comments on commit c609ad4

Please sign in to comment.