mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-07 23:07:26 +00:00
* holy shit? * final touches * this is dumb * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * whatever go my integration tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * whoopsie forgot blacklists * load bearing loc * minor stuff * whoopsie * cool * I LOVE REFLECTION * got a call from the stink department * i love fluent yes * direction changes * waiter more migrations please * typo ops --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Berger <toby@tobot.dev>
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;
|
|
|
|
namespace Content.Shared._DV.Traits.Effects;
|
|
|
|
/// <summary>
|
|
/// Effect that removes components from the player entity if they exist.
|
|
/// </summary>
|
|
public sealed partial class RemCompsEffect : BaseTraitEffect
|
|
{
|
|
/// <summary>
|
|
/// The component names to remove from the entity.
|
|
/// </summary>
|
|
[DataField(required: true, customTypeSerializer: typeof(CustomHashSetSerializer<string, ComponentNameSerializer>))]
|
|
public HashSet<string> Components = new();
|
|
|
|
public override void Apply(TraitEffectContext ctx)
|
|
{
|
|
foreach (var compName in Components)
|
|
{
|
|
if (!ctx.CompFactory.TryGetRegistration(compName, out var registration))
|
|
{
|
|
var sawmill = ctx.LogMan.GetSawmill("traits");
|
|
sawmill.Warning($"RemCompsEffect references unknown component: {compName}");
|
|
continue;
|
|
}
|
|
|
|
ctx.EntMan.RemoveComponent(ctx.Player, registration.Type);
|
|
}
|
|
}
|
|
}
|