void Update() { if (IsInCombat() && IsHUDShown() && !_isAbilityHovered && !_isAbilitySelected) { UnitEntityData unit = null; float radius = 0f; bool canTargetEnemies = true; bool canTargetFriends = false; if (ShowAttackIndicatorOnHoverUI && (unit = Mod.Core.UI.CombatTracker.HoveringUnit) != null) { GetRadius(); } else { if (ShowAttackIndicatorOfCurrentUnit && (unit = CurrentUnit(out TurnController currentTurn)) != null && (unit.IsDirectlyControllable ? ShowAttackIndicatorForPlayer : ShowAttackIndicatorForNonPlayer)) { GetRadius(); if (radius > 0f && currentTurn.EnabledFiveFootStep) { radius += currentTurn.GetRemainingMovementRange(); } } } if (unit != null && radius > 0 && (!DoNotMarkInvisibleUnit || unit.IsVisibleForPlayer)) { _range.SetPosition(unit); _range.SetRadius(radius); _range.SetVisible(true); Unit = unit; EventBus.RaiseEvent <IShowAoEAffectedUIHandler> (h => h.HandleAoEMove(new Vector3(radius, canTargetEnemies ? 1f : 0f, canTargetFriends ? 1f : 0f), null)); return; } void GetRadius() { AbilityData ability = ShowAutoCastAbilityRange ? unit.GetAvailableAutoUseAbility() : null; if (ability != null) { radius = ability.GetAbilityRadius(); canTargetEnemies = ability.Blueprint.CanTargetEnemies; canTargetFriends = ability.Blueprint.CanTargetFriends; _range.VisibleColor = ability.TargetAnchor == AbilityTargetAnchor.Owner ? Color.green : Color.yellow; } else { radius = unit.GetAttackRadius(); _range.VisibleColor = Color.red; } } } if (Unit != null) { _range.SetVisible(false); Unit = null; if (_isHandlingAOEMove) { EventBus.RaiseEvent <IShowAoEAffectedUIHandler>(h => h.HandleAoECancel()); } } }