using Content.Shared.Damage.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Turrets;
///
/// Attached to turrets that can be toggled between an inactive and active state
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(fieldDeltas: true), AutoGenerateComponentPause]
[Access(typeof(SharedDeployableTurretSystem))]
public sealed partial class DeployableTurretComponent : Component
{
///
/// Whether the turret is toggled 'on' or 'off'
///
[DataField, AutoNetworkedField]
public bool Enabled = false;
///
/// The current state of the turret. Used to inform the device network.
///
[DataField, AutoNetworkedField]
public DeployableTurretState CurrentState = DeployableTurretState.Retracted;
///
/// The visual state of the turret. Used on the client-side.
///
[DataField]
public DeployableTurretState VisualState = DeployableTurretState.Retracted;
///
/// The physics fixture that will have its collisions disabled when the turret is retracted.
///
[DataField]
public string? DeployedFixture = "turret";
///
/// When retracted, the following damage modifier set will be applied to the turret.
///
[DataField]
public ProtoId? RetractedDamageModifierSetId;
///
/// When deployed, the following damage modifier set will be applied to the turret.
///
[DataField]
public ProtoId? DeployedDamageModifierSetId;
#region: Sound data
///
/// Sound to play when denied access to the turret.
///
[DataField]
public SoundSpecifier AccessDeniedSound = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
///
/// Sound to play when the turret deploys.
///
[DataField]
public SoundSpecifier DeploymentSound = new SoundPathSpecifier("/Audio/Machines/blastdoor.ogg");
///
/// Sound to play when the turret retracts.
///
[DataField]
public SoundSpecifier RetractionSound = new SoundPathSpecifier("/Audio/Machines/blastdoor.ogg");
#endregion
#region: Animation data
///
/// The length of the deployment animation (in seconds)
///
[DataField]
public float DeploymentLength = 1.19f;
///
/// The length of the retraction animation (in seconds)
///
[DataField]
public float RetractionLength = 1.19f;
///
/// The time that the current animation should complete (in seconds)
///
[DataField, AutoPausedField]
public TimeSpan AnimationCompletionTime = TimeSpan.Zero;
///
/// The animation used when turret activates
///
[ViewVariables(VVAccess.ReadWrite)]
public object DeploymentAnimation = default!;
///
/// The animation used when turret deactivates
///
[ViewVariables(VVAccess.ReadWrite)]
public object RetractionAnimation = default!;
///
/// The key used to index the animation played when turning the turret on/off.
///
[ViewVariables(VVAccess.ReadOnly)]
public const string AnimationKey = "deployable_turret_animation";
#endregion
#region: Visual state data
///
/// The visual state to use when the turret is deployed.
///
[DataField]
public string DeployedState = "cover_open";
///
/// The visual state to use when the turret is not deployed.
///
[DataField]
public string RetractedState = "cover_closed";
///
/// Used to build the deployment animation when the component is initialized.
///
[DataField]
public string DeployingState = "cover_opening";
///
/// Used to build the retraction animation when the component is initialized.
///
[DataField]
public string RetractingState = "cover_closing";
#endregion
}
[Serializable, NetSerializable]
public enum DeployableTurretVisuals : byte
{
Turret,
Weapon,
Broken,
}
[Serializable, NetSerializable]
public enum DeployableTurretState : byte
{
Retracted = 0,
Deployed = (1 << 0),
Retracting = (1 << 1),
Deploying = (1 << 1) | Deployed,
Firing = (1 << 2) | Deployed,
Disabled = (1 << 3),
Broken = (1 << 4),
}