Combined stand still and right click casting into one block

Combined stand still and right click casting into one block
Moved vars into final fields to improve readability
Implemented getHovered(int) to get targetId (if any)
This commit is contained in:
Collin Smith 2020-08-29 02:08:19 -07:00
parent 45825b8a3d
commit d3c06188a7

View File

@ -80,14 +80,14 @@ public class CursorMovementSystem extends BaseSystem {
boolean hit = hit1 != null || hit2 != null;
if (hit) return;
if (Gdx.input.isButtonPressed(Input.Buttons.LEFT) && UIUtils.shift()) {
final boolean leftPressed = Gdx.input.isButtonPressed(Input.Buttons.LEFT);
if ((leftPressed && UIUtils.shift()) || Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
setTarget(renderer.getSrc(), Engine.INVALID_ENTITY);
final int playerId = renderer.getSrc();
final int skillId = Riiablo.charData.getAction(leftPressed ? Input.Buttons.LEFT : Input.Buttons.RIGHT);
iso.agg(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY())).unproject().toWorld();
actioneer.cast(renderer.getSrc(), Riiablo.charData.getAction(Input.Buttons.LEFT), Engine.INVALID_ENTITY, tmpVec2);
} else if (Gdx.input.isButtonPressed(Input.Buttons.RIGHT)) {
setTarget(renderer.getSrc(), Engine.INVALID_ENTITY);
iso.agg(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY())).unproject().toWorld();
actioneer.cast(renderer.getSrc(), Riiablo.charData.getAction(Input.Buttons.RIGHT), Engine.INVALID_ENTITY, tmpVec2);
final int targetId = getHovered(playerId);
actioneer.cast(playerId, skillId, targetId, tmpVec2);
} else {
updateLeft();
}