Add reflection for crystals (#16426)

This commit is contained in:
metalgearsloth
2023-05-15 15:21:05 +10:00
committed by GitHub
parent fd35b61160
commit 347dcfbeb5
11 changed files with 177 additions and 81 deletions

View File

@@ -1,44 +1,43 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Weapons.Reflect;
/// <summary>
/// Entities with this component have a chance to reflect projectiles and hitscan shots
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed class ReflectComponent : Component
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ReflectComponent : Component
{
/// <summary>
/// Can only reflect when enabled
/// </summary>
[DataField("enabled"), ViewVariables(VVAccess.ReadWrite)]
[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;
/// <summary>
/// Probability for a projectile to be reflected.
/// </summary>
[DataField("reflectProb"), ViewVariables(VVAccess.ReadWrite)]
public float ReflectProb;
[DataField("reflectProb"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public float ReflectProb = 0.25f;
[DataField("spread"), ViewVariables(VVAccess.ReadWrite)]
public Angle Spread = Angle.FromDegrees(5);
[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");
}
[Serializable, NetSerializable]
public sealed class ReflectComponentState : ComponentState
[Flags]
public enum ReflectType : byte
{
public bool Enabled;
public float ReflectProb;
public Angle Spread;
public ReflectComponentState(bool enabled, float reflectProb, Angle spread)
{
Enabled = enabled;
ReflectProb = reflectProb;
Spread = spread;
}
None = 0,
NonEnergy = 1 << 0,
Energy = 1 << 1,
}