Combat instances are created alongside the barriers
This commit is contained in:
@@ -77,16 +77,12 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
|
|||||||
disconnectButton.SetText(GetRenderer(), font, WHITE, "Disconnect");
|
disconnectButton.SetText(GetRenderer(), font, WHITE, "Disconnect");
|
||||||
shutdownButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
shutdownButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
||||||
shutdownButton.SetText(GetRenderer(), font, WHITE, "Shutdown");
|
shutdownButton.SetText(GetRenderer(), font, WHITE, "Shutdown");
|
||||||
inventoryButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture());
|
|
||||||
inventoryButton.SetText(GetRenderer(), font, WHITE, "Inventory");
|
|
||||||
|
|
||||||
//set the button positions
|
//set the button positions
|
||||||
disconnectButton.SetX(50);
|
disconnectButton.SetX(50);
|
||||||
disconnectButton.SetY(50);
|
disconnectButton.SetY(50);
|
||||||
shutdownButton.SetX(50);
|
shutdownButton.SetX(50);
|
||||||
shutdownButton.SetY(70);
|
shutdownButton.SetY(70);
|
||||||
inventoryButton.SetX(50);
|
|
||||||
inventoryButton.SetY(90);
|
|
||||||
|
|
||||||
//load the tilesheet
|
//load the tilesheet
|
||||||
//TODO: (2) Tile size and tile sheet should be loaded elsewhere
|
//TODO: (2) Tile size and tile sheet should be loaded elsewhere
|
||||||
@@ -270,7 +266,6 @@ void World::RenderFrame(SDL_Renderer* renderer) {
|
|||||||
//draw UI
|
//draw UI
|
||||||
disconnectButton.DrawTo(renderer);
|
disconnectButton.DrawTo(renderer);
|
||||||
shutdownButton.DrawTo(renderer);
|
shutdownButton.DrawTo(renderer);
|
||||||
inventoryButton.DrawTo(renderer);
|
|
||||||
|
|
||||||
//FPS
|
//FPS
|
||||||
fpsTextLine.DrawTo(renderer);
|
fpsTextLine.DrawTo(renderer);
|
||||||
@@ -295,13 +290,11 @@ void World::QuitEvent() {
|
|||||||
void World::MouseMotion(SDL_MouseMotionEvent const& event) {
|
void World::MouseMotion(SDL_MouseMotionEvent const& event) {
|
||||||
disconnectButton.MouseMotion(event);
|
disconnectButton.MouseMotion(event);
|
||||||
shutdownButton.MouseMotion(event);
|
shutdownButton.MouseMotion(event);
|
||||||
inventoryButton.MouseMotion(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::MouseButtonDown(SDL_MouseButtonEvent const& event) {
|
void World::MouseButtonDown(SDL_MouseButtonEvent const& event) {
|
||||||
disconnectButton.MouseButtonDown(event);
|
disconnectButton.MouseButtonDown(event);
|
||||||
shutdownButton.MouseButtonDown(event);
|
shutdownButton.MouseButtonDown(event);
|
||||||
inventoryButton.MouseButtonDown(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
void World::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
||||||
@@ -311,9 +304,6 @@ void World::MouseButtonUp(SDL_MouseButtonEvent const& event) {
|
|||||||
if (shutdownButton.MouseButtonUp(event) == Button::State::RELEASED) {
|
if (shutdownButton.MouseButtonUp(event) == Button::State::RELEASED) {
|
||||||
SendAdminShutdownRequest();
|
SendAdminShutdownRequest();
|
||||||
}
|
}
|
||||||
if (inventoryButton.MouseButtonUp(event) == Button::State::RELEASED) {
|
|
||||||
//TODO: show the inventory screen
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::MouseWheel(SDL_MouseWheelEvent const& event) {
|
void World::MouseWheel(SDL_MouseWheelEvent const& event) {
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ private:
|
|||||||
TTF_Font* font = nullptr;
|
TTF_Font* font = nullptr;
|
||||||
Button disconnectButton;
|
Button disconnectButton;
|
||||||
Button shutdownButton;
|
Button shutdownButton;
|
||||||
Button inventoryButton;
|
|
||||||
FrameRate fps;
|
FrameRate fps;
|
||||||
TextLine fpsTextLine;
|
TextLine fpsTextLine;
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ BarrierData::~BarrierData() {
|
|||||||
int BarrierData::Update(lua_State* L) {
|
int BarrierData::Update(lua_State* L) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
//NOTE: this is here mostly for the "barrier tick" effect
|
||||||
if (scriptRef != LUA_NOREF) {
|
if (scriptRef != LUA_NOREF) {
|
||||||
//Call the script reference
|
//Call the script reference
|
||||||
lua_pushinteger(L, scriptRef);
|
lua_pushinteger(L, scriptRef);
|
||||||
|
|||||||
+40
-18
@@ -31,7 +31,7 @@
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//TODO: (9) 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
|
||||||
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
||||||
@@ -67,6 +67,27 @@ void RoomData::RunFrame() {
|
|||||||
creatureMgr.Update(&creatureList, updateAll);
|
creatureMgr.Update(&creatureList, updateAll);
|
||||||
barrierMgr.Update(&barrierList, updateAll);
|
barrierMgr.Update(&barrierList, updateAll);
|
||||||
|
|
||||||
|
//update the combat instances
|
||||||
|
combatInstanceMgr.Update();
|
||||||
|
|
||||||
|
//send the creature updates
|
||||||
|
for (auto& it : creatureList) {
|
||||||
|
CreaturePacket packet;
|
||||||
|
copyCreatureToPacket(&packet, it.second, it.first);
|
||||||
|
packet.type = SerialPacketType::CREATURE_UPDATE;
|
||||||
|
packet.roomIndex = roomIndex;
|
||||||
|
pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
//send the barrier updates
|
||||||
|
for (auto& it : barrierList) {
|
||||||
|
BarrierPacket packet;
|
||||||
|
copyBarrierToPacket(&packet, it.second, it.first);
|
||||||
|
packet.type = SerialPacketType::BARRIER_UPDATE;
|
||||||
|
packet.roomIndex = roomIndex;
|
||||||
|
pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS);
|
||||||
|
}
|
||||||
|
|
||||||
//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) {
|
||||||
@@ -76,7 +97,7 @@ 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);
|
||||||
|
|
||||||
//Creature/character collisions, O(m*n)
|
//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();
|
||||||
|
|
||||||
@@ -86,7 +107,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)) {
|
||||||
int barrierIndex = barrierMgr.Create(-1);
|
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);
|
||||||
barrierData->SetOrigin({
|
barrierData->SetOrigin({
|
||||||
@@ -119,22 +140,23 @@ void RoomData::RunFrame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//send the creature updates
|
//TODO: check for character collisions with barriers, O(m*n)
|
||||||
for (auto& it : creatureList) {
|
for (auto characterIt : characterList) {
|
||||||
CreaturePacket packet;
|
BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin();
|
||||||
copyCreatureToPacket(&packet, it.second, it.first);
|
|
||||||
packet.type = SerialPacketType::CREATURE_UPDATE;
|
|
||||||
packet.roomIndex = roomIndex;
|
|
||||||
pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
//send the barrier updates
|
for (auto barrierIt : *barrierMgr.GetContainer()) {
|
||||||
for (auto& it : barrierList) {
|
BoundingBox barrierBox = barrierIt.second.GetBounds() + barrierIt.second.GetOrigin();
|
||||||
BarrierPacket packet;
|
|
||||||
copyBarrierToPacket(&packet, it.second, it.first);
|
if (characterBox.CheckOverlap(barrierBox)) {
|
||||||
packet.type = SerialPacketType::BARRIER_UPDATE;
|
//TODO: (0) actually move the character to an instance
|
||||||
packet.roomIndex = roomIndex;
|
CombatInstance* instance = combatInstanceMgr.Find(barrierIt.second.GetInstanceIndex());
|
||||||
pumpPacketProximity(reinterpret_cast<SerialPacket*>(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS);
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
//only confirm one barrier per character
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
int roomIndex = 0;
|
int roomIndex = 0;
|
||||||
BarrierManager barrierMgr;
|
BarrierManager barrierMgr;
|
||||||
std::list<CharacterData*> characterList;
|
std::list<CharacterData*> characterList;
|
||||||
CombatInstanceManager CombatInstanceMgr;
|
CombatInstanceManager combatInstanceMgr;
|
||||||
CreatureManager creatureMgr;
|
CreatureManager creatureMgr;
|
||||||
RegionPagerLua pager;
|
RegionPagerLua pager;
|
||||||
TriggerManager triggerMgr;
|
TriggerManager triggerMgr;
|
||||||
|
|||||||
Reference in New Issue
Block a user