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{ class ReferencedTarget{ public GameObject gameObject; public float targetWeight; public float refVelocity; public CinemachineTargetGroup.Target cinemachineTarget; } private CinemachineTargetGroup.Target playerTarget; // 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)] public GameObject lockonGameObject; // Needed because nulling the Target below doesn't actually empty it out [ShowInInspector] ReferencedTarget mainTarget; [ShowInInspector] List activeTargets = new List(); [ReadOnly] public CinemachineTargetGroup.Target lockonTarget; public CinemachineTargetGroup targetGroup; [FormerlySerializedAs("lockOnTargets")] [Space(5)] public 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(){ // Save the player target object to track later playerTarget = targetGroup.Targets[0]; // Quick check for things in lock-on target that aren't lock-onable if (lockonGameObject != null && lockonTarget.Object.GetComponent() == null) { Debug.LogError($"Game Object {lockonTarget.Object.name} does not implement the ILockOnTarget interface!"); } elementRoot = lockOnDocument.rootVisualElement.Query("LockOnGroup"); elementLabelName = lockOnDocument.rootVisualElement.Query