Skip to content

Commit

Permalink
Purifying tweaks and add DeCult reminder (#2424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 authored Dec 29, 2024
1 parent 96ae10f commit 79507cf
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,45 @@ namespace Content.Client.SS220.CultYogg.Cultists;

/// <summary>
/// </summary>
public sealed class CleansingVisualizerSystem : VisualizerSystem<CultYoggCleansedComponent>
public sealed class PurifyingVisualizerSystem : VisualizerSystem<CultYoggPurifiedComponent>
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<CultYoggCleansedComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<CultYoggCleansedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<CultYoggPurifiedComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<CultYoggPurifiedComponent, ComponentShutdown>(OnShutdown);
}

private void OnShutdown(Entity<CultYoggCleansedComponent> uid, ref ComponentShutdown args)
private void OnShutdown(Entity<CultYoggPurifiedComponent> uid, ref ComponentShutdown args)
{
// Need LayerMapTryGet because Init fails if there's no existing sprite / appearancecomp
// which means in some setups (most frequently no AppearanceComp) the layer never exists.
if (TryComp<SpriteComponent>(uid, out var sprite) &&
sprite.LayerMapTryGet(CleansingVisualLayers.Particles, out var layer))
sprite.LayerMapTryGet(PurifyingVisualLayers.Particles, out var layer))
{
sprite.RemoveLayer(layer);
}
}

private void OnComponentInit(Entity<CultYoggCleansedComponent> uid, ref ComponentInit args)
private void OnComponentInit(Entity<CultYoggPurifiedComponent> uid, ref ComponentInit args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite) || !TryComp(uid, out AppearanceComponent? appearance))
return;

sprite.LayerMapReserveBlank(CleansingVisualLayers.Particles);
sprite.LayerSetVisible(CleansingVisualLayers.Particles, true);
sprite.LayerSetShader(CleansingVisualLayers.Particles, "unshaded");
sprite.LayerMapReserveBlank(PurifyingVisualLayers.Particles);
sprite.LayerSetVisible(PurifyingVisualLayers.Particles, true);
sprite.LayerSetShader(PurifyingVisualLayers.Particles, "unshaded");

if (uid.Comp.Sprite != null)
{
sprite.LayerSetRSI(CleansingVisualLayers.Particles, uid.Comp.Sprite.RsiPath);
sprite.LayerSetState(CleansingVisualLayers.Particles, uid.Comp.Sprite.RsiState);
sprite.LayerSetRSI(PurifyingVisualLayers.Particles, uid.Comp.Sprite.RsiPath);
sprite.LayerSetState(PurifyingVisualLayers.Particles, uid.Comp.Sprite.RsiState);
}
}
}

public enum CleansingVisualLayers : byte
public enum PurifyingVisualLayers : byte
{
Particles
}
32 changes: 32 additions & 0 deletions Content.Client/SS220/CultYogg/DeCultReminder/DeCultReminderEui.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Client.Eui;
using JetBrains.Annotations;
using Robust.Client.Graphics;

namespace Content.Client.SS220.CultYogg.DeCultReminder
{
[UsedImplicitly]
public sealed class DeCultReminderEui : BaseEui
{
private readonly DeCultReminderWindow _window;

public DeCultReminderEui()
{
_window = new();

_window.AcceptButton.OnPressed += _ => _window.Close();
}

public override void Opened()
{
IoCManager.Resolve<IClyde>().RequestWindowAttention();
_window.OpenCentered();
}

public override void Closed()
{
_window.Close();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using System.Numerics;


namespace Content.Client.SS220.CultYogg.DeCultReminder
{
public sealed class DeCultReminderWindow : DefaultWindow
{
public readonly Button AcceptButton;

public DeCultReminderWindow()
{
Title = Loc.GetString("decult-reminder-window-title");

Contents.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
(new Label()
{
Text = Loc.GetString("decult-reminder-window-text")
}),
new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Align = AlignMode.Center,
Children =
{
(AcceptButton = new Button
{
Text = Loc.GetString("decult-reminder-window-accept-button"),
}),

(new Control()
{
MinSize = new Vector2(20, 0)
}),
}
},
}
},
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
// © 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.Atmos;
using Content.Shared.SS220.CultYogg.Cultists;
using Robust.Shared.Map;
using Robust.Shared.Timing;

namespace Content.Server.SS220.CultYogg.Cultists;

public sealed class CultYoggCleansedSystem : EntitySystem
public sealed class CultYoggPurifiedSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<CultYoggCleansedComponent>();
var query = EntityQueryEnumerator<CultYoggPurifiedComponent>();
while (query.MoveNext(out var uid, out var cleansedComp))
{
if (_timing.CurTime < cleansedComp.CleansingDecayEventTime)
if (_timing.CurTime < cleansedComp.PurifyingDecayEventTime)
continue;

RemComp<CultYoggCleansedComponent>(uid);
RemComp<CultYoggPurifiedComponent>(uid);
}
}
}
25 changes: 15 additions & 10 deletions Content.Server/SS220/CultYogg/Cultists/CultYoggSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using Robust.Shared.Audio.Systems;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs;
using Robust.Shared.Network;
using Content.Shared.SS220.Roles;

namespace Content.Server.SS220.CultYogg.Cultists;

Expand Down Expand Up @@ -295,7 +297,7 @@ public bool TryStartAscensionByReagent(EntityUid uid, CultYoggComponent comp)
private bool AvaliableMiGoCheck()
{
//Check number of MiGo in gamerule
_cultRule.GetCultGameRule(out var ruleComp);
var ruleComp = _cultRule.GetCultGameRule();

if (ruleComp is null)
return false;
Expand Down Expand Up @@ -343,23 +345,26 @@ private bool TryReplaceMiGo()
return true;
}
#endregion
private void OnSaintWaterDrinked(Entity<CultYoggComponent> uid, ref OnSaintWaterDrinkEvent args)

#region Purifying
private void OnSaintWaterDrinked(Entity<CultYoggComponent> entity, ref OnSaintWaterDrinkEvent args)
{
EnsureComp<CultYoggCleansedComponent>(uid, out var cleansedComp);
cleansedComp.AmountOfHolyWater += args.SaintWaterAmount;
EnsureComp<CultYoggPurifiedComponent>(entity, out var purifyedComp);
purifyedComp.TotalAmountOfHolyWater += args.SaintWaterAmount;

if (cleansedComp.AmountOfHolyWater >= cleansedComp.AmountToCleance)
if (purifyedComp.TotalAmountOfHolyWater >= purifyedComp.AmountToPurify)
{
//After cleansing effect
_audio.PlayEntity(cleansedComp.CleansingCollection, uid, uid);
//After purifying effect
_audio.PlayEntity(purifyedComp.PurifyingCollection, entity, entity);

//Removing stage visuals, cause later component will be removed
var ev = new CultYoggDeleteVisualsEvent();
RaiseLocalEvent(uid, ref ev);
RaiseLocalEvent(entity, ref ev);

RemComp<CultYoggComponent>(uid);
RemComp<CultYoggComponent>(entity);
}

cleansedComp.CleansingDecayEventTime = _timing.CurTime + cleansedComp.BeforeDeclinesTime; //setting timer, when cleansing will be removed
purifyedComp.PurifyingDecayEventTime = _timing.CurTime + purifyedComp.BeforeDeclinesTime; //setting timer, when purifying will be removed
}
#endregion
}
10 changes: 10 additions & 0 deletions Content.Server/SS220/CultYogg/DeCultReminder/DeCultReminderEui.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Server.EUI;

namespace Content.Server.SS220.CultYogg.DeCultReminder
{
public sealed class DeCultReminderEui : BaseEui
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Effect(EntityEffectBaseArgs args)
{
if (entityManager.TryGetComponent<CultYoggComponent>(args.TargetEntity, out var comp))
{
entityManager.RemoveComponent<CultYoggCleansedComponent>(args.TargetEntity);
entityManager.RemoveComponent<CultYoggPurifiedComponent>(args.TargetEntity);

comp.ConsumedAscensionReagent += reagentArgs.Quantity.Float();
entityManager.System<CultYoggSystem>().TryStartAscensionByReagent(args.TargetEntity, comp);
Expand Down
39 changes: 30 additions & 9 deletions Content.Server/SS220/GameTicking/Rules/CultYoggRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
using Content.Server.AlertLevel;
using Robust.Shared.Player;
using Robust.Shared.Map;
using Content.Server.EUI;
using Robust.Server.Player;
using Content.Server.SS220.CultYogg.DeCultReminder;

namespace Content.Server.SS220.GameTicking.Rules;

Expand All @@ -62,6 +65,8 @@ public sealed class CultYoggRuleSystem : GameRuleSystem<CultYoggRuleComponent>
[Dependency] private readonly ServerGlobalSoundSystem _sound = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly AlertLevelSystem _alertLevel = default!;
[Dependency] private readonly EuiManager _euiManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

private List<List<string>> _sacraficialTiers = [];
public TimeSpan DefaultShuttleArriving { get; set; } = TimeSpan.FromSeconds(85);
Expand Down Expand Up @@ -280,7 +285,7 @@ private void OnTargetSacrificed(Entity<CultYoggRuleComponent> entity, ref CultYo

private void SacraficialReplacement(ref SacraficialReplacementEvent args)
{
GetCultGameRule(out var cultRuleComp);
var cultRuleComp = GetCultGameRule();

if (cultRuleComp == null)
return;
Expand Down Expand Up @@ -330,7 +335,7 @@ private void MiGoEnslave(ref CultYoggEnslavedEvent args)
if (args.Target == null)
return;

GetCultGameRule(out var cultRuleComp);
var cultRuleComp = GetCultGameRule();

if (cultRuleComp == null)
return;
Expand Down Expand Up @@ -386,22 +391,29 @@ public void MakeCultist(EntityUid uid, CultYoggRuleComponent comp, bool initial

private void DeCult(ref CultYoggDeCultingEvent args)
{
GetCultGameRule(out var cultRuleComp);//ToDo bug potentialy if somebody will make cultist without gamerule, ask head dev
var cultRuleComp = GetCultGameRule();//ToDo bug potentialy if somebody will make cultist without gamerule, ask head dev

if (cultRuleComp == null)
return;

DeMakeCultist(args.Entity, cultRuleComp);
}

public void DeMakeCultist(EntityUid uid, CultYoggRuleComponent component)
{
if (!_mind.TryGetMind(uid, out var mindId, out var mindComp))
return;

if (!_role.MindHasRole<CultYoggRoleComponent>(mindId, out var mindSlave))
if (!_role.MindHasRole<CultYoggRoleComponent>(mindId, out var cultRoleEnt))
return;

// _mind.TryRemoveObjective(mindId, mindComp, objective.Value);
foreach (var obj in component.ListofObjectives)
{
if (!_mind.TryFindObjective(mindId, obj, out var objUid))
continue;

_mind.TryRemoveObjective(mindId, mindComp, objUid.Value);
}

_role.MindRemoveRole<CultYoggRoleComponent>(mindId);

Expand All @@ -418,6 +430,12 @@ public void DeMakeCultist(EntityUid uid, CultYoggRuleComponent component)

RemComp<ShowCultYoggIconsComponent>(uid);
RemComp<ZombieImmuneComponent>(uid);

if (mindComp.UserId != null &&
_playerManager.TryGetSessionById(mindComp.UserId.Value, out var session))
{
_euiManager.OpenEui(new DeCultReminderEui(), session);
}
}
#endregion

Expand Down Expand Up @@ -522,14 +540,17 @@ private float GetCultistsFraction()
}
#endregion

public void GetCultGameRule(out CultYoggRuleComponent? comp)
public CultYoggRuleComponent? GetCultGameRule()
{
comp = null;
var query = QueryActiveRules();
while (query.MoveNext(out _, out _, out var cultComp, out _))
CultYoggRuleComponent? comp = null;

var query = QueryAllRules();
while (query.MoveNext(out _, out var cultComp, out _))
{
comp = cultComp;
}

return comp;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void OnGetProgress(Entity<CultYoggSummonConditionComponent> ent, ref Obj
{
args.Progress = 0;

_cultRule.GetCultGameRule(out var ruleComp);
var ruleComp = _cultRule.GetCultGameRule();

if (ruleComp is null)
return;
Expand All @@ -62,7 +62,7 @@ private void OnGetProgress(Entity<CultYoggSummonConditionComponent> ent, ref Obj

private void TaskNumberUpdate(Entity<CultYoggSummonConditionComponent> ent)
{
_cultRule.GetCultGameRule(out var ruleComp);
var ruleComp = _cultRule.GetCultGameRule();

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.GetCultGameRule(out var ruleComp);
var ruleComp = _cultRule.GetCultGameRule();

if (ruleComp is null)
return;
Expand Down
Loading

0 comments on commit 79507cf

Please sign in to comment.