Skip to content

Commit

Permalink
Add warning anouncement
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Dec 28, 2024
1 parent 2a86b5f commit 1ce6e2e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 41 deletions.
8 changes: 4 additions & 4 deletions Content.Server/SS220/CultYogg/Altar/CultYoggAltarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ private void OnDoAfter(Entity<CultYoggAltarComponent> ent, ref MiGoSacrificeDoAf
int stage = 0;

var query = EntityQueryEnumerator<GameRuleComponent, CultYoggRuleComponent>();
while (query.MoveNext(out _, out var cultRule))
while (query.MoveNext(out var uid, out _, out var cultRule))
{
stage = ++cultRule.AmountOfSacrifices;
var ev = new CultYoggSacrificedTargetEvent(ent);
RaiseLocalEvent(uid, ref ev);

if (cultRule.AmountOfSacrifices == cultRule.ReqAmountOfSacrifices)
Spawn(ent.Comp.GodEnt, Transform(ent).Coordinates);
stage = cultRule.AmountOfSacrifices;
}

//sending all cultists updating stage event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NyarlathotepSearchTargetsComponent, MapInitEvent>(OnSearchMapInit);

SubscribeLocalEvent<NyarlathotepSearchTargetsComponent, ComponentStartup>(OnCompInit);
}

private void OnCompInit(Entity<NyarlathotepSearchTargetsComponent> uid, ref ComponentStartup args)
{
var ev = new CultYoggSummonedEvent(uid);
RaiseLocalEvent(uid, ref ev, true);
}

/// <summary>
Expand Down Expand Up @@ -78,19 +70,6 @@ public override void Update(float frameTime)
}
}

/// <summary>
/// Raised when god summoned to markup winning
/// </summary>
[ByRefEvent, Serializable]
public sealed class CultYoggSummonedEvent : EntityEventArgs
{
public readonly EntityUid Entity;

public CultYoggSummonedEvent(EntityUid entity)
{
Entity = entity;
}
}
/// <summary>
/// Component for entities to be attacked by Nyarlathotep.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.SS220.GameTicking.Rules.Components;

Expand All @@ -14,7 +15,10 @@ public sealed partial class CultYoggRuleComponent : Component
/// General requirements
/// </summary>
[DataField]
public int ReqAmountOfSacrifices = 3;
public int AmountOfSacrificesToGodSummon = 3;

[DataField]
public int AmountOfSacrificesToWarningAnouncement = 2;

[DataField]
public int ReqAmountOfMiGo = 3;
Expand Down Expand Up @@ -62,6 +66,9 @@ public sealed partial class CultYoggRuleComponent : Component
[ValidatePrototypeId<EntityPrototype>]
public string MindCultYoggAntagId = "MindRoleCultYogg";

[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string GodPrototype = "MobNyarlathotep";

//telephaty channel
[DataField]
public string TelepathyChannel = "TelepathyChannelYoggSothothCult";
Expand Down
43 changes: 32 additions & 11 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
using Content.Server.Pinpointer;
using Content.Server.Audio;
using Robust.Shared.Audio.Systems;
using Content.Server.AlertLevel;
using Robust.Shared.Player;
using Robust.Shared.Map;

namespace Content.Server.SS220.GameTicking.Rules;

Expand All @@ -58,6 +61,7 @@ public sealed class CultYoggRuleSystem : GameRuleSystem<CultYoggRuleComponent>
[Dependency] private readonly NavMapSystem _navMap = default!;
[Dependency] private readonly ServerGlobalSoundSystem _sound = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly AlertLevelSystem _alertLevel = default!;

private List<List<string>> _sacraficialTiers = [];
public TimeSpan DefaultShuttleArriving { get; set; } = TimeSpan.FromSeconds(85);
Expand All @@ -72,7 +76,7 @@ public override void Initialize()

SubscribeLocalEvent<SacraficialReplacementEvent>(SacraficialReplacement);

SubscribeLocalEvent<CultYoggSummonedEvent>(OnGodSummoned);
SubscribeLocalEvent<CultYoggRuleComponent, CultYoggSacrificedTargetEvent>(OnTargetSacrificed);

SubscribeLocalEvent<CultYoggAnouncementEvent>(SendCultAnounce);
}
Expand Down Expand Up @@ -254,6 +258,25 @@ private List<EntityUid> GetAliveNoneCultHumans()//maybe add here sacraficials an
#endregion

#region Sacraficials Events
private void OnTargetSacrificed(Entity<CultYoggRuleComponent> entity, ref CultYoggSacrificedTargetEvent args)
{
var (_, comp) = entity;
var (altar, altarComp) = args.Altar;
comp.AmountOfSacrifices++;

if (comp.AmountOfSacrifices == comp.AmountOfSacrificesToWarningAnouncement)
{
foreach (var station in _station.GetStations())
{
_chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-cultists-warning"), playSound: false, colorOverride: Color.Red);
_audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true);
_alertLevel.SetLevel(station, "gamma", true, true, true);
}
}

if (comp.AmountOfSacrifices == comp.AmountOfSacrificesToGodSummon)
SummonGod(entity, Transform(altar).Coordinates);
}

private void SacraficialReplacement(ref SacraficialReplacementEvent args)
{
Expand Down Expand Up @@ -415,27 +438,25 @@ private void SendCultAnounce(ref CultYoggAnouncementEvent args)
#endregion

#region RoundEnding
private void OnGodSummoned(ref CultYoggSummonedEvent args)
private void SummonGod(Entity<CultYoggRuleComponent> entity, EntityCoordinates coordinates)
{
GetCultGameRule(out var cultRuleComp);

if (cultRuleComp == null)
return;
var (_, comp) = entity;
var godUid = Spawn(comp.GodPrototype, coordinates);

foreach (var station in _station.GetStations())
{
_chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-shuttle-call", ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(args.Entity)))), colorOverride: Color.Crimson);
_chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-shuttle-call", ("location", FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(godUid)))), colorOverride: Color.Crimson);
_alertLevel.SetLevel(station, "delta", true, true, true);
}
_roundEnd.RequestRoundEnd(DefaultShuttleArriving, null);

var selectedSong = _audio.GetSound(cultRuleComp.SummonMusic);
var selectedSong = _audio.GetSound(comp.SummonMusic);

if (!string.IsNullOrEmpty(selectedSong))
_sound.DispatchStationEventMusic(args.Entity, selectedSong, StationEventMusicType.Nuke);//should i rename somehow?
_sound.DispatchStationEventMusic(godUid, selectedSong, StationEventMusicType.Nuke);//should i rename somehow?

cultRuleComp.Summoned = true;//Win EndText
comp.Summoned = true;//Win EndText
}

#endregion

#region EndText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void TaskNumberUpdate(Entity<CultYoggSummonConditionComponent> ent)
if (ruleComp is null)
return;

ent.Comp.reqSacrAmount = ruleComp.ReqAmountOfSacrifices;
ent.Comp.reqSacrAmount = ruleComp.AmountOfSacrificesToGodSummon;
}
private void SacraficialsUpdate(Entity<CultYoggSummonConditionComponent> ent)
{
Expand Down
3 changes: 0 additions & 3 deletions Content.Shared/SS220/CultYogg/Altar/CultYoggAltarComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public sealed partial class CultYoggAltarComponent : Component
[DataField]
public bool Used = false;

[DataField]
public string GodEnt = "Nyarlathotep";

[Serializable, NetSerializable]
public enum CultYoggAltarVisuals
{
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/SS220/CultYogg/Cultists/CultYoggEvents.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// © 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.SS220.CultYogg.Altar;

namespace Content.Shared.SS220.CultYogg.Cultists;

/// <summary>
Expand Down Expand Up @@ -32,3 +34,5 @@ public CultYoggDeCultingEvent(EntityUid entity)
[ByRefEvent, Serializable]
public record struct CultYoggForceAscendingEvent;

[ByRefEvent, Serializable]
public record struct CultYoggSacrificedTargetEvent(Entity<CultYoggAltarComponent> Altar);
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ objective-cult-yogg-sacrafice-start = Призовите темного бога
objective-cult-yogg-sacrafice-task-job = в должности
objective-condition-cult-yogg-sacrafice-person = {$targetName}, в должности {CAPITALIZE($job)}
cult-yogg-cultists-warning = Внимание! На станции зафиксировано множественное размножение грибов-паразитов. Совокупность данных с сенсоров подтверждает угрозу культа, ликвидируйте её любой ценой!
cult-yogg-shuttle-call = Датчики станции зафиксировали { $location } гигантский подвижный объект. Аварийный шаттл был отправлен для эвакуации оставшегося персонала.

0 comments on commit 1ce6e2e

Please sign in to comment.