update RigConfig

This commit is contained in:
MihailRis
2024-07-01 05:30:27 +03:00
parent 1b41a75cf4
commit beac332c96
15 changed files with 230 additions and 62 deletions
+4 -2
View File
@@ -36,7 +36,8 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args) {
auto id = nextID++;
registry.emplace<EntityId>(entity, static_cast<entityid_t>(id), def);
registry.emplace<Transform>(entity, pos, size, glm::mat3(1.0f));
auto& body = registry.emplace<Rigidbody>(entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
auto& body = registry.emplace<Rigidbody>(
entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
for (auto& box : def.triggers) {
body.triggers.emplace_back(Trigger{true, id, box, AABB{}, {}, {},
[=](auto entityid, auto index, auto otherid) {
@@ -140,7 +141,8 @@ void Entities::updatePhysics(float delta) {
hitbox.linearDamping = hitbox.grounded * 24;
transform.setPos(hitbox.position);
if (hitbox.grounded && !grounded) {
scripting::on_entity_grounded(*get(eid.uid), glm::length(prevVel-hitbox.velocity));
scripting::on_entity_grounded(
*get(eid.uid), glm::length(prevVel-hitbox.velocity));
}
if (!hitbox.grounded && grounded) {
scripting::on_entity_fall(*get(eid.uid));