using Content.Server.Explosion.EntitySystems; using Content.Shared.Explosion; using Content.Shared.Explosion.Components; using Content.Shared.Physics; 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.Server.Explosion.Components { /// /// Raises a whenever an entity collides with a fixture attached to the owner of this component. /// [RegisterComponent, AutoGenerateComponentPause] public sealed partial class TriggerOnProximityComponent : SharedTriggerOnProximityComponent { public const string FixtureID = "trigger-on-proximity-fixture"; [ViewVariables] public readonly Dictionary Colliding = new(); /// /// What is the shape of the proximity fixture? /// [ViewVariables] [DataField("shape")] public IPhysShape Shape = new PhysShapeCircle(2f); /// /// How long the the proximity trigger animation plays for. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("animationDuration")] public TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.6f); /// /// Whether the entity needs to be anchored for the proximity to work. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("requiresAnchored")] public bool RequiresAnchored = true; [ViewVariables(VVAccess.ReadWrite)] [DataField("enabled")] public bool Enabled = true; /// /// The minimum delay between repeating triggers. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("cooldown")] public TimeSpan Cooldown = TimeSpan.FromSeconds(5); /// /// When can the trigger run again? /// [ViewVariables(VVAccess.ReadWrite)] [DataField("nextTrigger", customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan NextTrigger = TimeSpan.Zero; /// /// When will the visual state be updated again after activation? /// [ViewVariables(VVAccess.ReadWrite)] [DataField("nextVisualUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan NextVisualUpdate = TimeSpan.Zero; /// /// What speed should the other object be moving at to trigger the proximity fixture? /// [ViewVariables(VVAccess.ReadWrite)] [DataField("triggerSpeed")] public float TriggerSpeed = 3.5f; /// /// If this proximity is triggered should we continually repeat it? /// [ViewVariables(VVAccess.ReadWrite)] [DataField("repeating")] public bool Repeating = true; /// /// What layer is the trigger fixture on? /// [ViewVariables] [DataField("layer", customTypeSerializer: typeof(FlagSerializer))] public int Layer = (int) (CollisionGroup.MidImpassable | CollisionGroup.LowImpassable | CollisionGroup.HighImpassable); } }