Entity whitelist/blacklist for traits (#12348)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Shared.Traits;
|
using Content.Shared.Traits;
|
||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.Manager;
|
using Robust.Shared.Serialization.Manager;
|
||||||
|
|
||||||
@@ -28,6 +29,12 @@ public sealed class TraitSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (traitPrototype.Whitelist != null && !traitPrototype.Whitelist.IsValid(args.Mob))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (traitPrototype.Blacklist != null && traitPrototype.Blacklist.IsValid(args.Mob))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Add all components required by the prototype
|
// Add all components required by the prototype
|
||||||
foreach (var entry in traitPrototype.Components.Values)
|
foreach (var entry in traitPrototype.Components.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using static Robust.Shared.Prototypes.EntityPrototype; // don't worry about it
|
using static Robust.Shared.Prototypes.EntityPrototype; // don't worry about it
|
||||||
|
|
||||||
@@ -25,6 +26,18 @@ namespace Content.Shared.Traits
|
|||||||
[DataField("description")]
|
[DataField("description")]
|
||||||
public string? Description { get; }
|
public string? Description { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Don't apply this trait to entities this whitelist IS NOT valid for.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("whitelist")]
|
||||||
|
public EntityWhitelist? Whitelist;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Don't apply this trait to entities this whitelist IS valid for. (hence, a blacklist)
|
||||||
|
/// </summary>
|
||||||
|
[DataField("blacklist")]
|
||||||
|
public EntityWhitelist? Blacklist;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The components that get added to the player, when they pick this trait.
|
/// The components that get added to the player, when they pick this trait.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
id: Blindness
|
id: Blindness
|
||||||
name: Blindness
|
name: Blindness
|
||||||
description: You lack vision
|
description: You lack vision
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- Blindable
|
||||||
components:
|
components:
|
||||||
- type: PermanentBlindness
|
- type: PermanentBlindness
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
id: UncontrollableSneezing
|
id: UncontrollableSneezing
|
||||||
name: Runny nose
|
name: Runny nose
|
||||||
description: You sneeze and cough uncontrollably
|
description: You sneeze and cough uncontrollably
|
||||||
|
whitelist:
|
||||||
|
components:
|
||||||
|
- DiseaseCarrier
|
||||||
components:
|
components:
|
||||||
- type: UncontrollableSnough
|
- type: UncontrollableSnough
|
||||||
snoughSound:
|
snoughSound:
|
||||||
|
|||||||
Reference in New Issue
Block a user