diff --git a/client/scenes/world.cpp b/client/scenes/world.cpp index 2357614..b967d94 100644 --- a/client/scenes/world.cpp +++ b/client/scenes/world.cpp @@ -77,16 +77,12 @@ World::World(int* const argClientIndex, int* const argAccountIndex): disconnectButton.SetText(GetRenderer(), font, WHITE, "Disconnect"); shutdownButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture()); shutdownButton.SetText(GetRenderer(), font, WHITE, "Shutdown"); - inventoryButton.SetBackgroundTexture(GetRenderer(), buttonImage.GetTexture()); - inventoryButton.SetText(GetRenderer(), font, WHITE, "Inventory"); //set the button positions disconnectButton.SetX(50); disconnectButton.SetY(50); shutdownButton.SetX(50); shutdownButton.SetY(70); - inventoryButton.SetX(50); - inventoryButton.SetY(90); //load the tilesheet //TODO: (2) Tile size and tile sheet should be loaded elsewhere @@ -270,7 +266,6 @@ void World::RenderFrame(SDL_Renderer* renderer) { //draw UI disconnectButton.DrawTo(renderer); shutdownButton.DrawTo(renderer); - inventoryButton.DrawTo(renderer); //FPS fpsTextLine.DrawTo(renderer); @@ -295,13 +290,11 @@ void World::QuitEvent() { void World::MouseMotion(SDL_MouseMotionEvent const& event) { disconnectButton.MouseMotion(event); shutdownButton.MouseMotion(event); - inventoryButton.MouseMotion(event); } void World::MouseButtonDown(SDL_MouseButtonEvent const& event) { disconnectButton.MouseButtonDown(event); shutdownButton.MouseButtonDown(event); - inventoryButton.MouseButtonDown(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) { SendAdminShutdownRequest(); } - if (inventoryButton.MouseButtonUp(event) == Button::State::RELEASED) { - //TODO: show the inventory screen - } } void World::MouseWheel(SDL_MouseWheelEvent const& event) { diff --git a/client/scenes/world.hpp b/client/scenes/world.hpp index 3446a37..99e54c5 100644 --- a/client/scenes/world.hpp +++ b/client/scenes/world.hpp @@ -143,7 +143,6 @@ private: TTF_Font* font = nullptr; Button disconnectButton; Button shutdownButton; - Button inventoryButton; FrameRate fps; TextLine fpsTextLine; diff --git a/server/combat/barrier_data.cpp b/server/combat/barrier_data.cpp index 648d398..838071c 100644 --- a/server/combat/barrier_data.cpp +++ b/server/combat/barrier_data.cpp @@ -39,6 +39,7 @@ BarrierData::~BarrierData() { int BarrierData::Update(lua_State* L) { int ret = 0; + //NOTE: this is here mostly for the "barrier tick" effect if (scriptRef != LUA_NOREF) { //Call the script reference lua_pushinteger(L, scriptRef); diff --git a/server/rooms/room_data.cpp b/server/rooms/room_data.cpp index 3f23bb5..0561349 100644 --- a/server/rooms/room_data.cpp +++ b/server/rooms/room_data.cpp @@ -31,7 +31,7 @@ #include #include -//TODO: (9) character collisions should be preformed client-side +//NOTE: character collisions should be preformed client-side void RoomData::RunFrame() { //get the hook lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef); @@ -67,6 +67,27 @@ void RoomData::RunFrame() { creatureMgr.Update(&creatureList, 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(&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(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS); + } + //build a list of entities for use with the triggers std::stack entityStack; for (auto& it : characterList) { @@ -76,7 +97,7 @@ void RoomData::RunFrame() { //Compare the triggers to the entities, using their real hitboxes triggerMgr.Compare(entityStack); - //Creature/character collisions, O(m*n) + //Creature/character collisions, O(m*n), making the barriers for (auto characterIt : characterList) { BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin(); @@ -86,7 +107,7 @@ void RoomData::RunFrame() { BoundingBox creatureBox = creatureIt.second.GetBounds() + creatureIt.second.GetOrigin(); 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->SetRoomIndex(roomIndex); barrierData->SetOrigin({ @@ -119,22 +140,23 @@ void RoomData::RunFrame() { } } - //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(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS); - } + //TODO: check for character collisions with barriers, O(m*n) + for (auto characterIt : characterList) { + BoundingBox characterBox = characterIt->GetBounds() + characterIt->GetOrigin(); - //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(&packet), roomIndex, it.second->GetOrigin(), INFLUENCE_RADIUS); + for (auto barrierIt : *barrierMgr.GetContainer()) { + BoundingBox barrierBox = barrierIt.second.GetBounds() + barrierIt.second.GetOrigin(); + + if (characterBox.CheckOverlap(barrierBox)) { + //TODO: (0) actually move the character to an instance + CombatInstance* instance = combatInstanceMgr.Find(barrierIt.second.GetInstanceIndex()); + + //... + + //only confirm one barrier per character + break; + } + } } } diff --git a/server/rooms/room_data.hpp b/server/rooms/room_data.hpp index 8cb31c2..ab6dfa4 100644 --- a/server/rooms/room_data.hpp +++ b/server/rooms/room_data.hpp @@ -82,7 +82,7 @@ private: int roomIndex = 0; BarrierManager barrierMgr; std::list characterList; - CombatInstanceManager CombatInstanceMgr; + CombatInstanceManager combatInstanceMgr; CreatureManager creatureMgr; RegionPagerLua pager; TriggerManager triggerMgr;