Predict Flashes (#37640)

Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
slarticodefast
2025-06-23 13:32:56 +02:00
committed by GitHub
parent 7e77ee0cd2
commit b83d00b792
23 changed files with 501 additions and 386 deletions

View File

@@ -1,55 +1,79 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Flash.Components
namespace Content.Shared.Flash.Components;
/// <summary>
/// Allows this entity to flash someone by using it or melee attacking with it.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedFlashSystem))]
public sealed partial class FlashComponent : Component
{
[RegisterComponent, NetworkedComponent, Access(typeof(SharedFlashSystem))]
public sealed partial class FlashComponent : Component
/// <summary>
/// Flash the area around the entity when used in hand?
/// </summary>
[DataField, AutoNetworkedField]
public bool FlashOnUse = true;
/// <summary>
/// Flash the target when melee attacking them?
/// </summary>
[DataField, AutoNetworkedField]
public bool FlashOnMelee = true;
/// <summary>
/// Time the Flash will be visually flashing after use.
/// For the actual interaction delay use UseDelayComponent.
/// These two times should be the same.
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan FlashingTime = TimeSpan.FromSeconds(4);
/// <summary>
/// For how long the target will lose vision when melee attacked with the flash.
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan MeleeDuration = TimeSpan.FromSeconds(5);
/// <summary>
/// For how long the target will lose vision when used in hand.
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan AoeFlashDuration = TimeSpan.FromSeconds(2);
/// <summary>
/// How long a target is stunned when a melee flash is used.
/// If null, melee flashes will not stun at all.
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan? MeleeStunDuration = TimeSpan.FromSeconds(1.5);
/// <summary>
/// Range of the flash when using it.
/// </summary>
[DataField, AutoNetworkedField]
public float Range = 7f;
/// <summary>
/// Movement speed multiplier for slowing down the target while they are flashed.
/// </summary>
[DataField, AutoNetworkedField]
public float SlowTo = 0.5f;
/// <summary>
/// The sound to play when flashing.
/// </summary>
[DataField, AutoNetworkedField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Weapons/flash.ogg")
{
Params = AudioParams.Default.WithVolume(1f).WithMaxDistance(3f)
};
[DataField("duration")]
[ViewVariables(VVAccess.ReadWrite)]
public int FlashDuration { get; set; } = 5000;
/// <summary>
/// How long a target is stunned when a melee flash is used.
/// If null, melee flashes will not stun at all
/// </summary>
[DataField]
public TimeSpan? MeleeStunDuration = TimeSpan.FromSeconds(1.5);
[DataField("range")]
[ViewVariables(VVAccess.ReadWrite)]
public float Range { get; set; } = 7f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("aoeFlashDuration")]
public int AoeFlashDuration { get; set; } = 2000;
[DataField("slowTo")]
[ViewVariables(VVAccess.ReadWrite)]
public float SlowTo { get; set; } = 0.5f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sound")]
public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/flash.ogg")
{
Params = AudioParams.Default.WithVolume(1f).WithMaxDistance(3f)
};
public bool Flashing;
[DataField]
public float Probability = 1f;
}
[Serializable, NetSerializable]
public enum FlashVisuals : byte
{
BaseLayer,
LightLayer,
Burnt,
Flashing,
}
/// <summary>
/// The probability of sucessfully flashing someone.
/// </summary>
[DataField, AutoNetworkedField]
public float Probability = 1f;
}