using System; using System.Collections; using System.Collections.Generic; using System.Numerics; using Sirenix.OdinInspector; using Unity.Cinemachine; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UIElements; using Vector2 = UnityEngine.Vector2; using Vector3 = UnityEngine.Vector3; public class LockOnManager : MonoBehaviour{ public class ActiveLockOnTarget{ public GameObject gameObject; public float targetWeight; public float refVelocity; public CinemachineTargetGroup.Target cinemachineTarget; } public static LockOnManager Instance; // Lock On settings [Space(5)] public float lockOnRange = 40f; public float lockOnMaxAngle = 70f; [Range(0,1)] public float mainTargetWeight = .15f; [FormerlySerializedAs("smoothing")] public float smoothTime = 1f; // Lock On Tracking [Space(10)] [ShowInInspector] ActiveLockOnTarget mainTarget; public List activeTargets = new List(); [ReadOnly] public CinemachineTargetGroup.Target lockonTarget; public CinemachineTargetGroup targetGroup; private List acceptedTargets = new List(); // UI [ShowInInspector] public UIDocument lockOnDocument; private Label elementLabelName; private VisualElement elementRoot; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start(){ // Register as singleton if (Instance == null) { Instance = this; } else { this.enabled = false; return; } // Quick check for things in lock-on target that aren't lock-onable if (mainTarget != null && mainTarget.gameObject.GetComponent() == null) { mainTarget.gameObject.AddComponent(); Debug.LogWarning($"The object {mainTarget.gameObject.name} has no ILockOnTarget interface. This isn't hyper critical, but adding one as a GenericLockOnTarget anyways."); } elementRoot = lockOnDocument.rootVisualElement.Query("LockOnGroup"); elementLabelName = lockOnDocument.rootVisualElement.Query