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 "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
31{
32private:
33 Manager& manager;
34
35public:
36
37 CollisionHandler(Manager& mManager) :
38 manager(mManager) { };
40
41 static IntersectionBitSet getIntersection( // intersections relative to entityA
42 Entity* entityA,
43 Entity* entityB,
44 Vector2D posModA = Vector2D(0,0),
45 Vector2D posModB = Vector2D(0,0));
46 static IntersectionBitSet getIntersectionWithBounds( // will fail to determine direction if speed high enough to switch from no collision to full overlap in one tick
47 Entity* entity,
48 Vector2D posMod = Vector2D(0,0));
49
50 // temporary function, remove once game.cpp cleaned up
51 std::vector<ColliderComponent*> getColliders(
52 std::initializer_list<Entity::GroupLabel> const& groupLabels,
53 std::initializer_list<Entity*> const& excludedEntities = {});
54
69 template<typename T>
71 Entity* entity,
72 Vector2D posMod = {},
73 std::initializer_list<Entity::GroupLabel> const& groupLabels = {},
74 std::initializer_list<Entity*> const& excludedEntities = {});
75
76 void update();
77};
Definition ColliderComponent.h:11
Definition CollisionHandler.h:31
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
Definition Vector2D.h:7