1
0

MeleeSpeechComponent.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Content.Shared.Actions;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Prototypes;
  4. using Robust.Shared.Serialization;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  6. namespace Content.Shared.Speech.Components;
  7. [RegisterComponent, NetworkedComponent]
  8. [AutoGenerateComponentState]
  9. public sealed partial class MeleeSpeechComponent : Component
  10. {
  11. /// <summary>
  12. /// The battlecry to be said when an entity attacks with this component
  13. /// </summary>
  14. [ViewVariables(VVAccess.ReadWrite)]
  15. [DataField("Battlecry")]
  16. [AutoNetworkedField]
  17. public string? Battlecry;
  18. /// <summary>
  19. /// The maximum amount of characters allowed in a battlecry
  20. /// </summary>
  21. [ViewVariables(VVAccess.ReadWrite)]
  22. [DataField("MaxBattlecryLength")]
  23. [AutoNetworkedField]
  24. public int MaxBattlecryLength = 12;
  25. [DataField] public EntProtoId ConfigureAction = "ActionConfigureMeleeSpeech";
  26. /// <summary>
  27. /// The action to open the battlecry UI
  28. /// </summary>
  29. [DataField("configureActionEntity")] public EntityUid? ConfigureActionEntity;
  30. }
  31. /// <summary>
  32. /// Key representing which <see cref="PlayerBoundUserInterface"/> is currently open.
  33. /// Useful when there are multiple UI for an object. Here it's future-proofing only.
  34. /// </summary>
  35. [Serializable, NetSerializable]
  36. public enum MeleeSpeechUiKey : byte
  37. {
  38. Key,
  39. }
  40. /// <summary>
  41. /// Represents an <see cref="MeleeSpeechComponent"/> state that can be sent to the client
  42. /// </summary>
  43. [Serializable, NetSerializable]
  44. public sealed class MeleeSpeechBoundUserInterfaceState : BoundUserInterfaceState
  45. {
  46. public string CurrentBattlecry { get; }
  47. public MeleeSpeechBoundUserInterfaceState(string currentBattlecry)
  48. {
  49. CurrentBattlecry = currentBattlecry;
  50. }
  51. }
  52. [Serializable, NetSerializable]
  53. public sealed class MeleeSpeechBattlecryChangedMessage : BoundUserInterfaceMessage
  54. {
  55. public string Battlecry { get; }
  56. public MeleeSpeechBattlecryChangedMessage(string battlecry)
  57. {
  58. Battlecry = battlecry;
  59. }
  60. }
  61. public sealed partial class MeleeSpeechConfigureActionEvent : InstantActionEvent { }