add entity trigger type parameter
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"hitbox": [0.2, 0.125, 0.2],
|
"hitbox": [0.2, 0.125, 0.2],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
[-0.2, -0.2, -0.2, 0.2, 0.2, 0.2]
|
["aabb", -0.2, -0.2, -0.2, 0.2, 0.2, 0.2]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ function file.readlines(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
stdcomp = require "core:internal/stdcomp"
|
stdcomp = require "core:internal/stdcomp"
|
||||||
entity.get = stdcomp.get_Entity
|
entities.get = stdcomp.get_Entity
|
||||||
|
|
||||||
-- Deprecated functions
|
-- Deprecated functions
|
||||||
block_index = block.index
|
block_index = block.index
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "../logic/scripting/scripting.hpp"
|
#include "../logic/scripting/scripting.hpp"
|
||||||
#include "../typedefs.hpp"
|
#include "../typedefs.hpp"
|
||||||
#include "../util/listutil.hpp"
|
#include "../util/listutil.hpp"
|
||||||
|
#include "../util/stringutil.hpp"
|
||||||
#include "../voxels/Block.hpp"
|
#include "../voxels/Block.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -317,10 +318,16 @@ void ContentLoader::loadEntity(EntityDef& def, const std::string& name, const fs
|
|||||||
if (auto triggersarr = root->list("triggers")) {
|
if (auto triggersarr = root->list("triggers")) {
|
||||||
for (size_t i = 0; i < triggersarr->size(); i++) {
|
for (size_t i = 0; i < triggersarr->size(); i++) {
|
||||||
if (auto triggerarr = triggersarr->list(i)) {
|
if (auto triggerarr = triggersarr->list(i)) {
|
||||||
def.triggers.push_back({
|
auto triggerType = triggerarr->str(0);
|
||||||
{triggerarr->num(0), triggerarr->num(1), triggerarr->num(2)},
|
if (triggerType == "aabb") {
|
||||||
{triggerarr->num(3), triggerarr->num(4), triggerarr->num(5)}
|
def.boxTriggers.push_back({
|
||||||
});
|
{triggerarr->num(1), triggerarr->num(2), triggerarr->num(3)},
|
||||||
|
{triggerarr->num(4), triggerarr->num(5), triggerarr->num(6)}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.error() << name << ": trigger #" << i << " - unknown type "
|
||||||
|
<< util::quote(triggerType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ entityid_t Entities::spawn(
|
|||||||
registry.emplace<Transform>(entity, pos, size, glm::mat3(1.0f));
|
registry.emplace<Transform>(entity, pos, size, glm::mat3(1.0f));
|
||||||
auto& body = registry.emplace<Rigidbody>(
|
auto& body = registry.emplace<Rigidbody>(
|
||||||
entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
|
entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
|
||||||
for (auto& box : def.triggers) {
|
for (auto& box : def.boxTriggers) {
|
||||||
body.triggers.emplace_back(Trigger{
|
body.triggers.emplace_back(Trigger{
|
||||||
true,
|
true,
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ struct EntityDef {
|
|||||||
|
|
||||||
std::string scriptName = name.substr(name.find(':')+1);
|
std::string scriptName = name.substr(name.find(':')+1);
|
||||||
glm::vec3 hitbox {0.5f};
|
glm::vec3 hitbox {0.5f};
|
||||||
std::vector<AABB> triggers {};
|
std::vector<AABB> boxTriggers {};
|
||||||
std::string rigName = name.substr(name.find(":")+1);
|
std::string rigName = name.substr(name.find(":")+1);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user