* Fixed ReflectSystem + Added logic for reflective items positioning * Total oppsie fix * Born to shitcode
98 lines
3.1 KiB
C#
98 lines
3.1 KiB
C#
using Robust.Shared.Audio;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Shared.Weapons.Reflect;
|
|
|
|
/// <summary>
|
|
/// Entities with this component have a chance to reflect projectiles and hitscan shots
|
|
/// </summary>
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
|
public sealed partial class ReflectComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// Can only reflect when enabled
|
|
/// </summary>
|
|
[DataField("enabled"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
|
public bool Enabled = true;
|
|
|
|
/// <summary>
|
|
/// What we reflect.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField("reflects")]
|
|
public ReflectType Reflects = ReflectType.Energy | ReflectType.NonEnergy;
|
|
|
|
[DataField("spread"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
|
public Angle Spread = Angle.FromDegrees(45);
|
|
|
|
[DataField("soundOnReflect")]
|
|
public SoundSpecifier? SoundOnReflect = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg");
|
|
|
|
// WD START
|
|
[DataField("damageOnReflect"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
|
public bool DamageOnReflect;
|
|
// WD END
|
|
|
|
/// <summary>
|
|
/// Is the deflection an innate power or something actively maintained? If true, this component grants a flat
|
|
/// deflection chance rather than a chance that degrades when moving/weightless/stunned/etc.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool Innate = false;
|
|
|
|
// WD START
|
|
/// <summary>
|
|
/// If the item for reflection needed in inventory slots only - select Body.
|
|
/// If the item for reflection needed in hands only - select Hands.
|
|
/// Otherwise it will reflect in any inventory position.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
|
public Placement Placement = Placement.Hands | Placement.Body;
|
|
|
|
/// <summary>
|
|
/// Can only reflect when placed correctly.
|
|
/// </summary>
|
|
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
|
public bool InRightPlace = true;
|
|
// WD END
|
|
|
|
/// <summary>
|
|
/// Maximum probability for a projectile to be reflected.
|
|
/// </summary>
|
|
[DataField("reflectProb"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
|
public float ReflectProb = 0.25f;
|
|
|
|
/// <summary>
|
|
/// The maximum velocity a wielder can move at before losing effectiveness.
|
|
/// </summary>
|
|
[DataField]
|
|
public float VelocityBeforeNotMaxProb = 2.5f; // Walking speed for a human. Suitable for a weightless deflector like an e-sword.
|
|
|
|
/// <summary>
|
|
/// The velocity a wielder has to be moving at to use the minimum effectiveness value.
|
|
/// </summary>
|
|
[DataField]
|
|
public float VelocityBeforeMinProb = 4.5f; // Sprinting speed for a human. Suitable for a weightless deflector like an e-sword.
|
|
|
|
/// <summary>
|
|
/// Minimum probability for a projectile to be reflected.
|
|
/// </summary>
|
|
[DataField]
|
|
public float MinReflectProb = 0.1f;
|
|
}
|
|
|
|
[Flags]
|
|
public enum ReflectType : byte
|
|
{
|
|
None = 0,
|
|
NonEnergy = 1 << 0,
|
|
Energy = 1 << 1,
|
|
}
|
|
|
|
[Flags]
|
|
public enum Placement : byte
|
|
{
|
|
None = 0,
|
|
Hands = 1 << 0,
|
|
Body = 1 << 1,
|
|
}
|