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");
|
||||
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) {
|
||||
|
||||
@@ -143,7 +143,6 @@ private:
|
||||
TTF_Font* font = nullptr;
|
||||
Button disconnectButton;
|
||||
Button shutdownButton;
|
||||
Button inventoryButton;
|
||||
FrameRate fps;
|
||||
TextLine fpsTextLine;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+40
-18
@@ -31,7 +31,7 @@
|
||||
#include <stack>
|
||||
#include <stdexcept>
|
||||
|
||||
//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<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
|
||||
std::stack<Entity*> 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<SerialPacket*>(&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<SerialPacket*>(&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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
int roomIndex = 0;
|
||||
BarrierManager barrierMgr;
|
||||
std::list<CharacterData*> characterList;
|
||||
CombatInstanceManager CombatInstanceMgr;
|
||||
CombatInstanceManager combatInstanceMgr;
|
||||
CreatureManager creatureMgr;
|
||||
RegionPagerLua pager;
|
||||
TriggerManager triggerMgr;
|
||||
|
||||
Reference in New Issue
Block a user