Abstract base class for entity interaction handlers. More...
#include <base_entity_handler.h>


Public Member Functions | |
| virtual | ~BaseEntityHandler ()=default |
| void | SetContext (InteractionContext *ctx) |
| Set the interaction context. | |
| InteractionContext * | context () const |
| Get the interaction context. | |
| virtual void | BeginPlacement ()=0 |
| Begin placement mode. | |
| virtual void | CancelPlacement ()=0 |
| Cancel current placement. | |
| virtual bool | IsPlacementActive () const =0 |
| Check if placement mode is active. | |
| virtual bool | HandleClick (int canvas_x, int canvas_y)=0 |
| Handle mouse click at canvas position. | |
| virtual void | HandleDrag (ImVec2 current_pos, ImVec2 delta)=0 |
| Handle mouse drag. | |
| virtual void | HandleRelease ()=0 |
| Handle mouse release. | |
| virtual void | DrawGhostPreview ()=0 |
| Draw ghost preview during placement. | |
| virtual void | DrawSelectionHighlight ()=0 |
| Draw selection highlight for selected entities. | |
| virtual std::optional< size_t > | GetEntityAtPosition (int canvas_x, int canvas_y) const =0 |
| Get entity at canvas position. | |
Protected Member Functions | |
| std::pair< int, int > | RoomToCanvas (int room_x, int room_y) const |
| Convert room tile coordinates to canvas pixel coordinates. | |
| std::pair< int, int > | CanvasToRoom (int canvas_x, int canvas_y) const |
| Convert canvas pixel coordinates to room tile coordinates. | |
| bool | IsWithinBounds (int canvas_x, int canvas_y) const |
| Check if coordinates are within room bounds. | |
| ImVec2 | GetCanvasZeroPoint () const |
| Get canvas zero point (for screen coordinate conversion) | |
| float | GetCanvasScale () const |
| Get canvas global scale. | |
| bool | HasValidContext () const |
| Check if context is valid. | |
| zelda3::Room * | GetCurrentRoom () const |
| Get current room (convenience method) | |
Protected Attributes | |
| InteractionContext * | ctx_ = nullptr |
Abstract base class for entity interaction handlers.
Each entity type (object, door, sprite, item) has its own handler that implements this interface. This provides consistent interaction patterns while allowing specialized behavior.
The InteractionCoordinator manages mode switching and dispatches calls to the appropriate handler.
Definition at line 24 of file base_entity_handler.h.
|
virtualdefault |
|
inline |
Set the interaction context.
Must be called before using any other methods. The context provides access to canvas, room data, and callbacks.
Definition at line 34 of file base_entity_handler.h.
References ctx_.
Referenced by yaze::editor::InteractionCoordinator::SetContext().
|
inline |
|
pure virtual |
Begin placement mode.
Called when user selects an entity to place from the palette. Override to initialize placement state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Cancel current placement.
Called when user presses Escape or switches modes. Override to clean up placement state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Check if placement mode is active.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Handle mouse click at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Handle mouse drag.
| current_pos | Current mouse position (screen coords) |
| delta | Mouse movement since last frame |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Handle mouse release.
Called when left mouse button is released after a drag.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Draw ghost preview during placement.
Called every frame when placement mode is active. Shows preview of entity at cursor position.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Draw selection highlight for selected entities.
Called every frame to show selection state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
pure virtual |
Get entity at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, and yaze::editor::SpriteInteractionHandler.
|
inlineprotected |
Convert room tile coordinates to canvas pixel coordinates.
Definition at line 137 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::RoomToCanvas().
Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview().

|
inlineprotected |
Convert canvas pixel coordinates to room tile coordinates.
Definition at line 144 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::CanvasToRoom().

|
inlineprotected |
Check if coordinates are within room bounds.
Definition at line 151 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::IsWithinBounds().

|
inlineprotected |
Get canvas zero point (for screen coordinate conversion)
Definition at line 158 of file base_entity_handler.h.
References yaze::editor::InteractionContext::canvas, ctx_, and yaze::gui::Canvas::zero_point().
Referenced by yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), and yaze::editor::DoorInteractionHandler::DrawSnapIndicators().

|
inlineprotected |
Get canvas global scale.
Definition at line 166 of file base_entity_handler.h.
References yaze::editor::InteractionContext::canvas, ctx_, and yaze::gui::Canvas::global_scale().
Referenced by yaze::editor::SpriteInteractionHandler::CanvasToSpriteCoords(), yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::HandleRelease(), and yaze::editor::ItemInteractionHandler::PlaceItemAtPosition().

|
inlineprotected |
Check if context is valid.
Definition at line 175 of file base_entity_handler.h.
References ctx_, and yaze::editor::InteractionContext::IsValid().
Referenced by yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().

|
inlineprotected |
Get current room (convenience method)
Definition at line 180 of file base_entity_handler.h.
References ctx_, and yaze::editor::InteractionContext::GetCurrentRoom().
Referenced by yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().

|
protected |
Definition at line 128 of file base_entity_handler.h.
Referenced by context(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), GetCanvasScale(), GetCanvasZeroPoint(), GetCurrentRoom(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), HasValidContext(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::DoorInteractionHandler::SelectDoor(), yaze::editor::ItemInteractionHandler::SelectItem(), yaze::editor::SpriteInteractionHandler::SelectSprite(), and SetContext().