* Add Whitelist.Components yaml valiation * poke_tests * fix linter --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using Content.Shared.Item;
|
|
using Content.Shared.Tag;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic;
|
|
|
|
namespace Content.Shared.Whitelist;
|
|
|
|
/// <summary>
|
|
/// Used to determine whether an entity fits a certain whitelist.
|
|
/// Does not whitelist by prototypes, since that is undesirable; you're better off just adding a tag to all
|
|
/// entity prototypes that need to be whitelisted, and checking for that.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Do not add more conditions like itemsize to the whitelist, this should stay as lightweight as possible!
|
|
/// </remarks>
|
|
/// <code>
|
|
/// whitelist:
|
|
/// tags:
|
|
/// - Cigarette
|
|
/// - FirelockElectronics
|
|
/// components:
|
|
/// - Buckle
|
|
/// - AsteroidRock
|
|
/// sizes:
|
|
/// - Tiny
|
|
/// - Large
|
|
/// </code>
|
|
[DataDefinition]
|
|
[Serializable, NetSerializable]
|
|
public sealed partial class EntityWhitelist
|
|
{
|
|
/// <summary>
|
|
/// Component names that are allowed in the whitelist.
|
|
/// </summary>
|
|
[DataField(customTypeSerializer:typeof(CustomArraySerializer<string, ComponentNameSerializer>))]
|
|
public string[]? Components;
|
|
|
|
/// <summary>
|
|
/// Item sizes that are allowed in the whitelist.
|
|
/// </summary>
|
|
[DataField]
|
|
public List<ProtoId<ItemSizePrototype>>? Sizes;
|
|
|
|
[NonSerialized, Access(typeof(EntityWhitelistSystem))]
|
|
public List<ComponentRegistration>? Registrations;
|
|
|
|
/// <summary>
|
|
/// Tags that are allowed in the whitelist.
|
|
/// </summary>
|
|
[DataField]
|
|
public List<ProtoId<TagPrototype>>? Tags;
|
|
|
|
/// <summary>
|
|
/// If false, an entity only requires one of these components or tags to pass the whitelist. If true, an
|
|
/// entity requires to have ALL of these components and tags to pass.
|
|
/// The "Sizes" criteria will ignores this, since an item can only have one size.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool RequireAll;
|
|
}
|