Skip to content

Commit

Permalink
aftermerge icon fix + force acsension
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaldetSkaeg committed Sep 8, 2024
1 parent d11342c commit f372bd5
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Content.Client/SS220/CultYogg/ShowCultYoggIconSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override void Initialize()
SubscribeLocalEvent<CultYoggSacrificialComponent, GetStatusIconsEvent>(OnGetSacraficialIconsEvent);
}

private void OnGetCultistsIconsEvent(EntityUid uid, ShowCultYoggIconsComponent _, ref GetStatusIconsEvent ev)
private void OnGetCultistsIconsEvent(Entity<ShowCultYoggIconsComponent> uid, ref GetStatusIconsEvent ev)
{
var iconId = JobIconForNoId;

Expand All @@ -32,12 +32,12 @@ private void OnGetCultistsIconsEvent(EntityUid uid, ShowCultYoggIconsComponent _
iconId = cultComp.StatusIcon;
}

if (_prototype.TryIndex<StatusIconPrototype>(iconId, out var iconPrototype))
if (_prototype.TryIndex<FactionIconPrototype>(iconId, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype);
else
Log.Error($"Invalid job icon prototype: {iconPrototype}");
}
private void OnGetSacraficialIconsEvent(EntityUid uid, CultYoggSacrificialComponent _, ref GetStatusIconsEvent ev)
private void OnGetSacraficialIconsEvent(Entity<CultYoggSacrificialComponent> uid, ref GetStatusIconsEvent ev)
{
var viewer = _playerManager.LocalSession?.AttachedEntity;
if (viewer == uid)
Expand All @@ -50,7 +50,7 @@ private void OnGetSacraficialIconsEvent(EntityUid uid, CultYoggSacrificialCompon
iconId = sacrComp.StatusIcon;
}

if (_prototype.TryIndex<StatusIconPrototype>(iconId, out var iconPrototype))
if (_prototype.TryIndex<FactionIconPrototype>(iconId, out var iconPrototype))
ev.StatusIcons.Add(iconPrototype);
else
Log.Error($"Invalid job icon prototype: {iconPrototype}");
Expand Down
3 changes: 1 addition & 2 deletions Content.Server/SS220/CultYogg/CultYoggSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Content.Shared.SS220.CultYogg.Components;
using Content.Shared.SS220.CultYogg.EntitySystems;
using Robust.Shared.Timing;
using System;

namespace Content.Server.SS220.CultYogg;

Expand Down Expand Up @@ -60,7 +59,7 @@ public override void Initialize()
private bool AvaliableMiGoCheck()
{
//Check number of MiGo in gamerule
_cultRule.GetCultGameRuleComp(out var ruleComp);
_cultRule.GetCultGameRule(out var cultRuleEnt, out var ruleComp);

if (ruleComp is null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ private void OnCompInit(Entity<NyarlathotepSearchTargetsComponent> uid, ref Comp
{
var selectedSong = _audio.GetSound(uid.Comp.SummonMusic);
if (!string.IsNullOrEmpty(selectedSong))
_sound.DispatchStationEventMusic(uid, selectedSong, StationEventMusicType.Nuke);
_sound.DispatchStationEventMusic(uid, selectedSong, StationEventMusicType.Nuke);//ToDo should i rename?

var ev = new CultYoggSummonedEvent();
var ev = new CultYoggSummonedEvent(uid);
RaiseLocalEvent(uid, ref ev, true);
}

Expand Down Expand Up @@ -96,8 +96,15 @@ private void TargetSearch(EntityUid uid, NyarlathotepSearchTargetsComponent comp
/// Raised when god summoned to markup winning
/// </summary>
[ByRefEvent, Serializable]
public record struct CultYoggSummonedEvent;
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
30 changes: 24 additions & 6 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
using static System.Net.Mime.MediaTypeNames;
using System.Xml.Linq;
using Content.Server.SS220.CultYogg.Nyarlathotep.Components;
using static Content.Shared.SS220.CultYogg.EntitySystems.SharedCultYoggSystem;
using Content.Shared.PDA;

namespace Content.Server.SS220.GameTicking.Rules;

Expand Down Expand Up @@ -228,7 +230,7 @@ private List<EntityUid> GetAliveHumans()//maybe add here sacraficials and cultis

private void SacraficialReplacement(ref SacraficialReplacementEvent args)
{
GetCultGameRuleComp(out var cultRuleComp);
GetCultGameRule(out var cultRuleEnt, out var cultRuleComp);

if (cultRuleComp == null)
return;
Expand Down Expand Up @@ -274,14 +276,12 @@ private void MiGoEnslave(ref CultYoggEnslavedEvent args)
if (args.Target == null)
return;

GetCultGameRuleComp(out var cultRuleComp);
GetCultGameRule(out var cultRuleEnt, out var cultRuleComp);

if (cultRuleComp == null)
return;

MakeCultist(args.Target.Value, cultRuleComp, false);

//args.Handled = true;
}
#endregion

Expand Down Expand Up @@ -326,13 +326,29 @@ public bool MakeCultist(EntityUid uid, CultYoggRuleComponent component, bool ini
#endregion

#region RoundEnding
private void OnGodSummoned(ref CultYoggSummonedEvent ev)
private void OnGodSummoned(ref CultYoggSummonedEvent args)
{
foreach (var station in _station.GetStations())
{
_chat.DispatchStationAnnouncement(station, Loc.GetString("cult-yogg-shuttle-call"), colorOverride: Color.Crimson);
}
_roundEnd.RequestRoundEnd(DefaultShuttleArriving, null);

GetCultGameRule(out var cultRuleEnt, out var cultRuleComp);

if (cultRuleEnt == null || cultRuleComp == null)
return;

cultRuleComp.Summoned = true;//Win EndText

var ev = new CultYoggForceAscendingEvent();

//Event hadn't raised on Cultists even with broadcast, so i made this
var query = EntityQueryEnumerator<CultYoggComponent>();
while (query.MoveNext(out var ent, out var comp))
{
RaiseLocalEvent(ent, ref ev);//Make all cultists MiGo
}
}

#endregion
Expand Down Expand Up @@ -405,13 +421,15 @@ private float GetCultistsFraction()
}
#endregion

public void GetCultGameRuleComp(out CultYoggRuleComponent? comp)
public void GetCultGameRule(out EntityUid? ent, out CultYoggRuleComponent? comp)
{
comp = null;
ent = null;
var query = QueryActiveRules();
while (query.MoveNext(out var uid, out _, out var cultComp, out _))
{
comp = cultComp;
ent = uid;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Initialize()
//check if gamerule was rewritten
private void OnInit(Entity<CultYoggSummonConditionComponent> ent, ref ComponentInit args)
{
_cultRule.GetCultGameRuleComp(out var ruleComp);
_cultRule.GetCultGameRule(out var cultRuleEnt, out var ruleComp);

if (ruleComp is null)
return;
Expand Down Expand Up @@ -60,7 +60,7 @@ private void OnAfterAssign(Entity<CultYoggSummonConditionComponent> ent, ref Obj
}
private void OnGetProgress(Entity<CultYoggSummonConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
_cultRule.GetCultGameRuleComp(out var ruleComp);
_cultRule.GetCultGameRule(out var cultRuleEnt, out var ruleComp);

if (ruleComp is null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Initialize()
//check if gamerule was rewritten
private void OnInit(Entity<MiGoAliveConditionComponent> ent, ref ComponentInit args)
{
_cultRule.GetCultGameRuleComp(out var ruleComp);
_cultRule.GetCultGameRule(out var cultRuleEnt, out var ruleComp);

if (ruleComp is null)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed partial class CultYoggSacrificialComponent : Component
public bool IconVisibleToGhost { get; set; } = true;

[DataField]
public ProtoId<StatusIconPrototype> StatusIcon = "CultYoggSacraficialTarget";
public ProtoId<FactionIconPrototype> StatusIcon { get; set; } = "CultYoggSacraficialTarget";

public int Tier = 0;//initilize as max possible tier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public sealed partial class ShowCultYoggIconsComponent : Component
/// Cultists icon
/// </summary>
[DataField]
public ProtoId<StatusIconPrototype> StatusIcon = "CultYoggFaction";
public ProtoId<FactionIconPrototype> StatusIcon = "CultYoggFaction";
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public override void Initialize()
SubscribeLocalEvent<CultYoggComponent, CultYoggCorruptItemEvent>(CorruptItemAction);
SubscribeLocalEvent<CultYoggComponent, CultYoggCorruptItemInHandEvent>(CorruptItemInHandAction);
SubscribeLocalEvent<CultYoggComponent, CultYoggAscendingEvent>(AscendingAction);

SubscribeLocalEvent<CultYoggComponent, CultYoggForceAscendingEvent>(ForcedAcending);
}

protected virtual void OnCompInit(Entity<CultYoggComponent> uid, ref ComponentStartup args)
Expand All @@ -66,6 +68,7 @@ protected virtual void OnCompInit(Entity<CultYoggComponent> uid, ref ComponentSt
}
}

#region Stage
private void UpdateStage(EntityUid uid, CultYoggComponent component)
{
//rework stage's update for cultist's
Expand Down Expand Up @@ -143,7 +146,7 @@ private void OnExamined(EntityUid uid, CultYoggComponent component, ExaminedEven

args.PushMarkup($"[color=green]{Loc.GetString("Глаза горят неестественно зелёным пламенем", ("ent", uid))}[/color]"); // no locale for right now
}

#endregion
#region Puke
private void PukeAction(Entity<CultYoggComponent> uid, ref CultYoggPukeShroomEvent args)
{
Expand Down Expand Up @@ -261,5 +264,26 @@ private void AscendingAction(Entity<CultYoggComponent> uid, ref CultYoggAscendin
if (TryComp<BodyComponent>(uid, out var body))
_body.GibBody(uid, body: body);
}
private void ForcedAcending(Entity<CultYoggComponent> uid, ref CultYoggForceAscendingEvent args)
{
if (_net.IsClient)
return;

if (TerminatingOrDeleted(uid))
return;

// Get original body position and spawn MiGo here
var migo = _entityManager.SpawnAtPosition(uid.Comp.AscendedEntity, Transform(uid).Coordinates);

// Move the mind if there is one and it's supposed to be transferred
if (_mind.TryGetMind(uid, out var mindId, out var mind))
_mind.TransferTo(mindId, migo, mind: mind);

//Gib original body
if (TryComp<BodyComponent>(uid, out var body))
_body.GibBody(uid, body: body);
}
[ByRefEvent, Serializable]
public record struct CultYoggForceAscendingEvent;
#endregion
}
4 changes: 2 additions & 2 deletions Resources/Prototypes/SS220/StatusIcon/antag.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

- type: statusIcon
- type: factionIcon
id: CultYoggFaction
priority: 11
showTo:
Expand All @@ -12,7 +12,7 @@
sprite: /Textures/SS220/Interface/Misc/cult_yogg_icons.rsi
state: cult_yogg

- type: statusIcon
- type: factionIcon
id: CultYoggSacraficialTarget
priority: 3
showTo:
Expand Down

0 comments on commit f372bd5

Please sign in to comment.