VEGO-Engine  0.1
Loading...
Searching...
No Matches
CollisionHandler.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "ColliderComponent.h"
8#include "Constants.h"
9#include "Entity.h"
10#include <SDL3/SDL_rect.h>
11#include "SpriteComponent.h"
12#include "Vector2D.h"
13#include "Manager.h"
14
15#include <bitset>
16#include <initializer_list>
17#include <tuple>
18#include <utility>
19#include <vector>
20
22class Entity;
23
24// [IntersectionBitSet]
25constexpr uint8_t DIRECTION_C = 4;
26
27using IntersectionBitSet = std::bitset<DIRECTION_C>;
28// [IntersectionBitSet]
29
31class CollisionHandler
32{
33private:
34 Manager& manager;
35
36public:
37
38 CollisionHandler(Manager& mManager) :
39 manager(mManager) { };
40 ~CollisionHandler();
41
46 static IntersectionBitSet getIntersection(
47 Entity* entityA,
48 Entity* entityB,
49 Vector2D posModA = Vector2D(0,0),
50 Vector2D posModB = Vector2D(0,0));
51 static IntersectionBitSet getIntersectionWithBounds( // will fail to determine direction if speed high enough to switch from no collision to full overlap in one tick
52 Entity* entity,
53 Vector2D posMod = Vector2D(0,0));
54
55 // temporary function, remove once game.cpp cleaned up
56 std::vector<ColliderComponent*> getColliders(
57 std::initializer_list<Entity::GroupLabel> const& groupLabels,
58 std::initializer_list<Entity*> const& excludedEntities = {});
59
74 template<typename T>
76 Entity* entity,
77 Vector2D posMod = {},
78 std::initializer_list<Entity::GroupLabel> const& groupLabels = {},
79 std::initializer_list<Entity*> const& excludedEntities = {});
80
81 void update();
82};
Adds a collision box to an entity when added via entity.addComponent()
Definition ColliderComponent.h:12
static IntersectionBitSet getIntersection(Entity *entityA, Entity *entityB, Vector2D posModA=Vector2D(0, 0), Vector2D posModB=Vector2D(0, 0))
Checks for intersections relative to entityA.
Definition CollisionHandler.cpp:15
T getAnyIntersection(Entity *entity, Vector2D posMod={}, std::initializer_list< Entity::GroupLabel > const &groupLabels={}, std::initializer_list< Entity * > const &excludedEntities={})
Tests entity against all entities with the specified labels for a collision.
Main class for any object in game, stores associations, labeling and components.
Definition Entity.h:35
Is responsible for managing all entities.
Definition Manager.h:23