Skip to content

Commit

Permalink
Cult_hotfix_4 (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg authored Jan 14, 2025
1 parent 6bff2ab commit eff8ec4
Show file tree
Hide file tree
Showing 30 changed files with 202 additions and 204 deletions.
5 changes: 5 additions & 0 deletions Content.Server/Bed/Cryostorage/CryostorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
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();
2 changes: 1 addition & 1 deletion Content.Server/SS220/CultYogg/Cultists/CultYoggSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void UpdateStage(Entity<CultYoggComponent> entity, ref ChangeCultYoggSta

if (_prototype.HasIndex<MarkingPrototype>(newMarkingId))
{
if (huAp.MarkingSet.Markings.TryGetValue(MarkingCategories.Tail, out var value))
if (huAp.MarkingSet.Markings.TryGetValue(MarkingCategories.Special, out var value))
{
entity.Comp.PreviousTail = value.FirstOrDefault();
value.Clear();
Expand Down
120 changes: 0 additions & 120 deletions Content.Server/SS220/CultYogg/MiGo/MiGoReplacementSystem.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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);
Expand All @@ -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)
{
Expand All @@ -40,6 +43,9 @@ private void OnInit(Entity<CultYoggSacrificialComponent> ent, ref ComponentInit
{
RaiseLocalEvent(uid, ref ev);
}

var ev2 = new CultYoggAnouncementEvent(ent, Loc.GetString("cult-yogg-sacraficial-was-picked", ("name", MetaData(ent).EntityName)));
RaiseLocalEvent(ent, ref ev, true);
}
private void OnRemove(Entity<CultYoggSacrificialComponent> ent, ref ComponentRemove args)
{
Expand All @@ -52,29 +58,37 @@ 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);

var meta = MetaData(ent);
if(_announceSchedule.ContainsKey(ent))//if the announcement was not sent
{
_announceSchedule.Remove(ent);
return;
}

var ev = new CultYoggAnouncementEvent(ent, Loc.GetString("cult-yogg-sacraficial-cant-be-replaced", ("name", meta.EntityName)));
var ev = new CultYoggAnouncementEvent(ent, Loc.GetString("cult-yogg-sacraficial-cant-be-replaced", ("name", MetaData(ent).EntityName)));
RaiseLocalEvent(ent, ref ev, true);
}

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 + ent.Comp.ReplacementCooldown);
_announceSchedule.Add(ent, _timing.CurTime + ent.Comp.AnnounceReplacementCooldown);
}

private void OnCryoDeleted(Entity<CultYoggSacrificialComponent> ent, ref BeingCryoDeletedEvent args)
{
var ev = new SacraficialReplacementEvent(ent);
RaiseLocalEvent(ent, ref ev, true);
}

private void ReplacamantStatusAnnounce(EntityUid uid)
{
if (!TryComp<CultYoggSacrificialComponent>(uid, out var comp))
return;

var meta = MetaData(uid);

var ev = new CultYoggAnouncementEvent(uid, Loc.GetString("cult-yogg-sacraficial-may-be-replaced", ("name", meta.EntityName)));
var time = (comp.ReplacementCooldown.TotalSeconds - comp.AnnounceReplacementCooldown.TotalSeconds).ToString();
var ev = new CultYoggAnouncementEvent(uid, Loc.GetString("cult-yogg-sacraficial-will-be-replaced", ("name", MetaData(uid).EntityName), ("time", time)));
RaiseLocalEvent(uid, ref ev, true);
}

Expand All @@ -83,21 +97,21 @@ public override void Update(float frameTime)
base.Update(frameTime);
foreach (var pair in _replaceSacrSchedule)
{
if (_timing.CurTime < pair.Value + _beforeReplacementCooldown)
if (_timing.CurTime < pair.Value)
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);
}

foreach (var pair in _announceSchedule)//it is stupid, but idk how to make it 1 time event without second System :(
{
if (_timing.CurTime < pair.Value + _announceReplacementCooldown)
if (_timing.CurTime < pair.Value)
continue;

ReplacamantStatusAnnounce(pair.Key.Item1);
ReplacamantStatusAnnounce(pair.Key);

_announceSchedule.Remove(pair.Key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
36 changes: 9 additions & 27 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -223,17 +220,11 @@ private void SetSacraficeTarget(CultYoggRuleComponent component, EntityUid? uid,
if (mind.Session.AttachedEntity is null)
return;

var meta = MetaData(uid.Value);

//_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
Expand All @@ -252,6 +243,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);
Expand Down Expand Up @@ -299,19 +293,8 @@ 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)));
var ev = new CultYoggAnouncementEvent(args.Entity, Loc.GetString("cult-yogg-sacraficial-was-replaced", ("name", MetaData(args.Entity).EntityName)));
RaiseLocalEvent(args.Entity, ref ev, true);

cultRuleComp.SacraficialsList.Remove(mindUid.Value);

RemComp<CultYoggSacrificialMindComponent>(mindUid.Value);
}
private void SetNewSacraficial(CultYoggRuleComponent comp, int tier)
{
Expand Down Expand Up @@ -442,15 +425,14 @@ public void DeMakeCultist(EntityUid uid, CultYoggRuleComponent component)
private void SendCultAnounce(ref CultYoggAnouncementEvent args)
{
//ToDo refactor without spam
/*
GetCultGameRule(out var comp);

if (comp == null)
var ruleComp = GetCultGameRule();

if (ruleComp == null)
return;

var ev = new TelepathyAnnouncementSendEvent(args.Message, comp.TelepathyChannel);
RaiseLocalEvent(ref ev);
*/
var ev = new TelepathyAnnouncementSendEvent(args.Message, ruleComp.TelepathyChannel);
RaiseLocalEvent(args.Entity, ev, true);
}
#endregion

Expand Down
Loading

0 comments on commit eff8ec4

Please sign in to comment.