mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
add triggers
This commit is contained in:
parent
50c714692a
commit
5769be8ec8
15 changed files with 239 additions and 64 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "../typedefs.hpp"
|
||||
#include "../physics/Hitbox.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <glm/glm.hpp>
|
||||
#include <unordered_map>
|
||||
|
|
@ -14,6 +15,8 @@ struct entity_funcs_set {
|
|||
bool on_despawn : 1;
|
||||
bool on_grounded : 1;
|
||||
bool on_fall : 1;
|
||||
bool on_trigger_enter : 1;
|
||||
bool on_trigger_exit : 1;
|
||||
};
|
||||
|
||||
struct EntityDef;
|
||||
|
|
@ -21,6 +24,7 @@ struct EntityDef;
|
|||
struct EntityId {
|
||||
entityid_t uid;
|
||||
const EntityDef& def;
|
||||
bool destroyFlag = false;
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
|
|
@ -35,6 +39,7 @@ struct Transform {
|
|||
struct Rigidbody {
|
||||
bool enabled = true;
|
||||
Hitbox hitbox;
|
||||
std::vector<Trigger> triggers;
|
||||
};
|
||||
|
||||
struct Scripting {
|
||||
|
|
@ -59,8 +64,8 @@ public:
|
|||
Entity(Entities& entities, entityid_t id, entt::registry& registry, const entt::entity entity)
|
||||
: entities(entities), id(id), registry(registry), entity(entity) {}
|
||||
|
||||
entityid_t getID() const {
|
||||
return id;
|
||||
EntityId& getID() const {
|
||||
return registry.get<EntityId>(entity);
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
|
|
@ -106,7 +111,7 @@ public:
|
|||
void updatePhysics(float delta);
|
||||
void update();
|
||||
|
||||
void renderDebug(LineBatch& batch);
|
||||
void renderDebug(LineBatch& batch, Frustum& frustum);
|
||||
void render(Assets* assets, ModelBatch& batch, Frustum& frustum);
|
||||
|
||||
entityid_t spawn(EntityDef& def, glm::vec3 pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue