temporary patch for the door system

This commit is contained in:
2016-12-05 01:20:02 +11:00
parent 398ccd5b3f
commit 19ccd823ef
2 changed files with 12 additions and 4 deletions
+8
View File
@@ -66,6 +66,10 @@ function doorUtility.CreateDoorPair(handle, roomOne, Xone, Yone, roomTwo, Xtwo,
--disable the other trigger --disable the other trigger
local triggerTwo = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomTwo), handle) local triggerTwo = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomTwo), handle)
triggerAPI.PushExclusionEntity(triggerTwo, entity) triggerAPI.PushExclusionEntity(triggerTwo, entity)
--bookkeeping: remove from the original trigger's exclusion list
local triggerOne = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomOne), handle)
triggerAPI.RemoveExclusionEntity(triggerOne, entity)
end end
local function scriptTwo(entity) local function scriptTwo(entity)
@@ -79,6 +83,10 @@ function doorUtility.CreateDoorPair(handle, roomOne, Xone, Yone, roomTwo, Xtwo,
--disable the other trigger --disable the other trigger
local triggerOne = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomOne), handle) local triggerOne = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomOne), handle)
triggerAPI.PushExclusionEntity(triggerOne, entity) triggerAPI.PushExclusionEntity(triggerOne, entity)
--bookkeeping: remove from the original trigger's exclusion list
local triggerTwo = triggerManagerAPI.FindTrigger(roomAPI.GetTriggerMgr(roomTwo), handle)
triggerAPI.RemoveExclusionEntity(triggerTwo, entity)
end end
--create the triggers proper --create the triggers proper
+4 -4
View File
@@ -50,6 +50,9 @@ void TriggerManager::Compare(std::stack<Entity*> entityStack) {
continue; continue;
} }
//push to the exclusion list
triggerPair.second.GetExclusionList()->push_back(entity);
//run the trigger script //run the trigger script
lua_rawgeti(lua, LUA_REGISTRYINDEX, triggerPair.second.GetScriptReference()); lua_rawgeti(lua, LUA_REGISTRYINDEX, triggerPair.second.GetScriptReference());
lua_pushlightuserdata(lua, entity); lua_pushlightuserdata(lua, entity);
@@ -58,13 +61,10 @@ void TriggerManager::Compare(std::stack<Entity*> entityStack) {
//error //error
throw(std::runtime_error(std::string() + "Lua error: " + lua_tostring(lua, -1) )); throw(std::runtime_error(std::string() + "Lua error: " + lua_tostring(lua, -1) ));
} }
//push to the exclusion list
triggerPair.second.GetExclusionList()->push_back(entity);
} }
else { else {
//remove members of the exclusion list //remove members of the exclusion list
//NOTE: characters in different rooms won't be removed, but that shouldn't be a problem //NOTE: characters in different rooms won't be removed, which does tend to be a problem
triggerPair.second.GetExclusionList()->remove_if([entity](Entity* ptr) -> bool { triggerPair.second.GetExclusionList()->remove_if([entity](Entity* ptr) -> bool {
return entity == ptr; return entity == ptr;
}); });