BlockingComponent.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using Content.Shared.Damage;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Physics.Collision.Shapes;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Shared.Blocking;
  8. /// <summary>
  9. /// This component goes on an item that you want to use to block
  10. /// </summary>
  11. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  12. public sealed partial class BlockingComponent : Component
  13. {
  14. /// <summary>
  15. /// The entity that's blocking
  16. /// </summary>
  17. [ViewVariables, AutoNetworkedField]
  18. public EntityUid? User;
  19. /// <summary>
  20. /// Is it currently blocking?
  21. /// </summary>
  22. [ViewVariables, AutoNetworkedField]
  23. public bool IsBlocking;
  24. /// <summary>
  25. /// The ID for the fixture that's dynamically created when blocking
  26. /// </summary>
  27. public const string BlockFixtureID = "blocking-active";
  28. /// <summary>
  29. /// The shape of the blocking fixture that will be dynamically spawned
  30. /// </summary>
  31. [DataField("shape"), ViewVariables(VVAccess.ReadWrite)]
  32. public IPhysShape Shape = new PhysShapeCircle(0.5f);
  33. /// <summary>
  34. /// The damage modifer to use while passively blocking
  35. /// </summary>
  36. [DataField("passiveBlockModifier", required: true)]
  37. public DamageModifierSet PassiveBlockDamageModifer = default!;
  38. /// <summary>
  39. /// The damage modifier to use while actively blocking.
  40. /// </summary>
  41. [DataField("activeBlockModifier", required: true)]
  42. public DamageModifierSet ActiveBlockDamageModifier = default!;
  43. [DataField("blockingToggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
  44. public string BlockingToggleAction = "ActionToggleBlock";
  45. [DataField, AutoNetworkedField]
  46. public EntityUid? BlockingToggleActionEntity;
  47. /// <summary>
  48. /// The sound to be played when you get hit while actively blocking
  49. /// </summary>
  50. [DataField("blockSound")] public SoundSpecifier BlockSound =
  51. new SoundPathSpecifier("/Audio/Weapons/block_metal1.ogg")
  52. {
  53. Params = AudioParams.Default.WithVariation(0.25f)
  54. };
  55. /// <summary>
  56. /// Fraction of original damage shield will take instead of user
  57. /// when not blocking
  58. /// </summary>
  59. [DataField("passiveBlockFraction"), ViewVariables(VVAccess.ReadWrite)]
  60. public float PassiveBlockFraction = 0.5f;
  61. /// <summary>
  62. /// Fraction of original damage shield will take instead of user
  63. /// when blocking
  64. /// </summary>
  65. [DataField("activeBlockFraction"), ViewVariables(VVAccess.ReadWrite)]
  66. public float ActiveBlockFraction = 1.0f;
  67. }