Extend DV trait system to handle status effects
This commit is contained in:
parent
7f2b7500d2
commit
b24ec257b7
|
|
@ -7,6 +7,7 @@ using Content.Shared._DV.Traits.Effects;
|
|||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.StatusEffectNew;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
|
|
@ -773,6 +774,7 @@ public sealed partial class TraitSystemTest
|
|||
LogMan = IoCManager.Resolve<ILogManager>(),
|
||||
JobId = jobId,
|
||||
SpeciesId = speciesId,
|
||||
StatusEffects = IoCManager.Resolve<StatusEffectsSystem>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -790,6 +792,7 @@ public sealed partial class TraitSystemTest
|
|||
CompFactory = factory,
|
||||
LogMan = IoCManager.Resolve<ILogManager>(),
|
||||
Transform = entMan.GetComponent<TransformComponent>(player),
|
||||
StatusEffects = IoCManager.Resolve<StatusEffectsSystem>(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Content.Shared.Humanoid;
|
|||
using Content.Shared.Humanoid.Prototypes;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.StatusEffectNew;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
|
@ -25,6 +26,7 @@ public sealed class TraitSystem : EntitySystem
|
|||
[Dependency] private readonly ILogManager _log = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
||||
|
||||
private int _maxTraitCount;
|
||||
private int _maxTraitPoints;
|
||||
|
|
@ -104,6 +106,7 @@ public sealed class TraitSystem : EntitySystem
|
|||
JobId = jobId,
|
||||
SpeciesId = speciesId,
|
||||
Profile = profile,
|
||||
StatusEffects = _statusEffects
|
||||
};
|
||||
|
||||
foreach (var traitId in selectedTraits)
|
||||
|
|
@ -272,6 +275,7 @@ public sealed class TraitSystem : EntitySystem
|
|||
CompFactory = _factory,
|
||||
LogMan = _log,
|
||||
Transform = transform,
|
||||
StatusEffects = _statusEffects,
|
||||
};
|
||||
|
||||
foreach (var effect in trait.Effects)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Content.Shared.Preferences;
|
||||
using Content.Shared.StatusEffectNew;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
|
@ -48,6 +49,7 @@ public sealed class TraitConditionContext
|
|||
public required IPrototypeManager Proto { get; init; }
|
||||
public required IComponentFactory CompFactory { get; init; }
|
||||
public required ILogManager LogMan { get; init; }
|
||||
public required StatusEffectsSystem StatusEffects { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The job ID of the player, if available.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._DV.Traits.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// Effect that adds status effects to the player entity.
|
||||
/// </summary>
|
||||
public sealed partial class ApplyStatusEffect : BaseTraitEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// The status effects to add to the entity.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public HashSet<EntProtoId> StatusEffects = new();
|
||||
|
||||
public override void Apply(TraitEffectContext ctx)
|
||||
{
|
||||
foreach (var effect in StatusEffects)
|
||||
{
|
||||
ctx.StatusEffects.TrySetStatusEffectDuration(ctx.Player, effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using Content.Shared.StatusEffectNew;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
|
|
@ -28,4 +29,5 @@ public sealed class TraitEffectContext
|
|||
public required IComponentFactory CompFactory { get; init; }
|
||||
public required ILogManager LogMan { get; init; }
|
||||
public required TransformComponent Transform { get; init; }
|
||||
public required StatusEffectsSystem StatusEffects { get; init; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@
|
|||
description: trait-painnumbness-desc
|
||||
category: Disabilities
|
||||
effects:
|
||||
- !type:AddCompsEffect
|
||||
components:
|
||||
- type: PainNumbness
|
||||
- !type:ApplyStatusEffect
|
||||
statusEffects:
|
||||
- PainNumbnessTraitStatusEffect
|
||||
|
||||
- type: trait
|
||||
id: Hemophilia
|
||||
|
|
|
|||
Loading…
Reference in New Issue