Beispiel #1
0
        void Update()
        {
            if (IsInCombat() && IsHUDShown())
            {
                UnitEntityData unit        = null;
                float          radiusInner = 0f;
                float          radiusOuter = 0f;

                if (ShowMovementIndicatorOnHoverUI && (unit = Mod.Core.UI.CombatTracker.HoveringUnit) != null)
                {
                    radiusInner = unit.CurrentSpeedMps * TIME_MOVE_ACTION;
                    radiusOuter = radiusInner * 2f;
                }
                else
                {
                    if (ShowMovementIndicatorOfCurrentUnit && (unit = CurrentUnit(out ModTurnController currentTurn)) != null &&
                        (unit.IsDirectlyControllable ? ShowMovementIndicatorForPlayer : ShowMovementIndicatorForNonPlayer))
                    {
                        radiusInner = currentTurn.GetRemainingMovementRange();
                        radiusOuter = currentTurn.GetRemainingMovementRange(true);
                    }
                }

                if (unit != null && radiusOuter > 0 && (!DoNotMarkInvisibleUnit || unit.IsVisibleForPlayer))
                {
                    _rangeOuter.SetPosition(unit);
                    _rangeOuter.SetRadius(radiusOuter);
                    _rangeOuter.SetVisible(true);

                    if (radiusOuter != radiusInner)
                    {
                        _rangeInner.SetPosition(unit);
                        _rangeInner.SetRadius(radiusInner);
                        _rangeInner.SetVisible(true);
                    }
                    else
                    {
                        _rangeInner.SetVisible(false);
                    }

                    return;
                }
            }

            _rangeInner.SetVisible(false);
            _rangeOuter.SetVisible(false);
        }
        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 ModTurnController 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());
                }
            }
        }