using Content.Shared.Physics;
using Robust.Shared.GameStates;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Trigger.Components.Triggers;
///
/// Triggers whenever an entity collides with a fixture attached to the owner of this component.
/// The user is the entity that collided with the fixture.
///
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState, AutoGenerateComponentPause]
public sealed partial class TriggerOnProximityComponent : BaseTriggerOnXComponent
{
///
/// The ID if the fixture that is observed for collisions.
///
public const string FixtureID = "trigger-on-proximity-fixture";
///
/// Currently colliding entities.
///
[ViewVariables]
public readonly Dictionary Colliding = new();
///
/// What is the shape of the proximity fixture?
///
[ViewVariables]
[DataField]
public IPhysShape Shape = new PhysShapeCircle(2f);
///
/// How long the the proximity trigger animation plays for.
///
[DataField, AutoNetworkedField]
public TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.6f);
///
/// Whether the entity needs to be anchored for the proximity to work.
///
[DataField, AutoNetworkedField]
public bool RequiresAnchored = true;
///
/// Whether the proximity trigger is currently enabled.
///
[DataField, AutoNetworkedField]
public bool Enabled = true;
///
/// The minimum delay between repeating triggers.
///
[DataField, AutoNetworkedField]
public TimeSpan Cooldown = TimeSpan.FromSeconds(5);
///
/// When can the trigger run again?
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoNetworkedField, AutoPausedField]
public TimeSpan NextTrigger = TimeSpan.Zero;
///
/// When will the visual state be updated again after activation?
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoNetworkedField, AutoPausedField]
public TimeSpan NextVisualUpdate = TimeSpan.Zero;
///
/// What speed should the other object be moving at to trigger the proximity fixture?
///
[DataField, AutoNetworkedField]
public float TriggerSpeed = 3.5f;
///
/// If this proximity is triggered should we continually repeat it?
///
[DataField, AutoNetworkedField]
public bool Repeating = true;
///
/// What layer is the trigger fixture on?
///
[DataField(customTypeSerializer: typeof(FlagSerializer))]
public int Layer = (int)(CollisionGroup.MidImpassable | CollisionGroup.LowImpassable | CollisionGroup.HighImpassable);
}