Skip to content

Commit

Permalink
replacement tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Jan 12, 2025
1 parent c609ad4 commit ceec6ff
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 133 deletions.
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 @@ -43,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 @@ -56,18 +59,23 @@ private void OnRemove(Entity<CultYoggSacrificialComponent> ent, ref ComponentRem
private void OnPlayerAttached(Entity<CultYoggSacrificialComponent> ent, ref PlayerAttachedEvent args)
{
_replaceSacrSchedule.Remove(ent);
_announceSchedule.Remove(ent);

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

var meta = MetaData(ent);

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, _timing.CurTime);
_announceSchedule.Add(ent, _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)
Expand All @@ -92,7 +100,7 @@ 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);
Expand All @@ -103,7 +111,7 @@ public override void Update(float frameTime)

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);
Expand Down
13 changes: 6 additions & 7 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void SacraficialReplacement(ref SacraficialReplacementEvent args)
RemComp<CultYoggSacrificialComponent>(args.Entity);

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);
}
private void SetNewSacraficial(CultYoggRuleComponent comp, int tier)
Expand Down Expand Up @@ -428,15 +428,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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ public sealed partial class CultYoggSacrificialComponent : Component
[DataField]
public ProtoId<FactionIconPrototype> StatusIcon { get; set; } = "CultYoggSacraficialTargetIcon";

/// <summary>
/// Tier number required for replacement if it needed
/// </summary>
[DataField]
public int Tier = 0;//initilize as max possible tier

/// <summary>
/// Time required for announcement
/// </summary>
[DataField]
public TimeSpan AnnounceReplacementCooldown = TimeSpan.FromSeconds(120);
/// <summary>
/// Time required for replacement
/// </summary>
[DataField]
public TimeSpan ReplacementCooldown = TimeSpan.FromSeconds(300);


public bool WasSacraficed = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ cult-yogg-migo-cancel-replace = Ми-Го "{$name}" вернулся к служ
cult-yogg-sacraficial-replaced = Жертва "{$name}" была заменена
cult-yogg-sacraficial-may-be-replaced = Жертва "{$name}" потеряла душу, в скором времени она будет заменена
cult-yogg-sacraficial-cant-be-replaced = Жертва "{$name}" смогла вернуться к сознанию, и снова подходит как жертва
cult-yogg-sacraficial-was-replaced = Жертва "{$name}" больше не доступна для жертвоприношения и была заменена
cult-yogg-sacraficial-was-picked = Жертвой был выбран "{$name}"

0 comments on commit ceec6ff

Please sign in to comment.