Broke RoomData::RunFrame() into several parts for readability
This commit is contained in:
@@ -62,6 +62,17 @@
|
|||||||
|
|
||||||
//NOTE: character collisions should be preformed client-side
|
//NOTE: character collisions should be preformed client-side
|
||||||
void RoomData::RunFrame() {
|
void RoomData::RunFrame() {
|
||||||
|
RunFrameUpdates(RunFrameLuaOnTick());
|
||||||
|
RunFrameTriggers();
|
||||||
|
RunFrameCharacterCreatureCollisions();
|
||||||
|
RunFrameCharacterBarrierCollisions();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//hi-cohesion methods for one-time use
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
|
bool RoomData::RunFrameLuaOnTick() {
|
||||||
//get the hook
|
//get the hook
|
||||||
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
||||||
|
|
||||||
@@ -75,7 +86,7 @@ void RoomData::RunFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//pump creatures & barriers
|
//pump creatures & barriers
|
||||||
if (lua_tonumber(lua, -1)) {
|
if (lua_tonumber(lua, -1) > 0) {
|
||||||
updateAll = true;
|
updateAll = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +96,10 @@ void RoomData::RunFrame() {
|
|||||||
lua_pop(lua, 1);
|
lua_pop(lua, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return updateAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoomData::RunFrameUpdates(bool updateAll) {
|
||||||
//lists of non-character entities that need updating client-side
|
//lists of non-character entities that need updating client-side
|
||||||
std::list<std::pair<const int, CreatureData*>> creatureList;
|
std::list<std::pair<const int, CreatureData*>> creatureList;
|
||||||
std::list<std::pair<const int, BarrierData*>> barrierList;
|
std::list<std::pair<const int, BarrierData*>> barrierList;
|
||||||
@@ -118,8 +133,12 @@ void RoomData::RunFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: send the combat instance updates
|
//TODO: send the combat instance updates
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoomData::RunFrameTriggers() {
|
||||||
|
|
||||||
//build a list of entities for use with the triggers
|
//build a list of entities for use with the triggers
|
||||||
|
//currently, this only uses characters
|
||||||
std::stack<Entity*> entityStack;
|
std::stack<Entity*> entityStack;
|
||||||
for (auto& it : characterList) {
|
for (auto& it : characterList) {
|
||||||
entityStack.push(it);
|
entityStack.push(it);
|
||||||
@@ -127,7 +146,9 @@ void RoomData::RunFrame() {
|
|||||||
|
|
||||||
//Compare the triggers to the entities, using their real hitboxes
|
//Compare the triggers to the entities, using their real hitboxes
|
||||||
triggerMgr.Compare(entityStack);
|
triggerMgr.Compare(entityStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoomData::RunFrameCharacterCreatureCollisions() {
|
||||||
//Creature/character collisions, O(m*n), making the barriers
|
//Creature/character collisions, O(m*n), making the barriers
|
||||||
for (auto characterIt : characterList) {
|
for (auto characterIt : characterList) {
|
||||||
BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin();
|
BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin();
|
||||||
@@ -171,7 +192,9 @@ void RoomData::RunFrame() {
|
|||||||
creatureMgr.Unload(it);
|
creatureMgr.Unload(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoomData::RunFrameCharacterBarrierCollisions() {
|
||||||
//TODO: check for character collisions with barriers, O(m*n)
|
//TODO: check for character collisions with barriers, O(m*n)
|
||||||
for (auto characterIt : characterList) {
|
for (auto characterIt : characterList) {
|
||||||
BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin();
|
BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin();
|
||||||
@@ -193,6 +216,10 @@ void RoomData::RunFrame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//Utility methods
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
std::string RoomData::SetName(std::string s) {
|
std::string RoomData::SetName(std::string s) {
|
||||||
return roomName = s;
|
return roomName = s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ public:
|
|||||||
std::string GetTag(std::string key);
|
std::string GetTag(std::string key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//hi-cohesion methods for one-time use
|
||||||
|
bool RunFrameLuaOnTick();
|
||||||
|
void RunFrameUpdates(bool updateAll);
|
||||||
|
void RunFrameTriggers();
|
||||||
|
void RunFrameCharacterCreatureCollisions();
|
||||||
|
void RunFrameCharacterBarrierCollisions();
|
||||||
|
|
||||||
//metadata
|
//metadata
|
||||||
std::string roomName;
|
std::string roomName;
|
||||||
std::string tilesetName;
|
std::string tilesetName;
|
||||||
|
|||||||
Reference in New Issue
Block a user