package gameEngine.entites.editorComponents; import gameEngine.entites.EditorEntity; import gameEngine.input.Input; import gameEngine.input.MouseInput; import gameEngine.scenes.EditorScene; import gameEngine.views.Window; public abstract class Draggable extends EditorComponent { protected EditorEntity parent; protected boolean isDraggable = true; protected boolean isLeftDragging = false; protected boolean isRightDragging = false; public void setDraggable(boolean draggable) { this.isDraggable = draggable; } public void handleDragging() { if (!isDraggable) return; float mouseX = MouseInput.getX(); float mouseY = MouseInput.getY(); EditorScene scene = (EditorScene) Window.get().getScene(); if (scene.getSelectedEntity() == null) { if (Input.GetMouseButtonDown(0) && isMouseOver(mouseX, mouseY)) { isLeftDragging = true; scene.setSelectedEntity(parent); scene.setClickedEntity(parent); } if (Input.GetMouseButtonDown(1) && isMouseOver(mouseX, mouseY)) { isRightDragging = true; scene.setSelectedEntity(parent); scene.setClickedEntity(parent); } } if (isLeftDragging && Input.GetMouseButton(0)) { leftDraggingAction(mouseX, mouseY); // ドラッグ中の処理 } if (isRightDragging && Input.GetMouseButton(1)) { rightDraggingAction(mouseX, mouseY); // ドラッグ中の処理 } if (Input.GetMouseButtonUp(0)) { isLeftDragging = false; scene.clearSelectedObject(); // ドラッグ終了時に選択解除 } if (Input.GetMouseButtonUp(1)) { isRightDragging = false; scene.clearSelectedObject(); // ドラッグ終了時に選択解除 } } protected abstract boolean isMouseOver(float mouseX, float mouseY); protected abstract void leftDraggingAction(float mouseX, float mouseY); protected abstract void rightDraggingAction(float mouseX, float mouseY); }