package gameEngine.entites.gameComponents; import gameEngine.Time; import gameEngine.entites.Entity; import gameEngine.input.Input; import gameEngine.input.MouseInput; import gameEngine.scenes.Scene; import gameEngine.views.Window; public abstract class Draggable extends GameComponent { protected Entity parent; protected boolean isDraggable = true; protected boolean isDragging = false; public void setDraggable(boolean draggable) { this.isDraggable = draggable; } public void handleDragging() { if (!isDraggable) return; float mouseX = MouseInput.getX(); float mouseY = MouseInput.getY(); Scene scene = Window.get().getScene(); if (scene.getSelectedEntity() == null) { if (Input.GetMouseButtonDown(0) && isMouseOver(mouseX, mouseY)) { isDragging = true; scene.setSelectedEntity(parent); // エンティティを選択 } } if (isDragging && Input.GetMouseButton(0)) { draggingAction(mouseX, mouseY); // ドラッグ中の処理 } if (Input.GetMouseButtonUp(0)) { isDragging = false; scene.clearSelectedEntity(); // ドラッグ終了時に選択解除 } } protected abstract boolean isMouseOver(float mouseX, float mouseY); protected abstract void draggingAction(float mouseX, float mouseY); }