<commit_before>package net.mostlyoriginal.game.system.interaction;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Wire;
import com.artemis.managers.TagManager;
import com.artemis.systems.EntityProcessingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import net.mostlyoriginal.api.component.basic.Bounds;
import net.mostlyoriginal.api.system.physics.CollisionSystem;
import net.mostlyoriginal.game.component.ui.Clickable;

/**
 * Track mouse over clickables. will indicate hover or clicked.
 *
 * @author <NAME>
 */
@Wire
public class MouseClickSystem extends EntityProcessingSystem {

    CollisionSystem system;
    TagManager tagManager;

    protected ComponentMapper<Clickable> mClickable;
    private boolean leftMousePressed;
    private boolean rightMousePressed;

    public MouseClickSystem() {
        super(Aspect.getAspectForAll(Clickable.class, Bounds.class));
    }

    @Override
    protected void begin() {
        super.begin();

        leftMousePressed = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
        rightMousePressed = Gdx.input.isButtonPressed(Input.Buttons.RIGHT);
    }

    @Override
    protected void process(Entity e) {
        final Entity cursor = tagManager.getEntity("cursor");
        if ( cursor != null )
        {
            // update state based on cursor.
            final Clickable clickable = mClickable.get(e);
            final boolean overlapping = system.overlaps(cursor, e);
            if ( overlapping )
            {
                clickable.state =
                        rightMousePressed ? Clickable.ClickState.CLICKED_RIGHT :
                        leftMousePressed ?  Clickable.ClickState.CLICKED_LEFT : Clickable.ClickState.HOVER;
            } else {
                clickable.state = Clickable.ClickState.NONE;
            }
        }
    }
}<commit_msg>Fix clicking system from triggering on held mouse.<commit_after>package net.mostlyoriginal.game.system.interaction;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Wire;
import com.artemis.managers.TagManager;
import com.artemis.systems.EntityProcessingSystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import net.mostlyoriginal.api.component.basic.Bounds;
import net.mostlyoriginal.api.system.physics.CollisionSystem;
import net.mostlyoriginal.game.component.ui.Clickable;

/**
 * Track mouse over clickables. will indicate hover or clicked.
 *
 * @author <NAME>
 */
@Wire
public class MouseClickSystem extends EntityProcessingSystem {

    CollisionSystem system;
    TagManager tagManager;

    protected ComponentMapper<Clickable> mClickable;
    private boolean leftMouseTapped;
    private boolean rightMouseTapped;
    private boolean leftAlreadyDown;
    private boolean rightAlreadyDown;

    public MouseClickSystem() {
        super(Aspect.getAspectForAll(Clickable.class, Bounds.class));
    }

    @Override
    protected void begin() {
        super.begin();

        leftMouseTapped = Gdx.input.isButtonPressed(Input.Buttons.LEFT) && !leftAlreadyDown;
        rightMouseTapped = Gdx.input.isButtonPressed(Input.Buttons.RIGHT) && !rightAlreadyDown;
    }

    @Override
    protected void end() {
        super.end();

        leftAlreadyDown = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
        rightAlreadyDown = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
    }

    @Override
    protected void process(Entity e) {
        final Entity cursor = tagManager.getEntity("cursor");
        if ( cursor != null )
        {
            // update state based on cursor.
            final Clickable clickable = mClickable.get(e);
            final boolean overlapping = system.overlaps(cursor, e);
            if ( overlapping )
            {
                clickable.state =
                        rightMouseTapped ? Clickable.ClickState.CLICKED_RIGHT :
                        leftMouseTapped ?  Clickable.ClickState.CLICKED_LEFT : Clickable.ClickState.HOVER;
            } else {
                clickable.state = Clickable.ClickState.NONE;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0898716119828816, 'fraction_numerical': 0.0, 'mean_word_length': 2.8420091324200913, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3524836', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1152, 'n_words': 232}