package gameEngine.entites.editorComponents; import gameEngine.entites.EditorEntity; import gameEngine.entites.Entity; 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 isDragging = 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)) { isDragging = true; scene.setSelectedEntity(parent); // エンティティを選択 } } if (isDragging && Input.GetMouseButton(0)) { draggingAction(mouseX, mouseY); // ドラッグ中の処理 } if (Input.GetMouseButtonUp(0)) { isDragging = false; scene.clearSelectedObject(); // ドラッグ終了時に選択解除 } } protected abstract boolean isMouseOver(float mouseX, float mouseY); protected abstract void draggingAction(float mouseX, float mouseY); }