Wrote out the pseudocode for RoomData::RunFrame

This method is too overloaded. The pseudocode itself takes up a whole
page.
This commit is contained in:
2016-07-09 17:25:13 +10:00
parent 4894daa273
commit 011f71ea61
3 changed files with 35 additions and 1 deletions
+1
View File
@@ -81,6 +81,7 @@ static const luaL_Reg barrierLib[] = {
{"GetScript", getScript}, {"GetScript", getScript},
{"SetTag", setTag}, {"SetTag", setTag},
{"GetTag", getTag}, {"GetTag", getTag},
//NOTE: Why is the instance mutable?
{"SetInstance", setInstance}, {"SetInstance", setInstance},
{"GetInstance", getInstance}, {"GetInstance", getInstance},
{"SetStatus", setStatus}, {"SetStatus", setStatus},
+1
View File
@@ -39,6 +39,7 @@ public:
int SetScriptReference(int); int SetScriptReference(int);
int GetScriptReference(); int GetScriptReference();
//NOTE: Why does this have tags? Are the tags used?
std::string SetTag(std::string key, std::string value); std::string SetTag(std::string key, std::string value);
std::string GetTag(std::string key); std::string GetTag(std::string key);
+33 -1
View File
@@ -31,6 +31,35 @@
#include <stack> #include <stack>
#include <stdexcept> #include <stdexcept>
/* DOCS: this is the process for RoomData::RunFrame(), read more
*
* updateAll = OnTick()
*
* characterList .UpdateAll()
* creatureMgr .Update(updateAll)
* barrierMgr .Update(updateAll)
* combatMgr .Update(updateAll)
*
* creatureMgr .SendUpdates()
* barrierMgr .SendUpdates()
* //combatMgr .SendUpdates() //TODO: incomplete
*
* triggerMgr .Compare(characterList)
*
* if (a character collides with a creature)
* barrierMgr .Create()
* combatMgr .Create()
*
* barrierMgr .Send()
*
* creatureMgr .Delete()
* endif
*
* if (a character collides with a barrier)
* //TODO: incomplete
* endif
*/
//NOTE: character collisions should be preformed client-side //NOTE: character collisions should be preformed client-side
void RoomData::RunFrame() { void RoomData::RunFrame() {
//get the hook //get the hook
@@ -88,6 +117,8 @@ void RoomData::RunFrame() {
pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS); pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS);
} }
//TODO: send the combat instance updates
//build a list of entities for use with the triggers //build a list of entities for use with the triggers
std::stack<Entity*> entityStack; std::stack<Entity*> entityStack;
for (auto& it : characterList) { for (auto& it : characterList) {
@@ -107,6 +138,7 @@ void RoomData::RunFrame() {
BoundingBox creatureBox = creatureIt.second.GetBounds() + creatureIt.second.GetOrigin(); BoundingBox creatureBox = creatureIt.second.GetBounds() + creatureIt.second.GetOrigin();
if (characterBox.CheckOverlap(creatureBox)) { if (characterBox.CheckOverlap(creatureBox)) {
//create the barrier and instance
int barrierIndex = barrierMgr.Create(combatInstanceMgr.Create()); //link the barrier to an instance int barrierIndex = barrierMgr.Create(combatInstanceMgr.Create()); //link the barrier to an instance
BarrierData* barrierData = barrierMgr.Find(barrierIndex); BarrierData* barrierData = barrierMgr.Find(barrierIndex);
barrierData->SetRoomIndex(roomIndex); barrierData->SetRoomIndex(roomIndex);
@@ -151,7 +183,7 @@ void RoomData::RunFrame() {
//TODO: (0) actually move the character to an instance //TODO: (0) actually move the character to an instance
CombatInstance* instance = combatInstanceMgr.Find(barrierIt.second.GetInstanceIndex()); CombatInstance* instance = combatInstanceMgr.Find(barrierIt.second.GetInstanceIndex());
//... //DEBUG: output barrierIndex, instanceIndex
std::cout << barrierIt.first << "\t" << barrierIt.second.GetInstanceIndex() << std::endl; std::cout << barrierIt.first << "\t" << barrierIt.second.GetInstanceIndex() << std::endl;
//only confirm one barrier per character //only confirm one barrier per character