Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
CameraEventHandler.h
Go to the documentation of this file.
1/*
2Olympe Engine V2 - 2025
3Nicolas Chereau
4nchereau@gmail.com
5
6This file is part of Olympe Engine V2.
7
8CameraEventHandler: Singleton class that handles camera-related events
9and provides a public API for camera operations.
10
11*/
12
13#pragma once
14
15#include "message.h"
16#include "../ECS_Entity.h"
17#include <SDL3/SDL.h>
18
19// Forward declarations
20class GameObject;
21
22// Interface for message listeners
24{
25public:
26 virtual ~IMessageListener() = default;
27 virtual void OnEvent(const Message& msg) = 0;
28};
29
30// Camera Event Handler - Singleton that handles camera events
32{
33public:
34 // Singleton access
36 {
38 return instance;
39 }
40 static CameraEventHandler& Get() { return GetInstance(); }
41
42 // Initialization and cleanup
43 void Initialize();
44 void Shutdown();
45
46 // Event handling
47 virtual void OnEvent(const Message& msg) override;
48
49 // Public API for camera operations
50 void TriggerCameraShake(short playerID, float intensity, float duration);
51 void StopCameraShake(short playerID);
52 void TeleportCamera(short playerID, float x, float y);
53 void ZoomCameraTo(short playerID, float targetZoom, float speed);
54 void RotateCameraTo(short playerID, float targetRotation, float speed);
55 void ResetCamera(short playerID);
56 void SetCameraBounds(short playerID, const SDL_FRect& bounds);
57 void ClearCameraBounds(short playerID);
58 void FollowTarget(short playerID, EntityID targetEntity);
60 void UnfollowTarget(short playerID);
61
62private:
63 CameraEventHandler() = default;
65
66 // Delete copy and move constructors
71
72 // Event handlers
73 void HandleShakeEvent(const Message& msg);
74 void HandleShakeStopEvent(const Message& msg);
75 void HandleTeleportEvent(const Message& msg);
76 void HandleZoomEvent(const Message& msg);
77 void HandleRotateEvent(const Message& msg);
78 void HandleResetEvent(const Message& msg);
79 void HandleBoundsEvent(const Message& msg);
81 void HandleFollowEvent(const Message& msg);
82 void HandleUnfollowEvent(const Message& msg);
83
84 bool m_initialized = false;
85};
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::uint64_t EntityID
Definition ECS_Entity.h:21
void HandleUnfollowEvent(const Message &msg)
void HandleTeleportEvent(const Message &msg)
CameraEventHandler(CameraEventHandler &&)=delete
void HandleBoundsEvent(const Message &msg)
CameraEventHandler & operator=(CameraEventHandler &&)=delete
void RotateCameraTo(short playerID, float targetRotation, float speed)
void ZoomCameraTo(short playerID, float targetZoom, float speed)
void HandleFollowEvent(const Message &msg)
void StopCameraShake(short playerID)
void HandleZoomEvent(const Message &msg)
void HandleResetEvent(const Message &msg)
void ClearCameraBounds(short playerID)
virtual void OnEvent(const Message &msg) override
~CameraEventHandler()=default
static CameraEventHandler & GetInstance()
void HandleShakeStopEvent(const Message &msg)
void UnfollowTarget(short playerID)
CameraEventHandler(const CameraEventHandler &)=delete
void SetCameraBounds(short playerID, const SDL_FRect &bounds)
void FollowTarget(short playerID, EntityID targetEntity)
void TeleportCamera(short playerID, float x, float y)
void ResetCamera(short playerID)
CameraEventHandler & operator=(const CameraEventHandler &)=delete
void HandleClearBoundsEvent(const Message &msg)
void HandleRotateEvent(const Message &msg)
void TriggerCameraShake(short playerID, float intensity, float duration)
void FollowTarget_Legacy(short playerID, GameObject *targetObject)
static CameraEventHandler & Get()
void HandleShakeEvent(const Message &msg)
CameraEventHandler()=default
virtual void OnEvent(const Message &msg)=0
virtual ~IMessageListener()=default