Triggers now support exclusion lists
This commit is contained in:
@@ -86,6 +86,21 @@ static int getReference(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pushExclusionEntity(lua_State* L) {
|
||||
TriggerData* trigger = static_cast<TriggerData*>(lua_touserdata(L, 1));
|
||||
trigger->GetExclusionList()->push_back(static_cast<Entity*>(lua_touserdata(L, 2)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int removeExclusionEntity(lua_State* L) {
|
||||
TriggerData* trigger = static_cast<TriggerData*>(lua_touserdata(L, 1));
|
||||
Entity* entity = static_cast<Entity*>(lua_touserdata(L, 2));
|
||||
trigger->GetExclusionList()->remove_if([entity](Entity* ptr){
|
||||
return entity == ptr;
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg triggerLib[] = {
|
||||
{"SetHandle", setHandle},
|
||||
{"GetHandle", getHandle},
|
||||
@@ -99,6 +114,9 @@ static const luaL_Reg triggerLib[] = {
|
||||
{"SetScript",setReference},
|
||||
{"GetScript",getReference},
|
||||
|
||||
{"PushExclusionEntity", pushExclusionEntity},
|
||||
{"RemoveExclusionEntity", removeExclusionEntity},
|
||||
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
|
||||
@@ -51,4 +51,8 @@ int TriggerData::SetScriptReference(int i) {
|
||||
|
||||
int TriggerData::GetScriptReference() {
|
||||
return scriptRef;
|
||||
}
|
||||
|
||||
std::list<Entity*>* TriggerData::GetExclusionList() {
|
||||
return &exclusionList;
|
||||
}
|
||||
@@ -23,13 +23,14 @@
|
||||
#define TRIGGERDATA_HPP_
|
||||
|
||||
#include "bounding_box.hpp"
|
||||
#include "entity.hpp"
|
||||
#include "vector2.hpp"
|
||||
|
||||
#include "lua.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
//TODO: (0) state-system for preventing double triggering
|
||||
class TriggerData {
|
||||
public:
|
||||
TriggerData() = default;
|
||||
@@ -47,11 +48,14 @@ public:
|
||||
int SetScriptReference(int i);
|
||||
int GetScriptReference();
|
||||
|
||||
std::list<Entity*>* GetExclusionList();
|
||||
|
||||
private:
|
||||
std::string handle;
|
||||
Vector2 origin;
|
||||
BoundingBox bounds;
|
||||
int scriptRef = LUA_NOREF;
|
||||
std::list<Entity*> exclusionList;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user