2023-06-17 05:07:58 +03:00
|
|
|
using Content.Shared.Damage;
|
2022-07-29 14:13:12 +12:00
|
|
|
using Robust.Shared.Audio;
|
2023-10-08 06:08:13 +11:00
|
|
|
using Robust.Shared.GameStates;
|
2022-07-04 02:31:12 -04:00
|
|
|
using Robust.Shared.Physics.Collision.Shapes;
|
2023-09-08 18:16:05 -07:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-07-04 02:31:12 -04:00
|
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Blocking;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This component goes on an item that you want to use to block
|
|
|
|
|
/// </summary>
|
2023-10-08 06:08:13 +11:00
|
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class BlockingComponent : Component
|
2022-07-04 02:31:12 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The entity that's blocking
|
|
|
|
|
/// </summary>
|
2023-10-08 06:08:13 +11:00
|
|
|
[ViewVariables, AutoNetworkedField]
|
2022-07-04 02:31:12 -04:00
|
|
|
public EntityUid? User;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Is it currently blocking?
|
|
|
|
|
/// </summary>
|
2023-10-08 06:08:13 +11:00
|
|
|
[ViewVariables, AutoNetworkedField]
|
2022-07-04 02:31:12 -04:00
|
|
|
public bool IsBlocking;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The ID for the fixture that's dynamically created when blocking
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string BlockFixtureID = "blocking-active";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The shape of the blocking fixture that will be dynamically spawned
|
|
|
|
|
/// </summary>
|
2023-06-17 05:07:58 +03:00
|
|
|
[DataField("shape"), ViewVariables(VVAccess.ReadWrite)]
|
2023-01-15 15:38:59 +11:00
|
|
|
public IPhysShape Shape = new PhysShapeCircle(0.5f);
|
2022-07-04 02:31:12 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The damage modifer to use while passively blocking
|
|
|
|
|
/// </summary>
|
2023-06-17 05:07:58 +03:00
|
|
|
[DataField("passiveBlockModifier", required: true)]
|
|
|
|
|
public DamageModifierSet PassiveBlockDamageModifer = default!;
|
2022-07-04 02:31:12 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The damage modifier to use while actively blocking.
|
|
|
|
|
/// </summary>
|
2023-06-17 05:07:58 +03:00
|
|
|
[DataField("activeBlockModifier", required: true)]
|
|
|
|
|
public DamageModifierSet ActiveBlockDamageModifier = default!;
|
2022-07-04 02:31:12 -04:00
|
|
|
|
2023-09-08 18:16:05 -07:00
|
|
|
[DataField("blockingToggleAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
|
|
|
public string BlockingToggleAction = "ActionToggleBlock";
|
2022-07-04 02:31:12 -04:00
|
|
|
|
2023-10-08 06:08:13 +11:00
|
|
|
[DataField, AutoNetworkedField]
|
2023-09-08 18:16:05 -07:00
|
|
|
public EntityUid? BlockingToggleActionEntity;
|
2022-07-04 02:31:12 -04:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The sound to be played when you get hit while actively blocking
|
|
|
|
|
/// </summary>
|
2023-11-27 22:12:34 +11:00
|
|
|
[DataField("blockSound")] public SoundSpecifier BlockSound =
|
|
|
|
|
new SoundPathSpecifier("/Audio/Weapons/block_metal1.ogg")
|
|
|
|
|
{
|
|
|
|
|
Params = AudioParams.Default.WithVariation(0.25f)
|
|
|
|
|
};
|
2023-06-05 05:23:54 +03:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fraction of original damage shield will take instead of user
|
|
|
|
|
/// when not blocking
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("passiveBlockFraction"), ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public float PassiveBlockFraction = 0.5f;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fraction of original damage shield will take instead of user
|
|
|
|
|
/// when blocking
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("activeBlockFraction"), ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public float ActiveBlockFraction = 1.0f;
|
2022-07-04 02:31:12 -04:00
|
|
|
}
|