EntityTargetActionComponent.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Content.Shared.Whitelist;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.Actions;
  5. /// <summary>
  6. /// Used on action entities to define an action that triggers when targeting an entity.
  7. /// </summary>
  8. [RegisterComponent, NetworkedComponent]
  9. public sealed partial class EntityTargetActionComponent : BaseTargetActionComponent
  10. {
  11. public override BaseActionEvent? BaseEvent => Event;
  12. /// <summary>
  13. /// The local-event to raise when this action is performed.
  14. /// </summary>
  15. [DataField("event")]
  16. [NonSerialized]
  17. public EntityTargetActionEvent? Event;
  18. /// <summary>
  19. /// Determines which entities are valid targets for this action.
  20. /// </summary>
  21. /// <remarks>No whitelist check when null.</remarks>
  22. [DataField("whitelist")] public EntityWhitelist? Whitelist;
  23. /// <summary>
  24. /// Determines which entities are NOT valid targets for this action.
  25. /// </summary>
  26. /// <remarks>No blacklist check when null.</remarks>
  27. [DataField] public EntityWhitelist? Blacklist;
  28. /// <summary>
  29. /// Whether this action considers the user as a valid target entity when using this action.
  30. /// </summary>
  31. [DataField("canTargetSelf")] public bool CanTargetSelf = true;
  32. }
  33. [Serializable, NetSerializable]
  34. public sealed class EntityTargetActionComponentState : BaseActionComponentState
  35. {
  36. public EntityWhitelist? Whitelist;
  37. public EntityWhitelist? Blacklist;
  38. public bool CanTargetSelf;
  39. public EntityTargetActionComponentState(EntityTargetActionComponent component, IEntityManager entManager) : base(component, entManager)
  40. {
  41. Whitelist = component.Whitelist;
  42. Blacklist = component.Blacklist;
  43. CanTargetSelf = component.CanTargetSelf;
  44. }
  45. }