Skip to content

Commit

Permalink
Merge pull request #10 from Gnomeev/Cult-Storage
Browse files Browse the repository at this point in the history
Cult Heal
  • Loading branch information
SkaldetSkaeg authored Aug 10, 2024
2 parents d5204d7 + 3e39b0c commit 3bca2fc
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 189 deletions.
12 changes: 12 additions & 0 deletions Content.Client/SS220/CultYogg/CultYoggHealSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// © 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.EntitySystems;

namespace Content.Client.SS220.CultYogg;

public sealed partial class CultYoggHealSystem : SharedCultYoggHealSystem
{
public override void Initialize()
{
base.Initialize();
}
}
78 changes: 78 additions & 0 deletions Content.Server/SS220/CultYogg/CultYoggHealSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// © 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.Components;
using Content.Shared.SS220.CultYogg.EntitySystems;
using Content.Server.EUI;
using Content.Server.Ghost;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Mind;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;

namespace Content.Server.SS220.CultYogg;

public sealed class CultYoggHealSystem : SharedCultYoggHealSystem
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly EuiManager _euiManager = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly MobThresholdSystem _mobThreshold = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<CultYoggHealComponent, ComponentStartup>(SetupMiGoHeal);
}
private void SetupMiGoHeal(Entity<CultYoggHealComponent> uid, ref ComponentStartup args)
{
uid.Comp.NextIncidentTime = uid.Comp.TimeBetweenIncidents;
}
public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<CultYoggHealComponent, MobStateComponent>();
while (query.MoveNext(out var uid, out var healComp, out var _))
{
healComp.NextIncidentTime -= frameTime;

if (healComp.NextIncidentTime > 0)
continue;

Heal(uid, healComp);

healComp.NextIncidentTime += healComp.TimeBetweenIncidents;
}
}
public void Heal(EntityUid uid, CultYoggHealComponent component)
{
if (!TryComp<MobStateComponent>(uid, out var mobComp))
return;

if (!TryComp<DamageableComponent>(uid, out var damageableComp))
return;

_damageable.TryChangeDamage(uid, component.Heal, true, interruptsDoAfters: false, damageableComp);

if (!_mobState.IsDead(uid, mobComp))
return;

if (_mobThreshold.TryGetDeadThreshold(uid, out var threshold) && damageableComp.TotalDamage < threshold)
{
_mobState.ChangeMobState(uid, MobState.Critical);
_popup.PopupEntity(Loc.GetString("cult-yogg-resurrected-by-heal", ("target", uid)), uid, PopupType.Medium);

if (!_mind.TryGetMind(uid, out var _, out var mind))
return;

if (mind.Session != null && mind.CurrentEntity != uid)
_euiManager.OpenEui(new ReturnToBodyEui(mind, _mind), mind.Session);
}
}

}
133 changes: 0 additions & 133 deletions Content.Server/SS220/CultYogg/MiGoHealSystem.cs

This file was deleted.

34 changes: 34 additions & 0 deletions Content.Shared/SS220/CultYogg/Components/CultYoggHealComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Robust.Shared.GameStates;
using System.Text.Json.Serialization;
using Content.Shared.Damage;

namespace Content.Shared.SS220.CultYogg.Components;

[RegisterComponent, NetworkedComponent]
public sealed partial class CultYoggHealComponent : Component
{
/// <summary>
/// Damage that heals in a single incident
/// </summary>
[DataField(required: true)]
public DamageSpecifier Heal = new DamageSpecifier // god forgive me for hardcoding values
{
DamageDict = new()
{
{ "Slash", -6 },
{ "Blunt", -6 },
{ "Piercing", -6},
{"Heat", -4},
{"Cold", -4},
{"Shock", -4},
{"Airloss", -5},
}
};
/// <summary>
/// Time between each healing incident
/// </summary>
public float TimeBetweenIncidents = 2.5f; // most balanced value

public float NextIncidentTime;
}
2 changes: 1 addition & 1 deletion Content.Shared/SS220/CultYogg/Components/MiGoComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public sealed partial class MiGoComponent : Component
public string RequiedEffect = "Rave";

//How long heal effect will occure
public float HealingEffectTime = 100;
public float HealingEffectTime = 15;

//Astral variables
[ViewVariables, AutoNetworkedField]
Expand Down
20 changes: 0 additions & 20 deletions Content.Shared/SS220/CultYogg/Components/MiGoHealComponent.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// © 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.StatusEffect;
using Content.Shared.SS220.CultYogg.Components;
using Content.Shared.Damage;

namespace Content.Shared.SS220.CultYogg.EntitySystems;

public abstract class SharedMiGoHealSystem : EntitySystem
public abstract class SharedCultYoggHealSystem : EntitySystem
{
[ValidatePrototypeId<StatusEffectPrototype>]
public const string EffectkKey = "MiGoHeal";
Expand All @@ -14,24 +15,19 @@ public abstract class SharedMiGoHealSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MiGoComponent, MiGoSetHealStatusEvent>(SetupMiGoHeal);//IDK if its good to recieve it from another component
}
private void SetupMiGoHeal(Entity<MiGoComponent> uid, ref MiGoSetHealStatusEvent args)
public void TryApplyMiGoHeal(EntityUid uid, float time, StatusEffectsComponent? statusComp = null)
{
TryApplyMiGoHeal(uid, args.HealTime);
}
public void TryApplyMiGoHeal(EntityUid uid, float time, StatusEffectsComponent? status = null)
{
if (!Resolve(uid, ref status, false))
if (!Resolve(uid, ref statusComp, false))
return;

if (!_statusEffectsSystem.HasStatusEffect(uid, EffectkKey, status))
if (!_statusEffectsSystem.HasStatusEffect(uid, EffectkKey, statusComp))
{
_statusEffectsSystem.TryAddStatusEffect<MiGoHealComponent>(uid, EffectkKey, TimeSpan.FromSeconds(time), true, status);
_statusEffectsSystem.TryAddStatusEffect<CultYoggHealComponent>(uid, EffectkKey, TimeSpan.FromSeconds(time), true, statusComp);
}
else
{
_statusEffectsSystem.TryAddTime(uid, EffectkKey, TimeSpan.FromSeconds(time), status);
_statusEffectsSystem.TryAddTime(uid, EffectkKey, TimeSpan.FromSeconds(time), statusComp);
}
}

Expand All @@ -44,23 +40,3 @@ public void TryRemoveMiGoHealTime(EntityUid uid, double timeRemoved)
_statusEffectsSystem.TryRemoveTime(uid, EffectkKey, TimeSpan.FromSeconds(timeRemoved));
}
}

/// <summary>
/// Event that is raised whenever someone is implanted with any given implant.
/// Raised on the the implant entity.
/// </summary>
/// <remarks>
/// implant implant implant implant
/// </remarks>
[ByRefEvent]
public readonly struct MiGoSetHealStatusEvent
{
public readonly EntityUid Target;
public readonly float HealTime;

public MiGoSetHealStatusEvent(EntityUid target, float healTime)
{
Target = target;
HealTime = healTime;
}
}
12 changes: 8 additions & 4 deletions Content.Shared/SS220/CultYogg/EntitySystems/SharedMiGoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public abstract class SharedMiGoSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedCultYoggHealSystem _heal = default!;

//[Dependency] private readonly CultYoggRuleSystem _cultYoggRule = default!; //maybe use this for enslavement

Expand Down Expand Up @@ -321,11 +322,14 @@ private void MiGoHeal(Entity<MiGoComponent> uid, ref MiGoHealEvent args)
if (args.Handled)
return;

//unregistred errors idk how to fix
//_entityManager.System<SharedMiGoHealSystem>().TryApplyMiGoHeal(args.Target, uid.Comp.HealingEffectTime);
if (!HasComp<CultYoggComponent>(args.Target))
{
if (_net.IsServer)
_popup.PopupEntity(Loc.GetString("cult-yogg-heal-only-cultists"), uid);
return;
}

var ev = new MiGoSetHealStatusEvent(args.Target, uid.Comp.HealingEffectTime);
RaiseLocalEvent(uid, ref ev);
_heal.TryApplyMiGoHeal(args.Target, uid.Comp.HealingEffectTime);

args.Handled = true;
}
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/ss220/cultYogg/cult_yogg_popups.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cult-yogg-digest-no-nutritions = Недостаточно питательных
cult-yogg-altar-not-enough-migo = Недостаточно Ми-Го рядом с алтарём
cult-yogg-sacrifice-started = {$user} начинает жертвоприношение, тело {$target} медленно поднимается в воздух
cult-yogg-buckle-attempt = {$user} не является целью жертвоприношения
cult-yogg-resurrected-by-heal = Мистические силы возвращают к жизнь {$target}

0 comments on commit 3bca2fc

Please sign in to comment.