/// <summary> /// Set the target. /// </summary> /// <param name="target">The new target.</param> public virtual void SetTarget(Trackable target) { if (targetLocker != null) { targetLocker.SetTarget(target); } }
// Called when a module is mounted on one of the vehicle's module mounts. protected override void OnModuleMounted(Module module) { // Look for target leading weapons TargetLeader targetLeader = module.GetComponent <TargetLeader>(); if (targetLeader != null) { if (!targetLeaders.Contains(targetLeader)) { targetLeaders.Add(targetLeader); targetLeader.SetTarget(weaponsTargetSelector.SelectedTarget); if (weaponsTargetSelector != null) { weaponsTargetSelector.onSelectedTargetChanged.AddListener(targetLeader.SetTarget); } onTargetLeaderLoaded.Invoke(targetLeader); } } // Look for locking weapons TargetLocker targetLocker = module.GetComponent <TargetLocker>(); if (targetLocker != null) { if (!targetLockers.Contains(targetLocker)) { targetLockers.Add(targetLocker); targetLocker.SetTarget(weaponsTargetSelector.SelectedTarget); if (weaponsTargetSelector != null) { weaponsTargetSelector.onSelectedTargetChanged.AddListener(targetLocker.SetTarget); } onTargetLockerLoaded.Invoke(targetLocker); } } // Look for gimbaled weapons GimbalController gimbalController = module.GetComponentInChildren <GimbalController>(); if (gimbalController != null) { if (!gimbaledWeapons.Contains(gimbalController)) { gimbaledWeapons.Add(gimbalController); } } }
/// <summary> /// Set the target. /// </summary> /// <param name="target">The new target.</param> public virtual void SetTarget(Trackable target) { if (targetLocker != null) { targetLocker.SetTarget(target); } if (targetLeader != null) { targetLeader.SetTarget(target); } if (targetProximityTrigger != null) { targetProximityTrigger.SetTarget(target); } }
// Called when a module is unmounted from one of the vehicle's module mounts. protected override void OnModuleUnmounted(Module module) { // Unlink target leading weapons TargetLeader targetLeader = module.GetComponent <TargetLeader>(); if (targetLeader != null) { if (targetLeaders.Contains(targetLeader)) { targetLeader.SetTarget(null); targetLeaders.Remove(targetLeader); if (weaponsTargetSelector != null) { weaponsTargetSelector.onSelectedTargetChanged.RemoveListener(targetLeader.SetTarget); } } } // Unlink target locking weapons TargetLocker targetLocker = module.GetComponent <TargetLocker>(); if (targetLocker != null) { if (targetLockers.Contains(targetLocker)) { targetLocker.SetTarget(null); targetLockers.Remove(targetLocker); if (weaponsTargetSelector != null) { weaponsTargetSelector.onSelectedTargetChanged.RemoveListener(targetLocker.SetTarget); } } } // Look for gimbaled weapons GimbalController gimbalController = module.GetComponentInChildren <GimbalController>(); if (gimbalController != null) { if (gimbaledWeapons.Contains(gimbalController)) { gimbaledWeapons.Remove(gimbalController); } } }