Converted SupressPain and Suppress Addiction to the new ECS system.
This commit is contained in:
parent
98d9580ae5
commit
4077f006f4
|
|
@ -1,4 +1,4 @@
|
|||
using Content.Shared.StatusEffectNew;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.Addictions;
|
||||
|
|
@ -7,33 +7,34 @@ public abstract class SharedAddictionSystem : EntitySystem
|
|||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
||||
|
||||
public EntProtoId AddictedStatusEffectProto = "Addicted";
|
||||
public ProtoId<StatusEffectPrototype> StatusEffectKey = "Addicted";
|
||||
|
||||
protected abstract void UpdateTime(EntityUid uid);
|
||||
|
||||
public virtual void TryApplyAddiction(Entity<AddictionComponent?> ent, float addictionTime)
|
||||
public virtual void TryApplyAddiction(EntityUid uid, float addictionTime, StatusEffectsComponent? status = null)
|
||||
{
|
||||
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
||||
if (!Resolve(uid, ref status, false))
|
||||
return;
|
||||
|
||||
UpdateTime(ent.Owner);
|
||||
UpdateTime(uid);
|
||||
|
||||
if (!_statusEffects.HasStatusEffect(ent.Owner, StatusEffectKey, ent.Comp))
|
||||
if (!_statusEffects.HasStatusEffect(uid, StatusEffectKey, status))
|
||||
{
|
||||
_statusEffects.TryAddStatusEffect<AddictedComponent>(ent.Owner, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), true, ent.Comp);
|
||||
_statusEffects.TryAddStatusEffect<AddictedComponent>(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), true, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
_statusEffects.TryAddTime(ent.Owner, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), ent.Comp);
|
||||
_statusEffects.TryAddTime(uid, StatusEffectKey, TimeSpan.FromSeconds(addictionTime), status);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TrySuppressAddiction(Entity<AddictedComponent?> ent, float duration)
|
||||
public virtual void TrySuppressAddiction(EntityUid uid, float duration)
|
||||
{
|
||||
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
||||
if (!TryComp<AddictedComponent>(uid, out var comp))
|
||||
return;
|
||||
|
||||
UpdateAddictionSuppression((ent.Owner, ent.Comp), duration);
|
||||
var ent = new Entity<AddictedComponent>(uid, comp);
|
||||
UpdateAddictionSuppression(ent, duration);
|
||||
}
|
||||
|
||||
protected virtual void UpdateAddictionSuppression(Entity<AddictedComponent> ent, float duration)
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
using Content.Shared._DV.Addictions;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
|
||||
public sealed partial class SuppressAddiction : EntityEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// How long should the addiction suppression last for each metabolism cycle
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float SuppressionTime = 30f;
|
||||
|
||||
protected override string ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-addiction-suppression",
|
||||
("chance", Probability));
|
||||
|
||||
public override void Effect(EntityEffectBaseArgs args)
|
||||
{
|
||||
var suppressionTime = SuppressionTime;
|
||||
|
||||
if (args is EntityEffectReagentArgs reagentArgs)
|
||||
{
|
||||
suppressionTime *= reagentArgs.Scale.Float();
|
||||
}
|
||||
|
||||
var addictionSystem = args.EntityManager.System<SharedAddictionSystem>();
|
||||
addictionSystem.TrySuppressAddiction(args.TargetEntity, suppressionTime);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,9 @@ public sealed partial class SuppressAddictionEntityEffectSystem : EntityEffectSy
|
|||
[Dependency] private readonly SharedAddictionSystem _addiction = default!;
|
||||
protected override void Effect(Entity<AddictedComponent> entity, ref EntityEffectEvent<SuppressAddition> args)
|
||||
{
|
||||
// Effect goes here.
|
||||
var suppressionTime = args.Effect.Time * args.Scale;
|
||||
|
||||
_addiction.TrySuppressAddiction(entity.Owner, suppressionTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,10 +23,10 @@ public sealed partial class SuppressAddictionEntityEffectSystem : EntityEffectSy
|
|||
public sealed partial class SuppressAddition : EntityEffectBase<SuppressAddition>
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount we're adjusting temperature by.
|
||||
/// Amount of time that 1u suppresses addiction.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float SuppressionTime = 30;
|
||||
public float Time = 30f;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-addiction-suppression",
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
|
||||
public sealed partial class SuppressPain : EntityEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// How long should the pain suppression last for each metabolism cycle
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float SuppressionTime = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// The strength level of the pain suppression
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public PainSuppressionLevel SuppressionLevel = PainSuppressionLevel.Normal;
|
||||
|
||||
protected override string ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-pain-suppression",
|
||||
("chance", Probability),
|
||||
("level", SuppressionLevel.ToString().ToLowerInvariant()));
|
||||
|
||||
public override void Effect(EntityEffectBaseArgs args)
|
||||
{
|
||||
var suppressionTime = SuppressionTime;
|
||||
|
||||
if (args is EntityEffectReagentArgs reagentArgs)
|
||||
{
|
||||
suppressionTime *= reagentArgs.Scale.Float();
|
||||
}
|
||||
|
||||
var painSystem = args.EntityManager.System<SharedPainSystem>();
|
||||
painSystem.TrySuppressPain(args.TargetEntity, suppressionTime, SuppressionLevel);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using Content.Shared._DV.Pain;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.EntityEffects.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// A brief summary of the effect.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="EntityEffectSystem{T, TEffect}"/>
|
||||
public sealed partial class SuppressPainEntityEffectSystem : EntityEffectSystem<PainComponent, SuppressPain>
|
||||
{
|
||||
[Dependency] private readonly SharedPainSystem _pain = default!;
|
||||
protected override void Effect(Entity<PainComponent> entity, ref EntityEffectEvent<SuppressPain> args)
|
||||
{
|
||||
var suppressionTime = args.Effect.Time * args.Scale;
|
||||
|
||||
_pain.TrySuppressPain(entity, suppressionTime, args.Effect.Level);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EntityEffect"/>
|
||||
public sealed partial class SuppressPain : EntityEffectBase<SuppressPain>
|
||||
{
|
||||
/// <summary>
|
||||
/// How long should the pain suppression last for each metabolism cycle
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Time = 30f;
|
||||
|
||||
/// <summary>
|
||||
/// The strength level of the pain suppression.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public PainSuppressionLevel Level = PainSuppressionLevel.Normal;
|
||||
|
||||
public override string? EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString("reagent-effect-guidebook-pain-suppression",
|
||||
("chance", Probability),
|
||||
("level", Level.ToString().ToLowerInvariant()));
|
||||
}
|
||||
|
|
@ -444,7 +444,7 @@
|
|||
metabolismRate : 0.02
|
||||
effects:
|
||||
- !type:SuppressPain
|
||||
suppressionLevel: Mild
|
||||
level: Mild
|
||||
- !type:PopupMessage
|
||||
type: Local
|
||||
visualType: Medium
|
||||
|
|
@ -502,7 +502,7 @@
|
|||
metabolismRate : 0.01
|
||||
effects:
|
||||
- !type:SuppressPain
|
||||
suppressionLevel: Normal
|
||||
level: Normal
|
||||
- !type:SuppressAddiction
|
||||
- !type:PopupMessage
|
||||
type: Local
|
||||
|
|
@ -550,7 +550,7 @@
|
|||
metabolismRate : 0.01
|
||||
effects:
|
||||
- !type:SuppressPain
|
||||
suppressionLevel: Strong
|
||||
level: Strong
|
||||
- !type:SuppressAddiction
|
||||
- !type:PopupMessage
|
||||
type: Local
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
# Blurs your vision and makes you randomly fall asleep
|
||||
- type: entity
|
||||
parent: MobStatusEffectDebuff
|
||||
id: StatusEffectAddicted
|
||||
name: addicted
|
||||
components:
|
||||
- type: AddictedStatusEffect
|
||||
# TODO: Migrate the following OLD status effects
|
||||
|
||||
# * addicted
|
||||
# *
|
||||
|
||||
#- type: entity
|
||||
# parent: MobStatusEffectDebuff
|
||||
# id: StatusEffectAddicted
|
||||
# name: addicted
|
||||
# components:
|
||||
# - type: AddictedStatusEffect
|
||||
Loading…
Reference in New Issue