-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcollider.hpp
More file actions
34 lines (26 loc) · 1006 Bytes
/
Copy pathcollider.hpp
File metadata and controls
34 lines (26 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include <ecs/component.hpp>
#include <glm/glm.hpp>
namespace gameplay {
enum class ColliderShape { Sphere, Capsule, Box };
enum CollisionLayer : short {
LAYER_PLAYER = 1 << 0, // bit 0: 0000 0001
LAYER_ENEMY = 1 << 1, // bit 1: 0000 0010
LAYER_ENVIRONMENT = 1 << 2, // bit 2: 0000 0100
LAYER_PROJECTILE = 1 << 3, // bit 3: 0000 1000
LAYER_TRIGGER = 1 << 4, // bit 4: 0001 0000
};
class ColliderComponent : public our::Component {
public:
ColliderShape shape = ColliderShape::Sphere;
CollisionLayer layer = CollisionLayer::LAYER_ENVIRONMENT;
float radius = 0.5f;
float height = 1.0f; // must be the total height
bool isTrigger = false;
glm::vec3 halfExtents = glm::vec3(0.5f);
static std::string getID() {
return "Collider";
}
void deserialize(const nlohmann::json& data) override;
};
} // namespace gameplay