internal override bool MouseMoved(IGameViewport viewport, MessageMouseArgs args)
    {
        PickerStatusFlags &= ~PickerStatusFlags.Invalid;

        if (HandleClickInUnexploredArea(args.X, args.Y))
        {
            return(false);
        }

        // The picker may allow picking an object directly (which will be the basis of the area effect)
        if (Picker.modeTarget.HasFlag(UiPickerType.AreaOrObj))
        {
            var flags = PickerState.GetFlagsFromExclusions();
            if (GameSystems.Raycast.PickObjectOnScreen(viewport, args.X, args.Y, out var target, flags))
            {
                if ((Picker.flagsTarget.HasFlag(UiPickerFlagsTarget.LosNotRequired) || !Picker.LosBlocked(target)) &&
                    Picker.CheckTargetVsIncFlags(target) &&
                    Picker.TargetValid(target))
                {
                    ClearResults();
                    Picker.SetAreaTargets(target.GetLocationFull());
                    Result.flags |= PickerResultFlags.PRF_HAS_SELECTED_OBJECT;

                    // Sort the primary focus of selection to the beginning of the list,
                    // But don't insert it if it isn't in the list already
                    if (Result.objList.Remove(target))
                    {
                        Result.objList.Insert(0, target);
                    }

                    return(false);
                }
            }
        }

        var targetLoc = GameViews.Primary.ScreenToTile(args.X, args.Y);

        // Even when the picked object above is not valid, targeting the location underneath is a valid alternative
        if (!Picker.flagsTarget.HasFlag(UiPickerFlagsTarget.LosNotRequired) &&
            !HasLineOfSight(Picker.caster, targetLoc))
        {
            ClearResults();
            PickerStatusFlags |= PickerStatusFlags.Invalid;
            return(false);
        }

        Picker.SetAreaTargets(targetLoc);
        return(false);
    }
示例#2
0
    internal override bool MouseMoved(IGameViewport viewport, MessageMouseArgs args)
    {
        if (HandleClickInUnexploredArea(args.X, args.Y))
        {
            return(false);
        }

        var raycastFlags = PickerState.GetFlagsFromExclusions();

        if (!GameSystems.Raycast.PickObjectOnScreen(viewport, args.X, args.Y, out var target, raycastFlags))
        {
            PickerStatusFlags &= ~(PickerStatusFlags.Invalid | PickerStatusFlags.OutOfRange);
            PickerState.Target = null;
            return(true);
        }

        PickerState.Target = target;

        if (Picker.flagsTarget.HasFlag(UiPickerFlagsTarget.Exclude1st))
        {
            if (!Picker.TargetValid(target))
            {
                PickerStatusFlags |= PickerStatusFlags.Invalid;
            }
        }

        if (!Picker.CheckTargetVsIncFlags(target))
        {
            PickerStatusFlags |= PickerStatusFlags.Invalid;
        }

        if (!Picker.flagsTarget.HasFlag(UiPickerFlagsTarget.LosNotRequired) && Picker.LosBlocked(target))
        {
            PickerStatusFlags |= PickerStatusFlags.Invalid;
        }

        if (Picker.flagsTarget.HasFlag(UiPickerFlagsTarget.Range))
        {
            // TODO: This distance check seems bugged too (feet vs. inch, no radius considered)
            var dist = Picker.caster.GetLocationFull().DistanceTo(target.GetLocationFull());

            if (dist > Picker.range)
            {
                PickerStatusFlags |= PickerStatusFlags.OutOfRange;
            }
        }

        return(true);
    }
    private void SetPartyMemberTarget(GameObject target)
    {
        PickerState.Target = target;
        ClearResults();

        if (!Picker.modeTarget.HasFlag(UiPickerType.AreaOrObj) ||
            !Picker.CheckTargetVsIncFlags(target) ||
            !Picker.TargetValid(target))
        {
            // Only use the target object's location, but not the object itself
            Picker.SetAreaTargets(target.GetLocationFull());
            return;
        }

        Picker.SetAreaTargets(target.GetLocationFull());
        Result.flags |= PickerResultFlags.PRF_HAS_SELECTED_OBJECT;

        // Sort the primary focus of selection to the beginning of the list,
        // But don't insert it if it isn't in the list already
        if (Result.objList.Remove(target))
        {
            Result.objList.Insert(0, target);
        }
    }