// SPDX-FileCopyrightText: 2025 Ark // SPDX-FileCopyrightText: 2025 Redrover1760 // SPDX-FileCopyrightText: 2025 RikuTheKiller // // SPDX-License-Identifier: AGPL-3.0-or-later using System.Numerics; namespace Content.Server._Mono.Projectiles.TargetSeeking; /// /// Component that allows a projectile to seek and track targets autonomously. /// [RegisterComponent] public sealed partial class TargetSeekingComponent : Component { /// /// Maximum distance to search for potential targets. /// [DataField] public float DetectionRange = 300f; /// /// Minimum angular deviation from directly facing the target. /// [DataField] public Angle Tolerance = Angle.FromDegrees(1); /// /// How quickly the projectile can change direction in degrees per second. /// [DataField, ViewVariables(VVAccess.ReadWrite)] public Angle? TurnRate = 100f; /// /// The current target entity being tracked. /// [DataField] public EntityUid? CurrentTarget; /// /// Tracking algorithm used for intercepting the target. /// [DataField] public TrackingMethod TrackingAlgorithm = TrackingMethod.Predictive; /// /// How fast the projectile accelerates in m/s². /// [DataField] public float Acceleration = 50f; /// /// Maximum speed the projectile can reach in m/s. /// [DataField] public float MaxSpeed = 50f; /// /// Initial speed of the projectile in m/s. /// [DataField] public float LaunchSpeed = 10f; /// /// Has the projectile had its launch speed applied yet? /// [DataField] public bool Launched = false; /// /// Current speed of the projectile in m/s. /// [DataField] public float CurrentSpeed; /// /// The amount of time in seconds left the missile starts searching for targets. // Mono /// [DataField] public float TrackDelay = 0f; /// /// Field of view in degrees for target detection. /// [DataField] public float ScanArc = 90f; /// /// Used for tracking metrics between updates. /// public float PreviousDistance; /// /// Previous position of the target, used for velocity calculation. /// public Vector2 PreviousTargetPosition; /// /// Whether seeking has been disabled (e.g., after entering an enemy grid). /// public bool SeekingDisabled; } /// /// Defines different tracking algorithms that can be used. /// public enum TrackingMethod { /// /// Advanced tracking that predicts target movement. /// Predictive = 1, /// /// Basic tracking that simply points directly at the target. /// Direct = 2 }