Held interactions keep their area, new ones start only on click
This commit is contained in:
1 parent
d51a6b7e63
commit
30bfde4182
1 file changed
+5
-2
+5
-2
@@ -19,6 +19,8 @@ constexpr float AUTO_SPEED = 9;
|
||||
constexpr float AUTO_TARGET_EPSILON = 0.001f;
|
||||
constexpr int AUTO_CLICK_COOLDOWN = 45;
|
||||
|
||||
// Hovers and works the interact areas under the cursor. An interaction starts only on a click, and a held one keeps its
|
||||
// area until let go or left, never passing to another the cursor drifts over.
|
||||
void Interactions::update(Play& play, Pointer pointer)
|
||||
{
|
||||
Character& character = *play.character;
|
||||
@@ -42,6 +44,8 @@ void Interactions::update(Play& play, Pointer pointer)
|
||||
|
||||
for (int i = 0; i < (int)character.interactAreas.size(); i++)
|
||||
{
|
||||
if (isInteracting && area >= 0 && i != area)
|
||||
continue;
|
||||
InteractArea& entry = character.interactAreas[i];
|
||||
bool isInside = is_point_in_rect(body.actor.null_rect_get(entry.null), pointer.position);
|
||||
if (play.cursorState == CURSOR_DEFAULT && isInside && !pointer.isCaptured && entry.type == pointer.type)
|
||||
@@ -50,8 +54,7 @@ void Interactions::update(Play& play, Pointer pointer)
|
||||
active.play(entry.cursorHover, TRANSITION_IF_IDLE);
|
||||
isHovering = true;
|
||||
area = i;
|
||||
bool isHoldStart = entry.isHold && (pointer.isClicked || (pointer.isDown && !isInteracting));
|
||||
if (isHoldStart || (!entry.isHold && pointer.isClicked))
|
||||
if (pointer.isClicked)
|
||||
{
|
||||
if (entry.isHold)
|
||||
isInteracting = isHolding = true;
|
||||
|
||||
Reference in new issue
Block a user