Reorganized some of the new ECS code.
This commit is contained in:
parent
df9f638eee
commit
57d3798fee
|
|
@ -0,0 +1,5 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
|
||||
namespace Content.Client._DV.Pain;
|
||||
|
||||
public abstract class PainSystem : SharedPainSystem;
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Abilities.Psionics;
|
||||
using Content.Server.Psionics;
|
||||
using Content.Shared.Psionics.Glimmer;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// Changes glimmer when reaction happens.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
|
||||
public sealed partial class AffectsGlimmerEntityEffectSystem : EntityEffectSystem<MetaDataComponent, AffectsGlimmer>
|
||||
{
|
||||
[Dependency] private readonly GlimmerSystem _glimmer = default!;
|
||||
protected override void Effect(Entity<MetaDataComponent> entity, ref EntityEffectEvent<AffectsGlimmer> args)
|
||||
{
|
||||
_glimmer.Glimmer += args.Effect.Amount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class AffectsGlimmer : EntityEffectBase<AffectsGlimmer>
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount that is added or subtracted from glimmer.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int Amount = 1;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-change-glimmer-reaction-effect", ("chance", Probability),
|
||||
("amount", Amount));
|
||||
}
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Abilities.Psionics;
|
||||
using Content.Server.Psionics;
|
||||
using Content.Shared.Psionics.Glimmer;
|
||||
using Content.Shared._DV.EntityEffects.Effects.CosmicCult;
|
||||
using Content.Shared._DV.CosmicCult.Components;
|
||||
using Content.Shared.EntityEffects;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects;
|
||||
|
||||
|
|
@ -21,11 +16,4 @@ public sealed partial class CleanseCosmicCultEntityEffectSystem : EntityEffectSy
|
|||
if (_ent.HasComponent<CosmicCultComponent>(entity))
|
||||
_ent.EnsureComponent<CleanseCultComponent>(entity); // We just slap them with the component and let the Deconversion system handle the rest.
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class CleanseCosmicCult : EntityEffectBase<CleanseCosmicCult>
|
||||
{
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-cleanse-cultist", ("chance", Probability));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.Psionics.Glimmer;
|
||||
using Content.Shared._DV.EntityEffects.Effects.Glimmer;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects.Glimmer;
|
||||
|
||||
/// <summary>
|
||||
/// Changes glimmer when reaction happens.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
|
||||
public sealed partial class AffectsGlimmerEntityEffectSystem : EntityEffectSystem<MetaDataComponent, AffectsGlimmer>
|
||||
{
|
||||
[Dependency] private readonly GlimmerSystem _glimmer = default!;
|
||||
protected override void Effect(Entity<MetaDataComponent> entity, ref EntityEffectEvent<AffectsGlimmer> args)
|
||||
{
|
||||
_glimmer.Glimmer += args.Effect.Amount;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared._DV.EntityEffects.Effects.Psionics;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Abilities.Psionics;
|
||||
using Content.Server.Psionics;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects.Psionics;
|
||||
|
||||
/// <summary>
|
||||
/// Removes psionic abilities when at least 1u of the reagent is in the system.
|
||||
|
|
@ -23,11 +24,4 @@ public sealed partial class RemovePsionicAbilitiesEntityEffectSystem : EntityEff
|
|||
_psionicAbilities.RemovePsionics(entity);
|
||||
_psionic.GrantNewPsionicReroll(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class RemovePsionicAbilities : EntityEffectBase<RemovePsionicAbilities>
|
||||
{
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-chem-remove-psionic", ("chance", Probability));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Server.Psionics;
|
||||
using Content.Shared._DV.EntityEffects.Effects.Psionics;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Abilities.Psionics;
|
||||
using Content.Server.Psionics;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._DV.EntityEffects.Effects;
|
||||
namespace Content.Server._DV.EntityEffects.Effects.Psionics;
|
||||
|
||||
/// <summary>
|
||||
/// Rerolls psionic abilities when at least 1u of the reagent is in the system.
|
||||
|
|
@ -21,17 +21,4 @@ public sealed partial class RerollPsionicAbilitiesEntityEffectSystem : EntityEff
|
|||
|
||||
_psionic.RerollPsionics(entity, bonusMuliplier: args.Effect.BonusMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class RerollPsionicAbilities : EntityEffectBase<RerollPsionicAbilities>
|
||||
{
|
||||
/// <summary>
|
||||
/// Reroll multiplier.
|
||||
/// </summary>
|
||||
[DataField("bonusMultiplier")]
|
||||
public float BonusMultiplier = 1f;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-chem-reroll-psionic", ("chance", Probability));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +1,5 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server._DV.Pain;
|
||||
|
||||
public sealed class PainSystem : SharedPainSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PainComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<PainComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.NextUpdateTime = _timing.CurTime;
|
||||
ent.Comp.NextPopupTime = _timing.CurTime;
|
||||
}
|
||||
|
||||
protected override void UpdatePainSuppression(Entity<PainComponent> ent, float duration, PainSuppressionLevel level)
|
||||
{
|
||||
var curTime = _timing.CurTime;
|
||||
var newEndTime = curTime + TimeSpan.FromSeconds(duration);
|
||||
|
||||
// Only update if this would extend the suppression
|
||||
if (newEndTime <= ent.Comp.SuppressionEndTime)
|
||||
return;
|
||||
|
||||
ent.Comp.LastPainkillerTime = curTime;
|
||||
ent.Comp.SuppressionEndTime = newEndTime;
|
||||
UpdateSuppressed(ent);
|
||||
}
|
||||
|
||||
private void UpdateSuppressed(Entity<PainComponent> ent)
|
||||
{
|
||||
ent.Comp.Suppressed = (_timing.CurTime < ent.Comp.SuppressionEndTime);
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
private void ShowPainPopup(Entity<PainComponent> ent)
|
||||
{
|
||||
if (!_prototype.TryIndex(ent.Comp.DatasetPrototype, out var dataset))
|
||||
return;
|
||||
|
||||
var effects = dataset.Values;
|
||||
if (effects.Count == 0)
|
||||
return;
|
||||
|
||||
var effect = _random.Pick(effects);
|
||||
_popup.PopupEntity(Loc.GetString(effect), ent, ent);
|
||||
|
||||
// Set next popup time
|
||||
var delay = _random.NextFloat(ent.Comp.MinimumPopupDelay, ent.Comp.MaximumPopupDelay);
|
||||
ent.Comp.NextPopupTime = _timing.CurTime + TimeSpan.FromSeconds(delay);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var curTime = _timing.CurTime;
|
||||
var query = EntityQueryEnumerator<PainComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var component))
|
||||
{
|
||||
if (curTime < component.NextUpdateTime)
|
||||
continue;
|
||||
|
||||
var ent = new Entity<PainComponent>(uid, component);
|
||||
|
||||
if (component.Suppressed)
|
||||
{
|
||||
UpdateSuppressed(ent);
|
||||
}
|
||||
else if (curTime >= component.NextPopupTime)
|
||||
{
|
||||
ShowPainPopup(ent);
|
||||
}
|
||||
component.NextUpdateTime = curTime + TimeSpan.FromSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
public sealed class PainSystem : SharedPainSystem;
|
||||
|
|
@ -3,7 +3,7 @@ using Content.Shared.EntityEffects;
|
|||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Addiction;
|
||||
|
||||
// TODO: When Addiction is moved to new Status, make this use StatusEffectsContainerComponent.
|
||||
/// <summary>
|
||||
|
|
@ -3,7 +3,7 @@ using Content.Shared.EntityEffects;
|
|||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Addiction;
|
||||
|
||||
// TODO: When Addiction is moved to new Status, make this use StatusEffectsContainerComponent.
|
||||
/// <summary>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.CosmicCult;
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class CleanseCosmicCult : EntityEffectBase<CleanseCosmicCult>
|
||||
{
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-cleanse-cultist", ("chance", Probability));
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Glimmer;
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class AffectsGlimmer : EntityEffectBase<AffectsGlimmer>
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount that is added or subtracted from glimmer.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int Amount = 1;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-change-glimmer-reaction-effect", ("chance", Probability),
|
||||
("amount", Amount));
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ using Content.Shared.EntityEffects;
|
|||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Pain;
|
||||
|
||||
// TODO: When Pain is moved to new Status, make this use StatusEffectsContainerComponent.
|
||||
/// <summary>
|
||||
|
|
@ -3,7 +3,7 @@ using Content.Shared.EntityEffects;
|
|||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Pain;
|
||||
|
||||
// TODO: When Pain is moved to new Status, make this use StatusEffectsContainerComponent.
|
||||
/// <summary>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Psionics;
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class RemovePsionicAbilities : EntityEffectBase<RemovePsionicAbilities>
|
||||
{
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-chem-remove-psionic", ("chance", Probability));
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects.Psionics;
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class RerollPsionicAbilities : EntityEffectBase<RerollPsionicAbilities>
|
||||
{
|
||||
/// <summary>
|
||||
/// Reroll multiplier.
|
||||
/// </summary>
|
||||
[DataField("bonusMultiplier")]
|
||||
public float BonusMultiplier = 1f;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-chem-reroll-psionic", ("chance", Probability));
|
||||
}
|
||||
|
|
@ -1,17 +1,27 @@
|
|||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared._DV.Pain;
|
||||
|
||||
public abstract class SharedPainSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
||||
|
||||
public ProtoId<StatusEffectPrototype> StatusEffectKey = "InPain";
|
||||
|
||||
protected abstract void UpdatePainSuppression(Entity<PainComponent> ent, float duration, PainSuppressionLevel level);
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<PainComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
public virtual void TryApplyPain(EntityUid uid, float painTime, StatusEffectsComponent? status = null)
|
||||
public void TryApplyPain(EntityUid uid, float painTime, StatusEffectsComponent? status = null)
|
||||
{
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return;
|
||||
|
|
@ -26,13 +36,83 @@ public abstract class SharedPainSystem : EntitySystem
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void TrySuppressPain(EntityUid uid, float duration, PainSuppressionLevel level = PainSuppressionLevel.Normal)
|
||||
public void TrySuppressPain(EntityUid uid, float duration, PainSuppressionLevel level = PainSuppressionLevel.Normal)
|
||||
{
|
||||
if (!TryComp<PainComponent>(uid, out var comp))
|
||||
return;
|
||||
|
||||
UpdatePainSuppression((uid, comp), duration, level);
|
||||
}
|
||||
|
||||
protected void UpdatePainSuppression(Entity<PainComponent> ent, float duration, PainSuppressionLevel level)
|
||||
{
|
||||
var curTime = _timing.CurTime;
|
||||
var newEndTime = curTime + TimeSpan.FromSeconds(duration);
|
||||
|
||||
// Only update if this would extend the suppression
|
||||
if (newEndTime <= ent.Comp.SuppressionEndTime)
|
||||
return;
|
||||
|
||||
ent.Comp.LastPainkillerTime = curTime;
|
||||
ent.Comp.SuppressionEndTime = newEndTime;
|
||||
UpdateSuppressed(ent);
|
||||
}
|
||||
|
||||
private void UpdateSuppressed(Entity<PainComponent> ent)
|
||||
{
|
||||
ent.Comp.Suppressed = (_timing.CurTime < ent.Comp.SuppressionEndTime);
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
|
||||
private void OnMapInit(Entity<PainComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.NextUpdateTime = _timing.CurTime;
|
||||
ent.Comp.NextPopupTime = _timing.CurTime;
|
||||
}
|
||||
|
||||
private void ShowPainPopup(Entity<PainComponent> ent)
|
||||
{
|
||||
if (!_prototype.TryIndex(ent.Comp.DatasetPrototype, out var dataset))
|
||||
return;
|
||||
|
||||
var effects = dataset.Values;
|
||||
if (effects.Count == 0)
|
||||
return;
|
||||
|
||||
var effect = _random.Pick(effects);
|
||||
_popup.PopupEntity(Loc.GetString(effect), ent, ent);
|
||||
|
||||
// Set next popup time
|
||||
var delay = _random.NextFloat(ent.Comp.MinimumPopupDelay, ent.Comp.MaximumPopupDelay);
|
||||
ent.Comp.NextPopupTime = _timing.CurTime + TimeSpan.FromSeconds(delay);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var curTime = _timing.CurTime;
|
||||
var query = EntityQueryEnumerator<PainComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var component))
|
||||
{
|
||||
if (curTime < component.NextUpdateTime)
|
||||
continue;
|
||||
|
||||
var ent = new Entity<PainComponent>(uid, component);
|
||||
|
||||
if (component.Suppressed)
|
||||
{
|
||||
UpdateSuppressed(ent);
|
||||
}
|
||||
else if (curTime >= component.NextPopupTime)
|
||||
{
|
||||
ShowPainPopup(ent);
|
||||
}
|
||||
component.NextUpdateTime = curTime + TimeSpan.FromSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used by the StatusEffect
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ reagent-desc-penteticacid = A complicated anti-toxin solution that quickly flush
|
|||
reagent-name-granibitulari = granibitulari
|
||||
reagent-desc-granibitulari = A common, slow-acting medicine for all types of injuries.
|
||||
|
||||
reagent-name-pielovene = pielovene
|
||||
reagent-desc-pielovene = A honk-spectrum anti-toxin, which treats a broad variety of damage in clowns. Harmful to mimes.
|
||||
|
||||
reagent-name-hypothium = hypothium
|
||||
reagent-desc-hypothium = A difficult to synthesize drug used to cure most wounds and clot blood.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue