CatStation/Content.Shared/Electrocution/Components/ElectrifiedComponent.cs
Samuka d00ba81af3
Shock module (#44391)
* zap icon

* recipe todo

* add module

* add action image

* add electrified sprite to engi xenoborg

* add one pixel

* anti fun change

* remove useless action

* remove texture

* add shock delay

* check is done in the right place now

* pause stuff

* use custom serializer

* make shock only 3 seconds

* change values

* microbalance commit

* move down

* captalization
2026-08-05 05:31:25 +00:00

179 lines
5.2 KiB
C#

using Robust.Shared.GameStates;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Electrocution;
/// <summary>
/// Component for things that shock users on touch.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
public sealed partial class ElectrifiedComponent : Component
{
/// <summary>
/// Check if it is actually electrified at the moment.
/// </summary>
[DataField, AutoNetworkedField]
public bool Enabled = true;
/// <summary>
/// Should player get damage on collide
/// </summary>
[DataField, AutoNetworkedField]
public bool OnBump = true;
/// <summary>
/// Should player get damage on attack
/// </summary>
[DataField, AutoNetworkedField]
public bool OnAttacked = true;
/// <summary>
/// When true - disables power if a window is present in the same tile
/// </summary>
[DataField, AutoNetworkedField]
public bool NoWindowInTile = false;
/// <summary>
/// Should player get damage on interact with empty hand
/// </summary>
[DataField, AutoNetworkedField]
public bool OnHandInteract = true;
/// <summary>
/// Should player get damage on interact while holding an object in their hand
/// </summary>
[DataField, AutoNetworkedField]
public bool OnInteractUsing = true;
/// <summary>
/// Whether the entity should electrocute on activation in world.
/// </summary>
[DataField, AutoNetworkedField]
public bool OnActivateInWorld = false;
/// <summary>
/// Indicates if the entity requires power to function
/// </summary>
[DataField, AutoNetworkedField]
public bool RequirePower = true;
/// <summary>
/// Indicates if the entity uses APC power
/// </summary>
[DataField, AutoNetworkedField]
public bool UsesApcPower = false;
/// <summary>
/// Identifier for the high voltage node.
/// </summary>
[DataField, AutoNetworkedField]
public string? HighVoltageNode;
/// <summary>
/// Identifier for the medium voltage node.
/// </summary>
[DataField, AutoNetworkedField]
public string? MediumVoltageNode;
/// <summary>
/// Identifier for the low voltage node.
/// </summary>
[DataField, AutoNetworkedField]
public string? LowVoltageNode;
/// <summary>
/// Damage multiplier for HV electrocution
/// </summary>
[DataField, AutoNetworkedField]
public float HighVoltageDamageMultiplier = 3f;
/// <summary>
/// Shock time multiplier for HV electrocution
/// </summary>
[DataField, AutoNetworkedField]
public float HighVoltageTimeMultiplier = 2f;
/// <summary>
/// Damage multiplier for MV electrocution
/// </summary>
[DataField, AutoNetworkedField]
public float MediumVoltageDamageMultiplier = 2f;
/// <summary>
/// Shock time multiplier for MV electrocution
/// </summary>
[DataField, AutoNetworkedField]
public float MediumVoltageTimeMultiplier = 1.5f;
/// <summary>
/// Base damage to be inflected upon electrocution.
/// </summary>
[DataField, AutoNetworkedField]
public float ShockDamage = 7.5f;
/// <summary>
/// Shock time, in seconds.
/// </summary>
[DataField, AutoNetworkedField]
public float ShockTime = 5f;
/// <summary>
/// Delay between consecutive shocks
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan? ShockDelay;
/// <summary>
/// When the entity will be able to shock again
/// </summary>
[DataField(customTypeSerializer:typeof(TimeOffsetSerializer)), AutoNetworkedField, AutoPausedField]
public TimeSpan? NextShock;
/// Base conductivity, is combined coefficient of electrocution targets to check if electrocution attempts works.
/// </summary>
[DataField, AutoNetworkedField]
public float SiemensCoefficient = 1f;
/// <summary>
/// Noise to play when shocking.
/// </summary>
[DataField, AutoNetworkedField]
public SoundSpecifier ShockNoises = new SoundCollectionSpecifier("sparks");
/// <summary>
/// Sound to play when disabled.
/// </summary>
[DataField, AutoNetworkedField]
public SoundPathSpecifier AirlockElectrifyDisabled = new("/Audio/Machines/airlock_electrify_off.ogg");
/// <summary>
/// Sound to play when enabled.
/// </summary>
[DataField, AutoNetworkedField]
public SoundPathSpecifier AirlockElectrifyEnabled = new("/Audio/Machines/airlock_electrify_on.ogg");
/// <summary>
/// If sound should be played upon shocking something or someone.
/// </summary>
[DataField, AutoNetworkedField]
public bool PlaySoundOnShock = true;
/// <summary>
/// Volume of shock sound.
/// </summary>
[DataField, AutoNetworkedField]
public float ShockVolume = 20;
/// <summary>
/// The chance if it would shock someone.
/// </summary>
[DataField, AutoNetworkedField]
public float Probability = 1f;
/// <summary>
/// If the power wire of this component is cut, aka no longer electrified.
/// </summary>
[DataField, AutoNetworkedField]
public bool IsWireCut = false;
}