From d3c06188a7de3f6da36816fa18f00a5df1bebe9b Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sat, 29 Aug 2020 02:08:19 -0700 Subject: [PATCH] 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) --- .../riiablo/engine/client/CursorMovementSystem.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/com/riiablo/engine/client/CursorMovementSystem.java b/core/src/com/riiablo/engine/client/CursorMovementSystem.java index 3926ad54..b67bacb1 100644 --- a/core/src/com/riiablo/engine/client/CursorMovementSystem.java +++ b/core/src/com/riiablo/engine/client/CursorMovementSystem.java @@ -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(); }