summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-18 17:13:01 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-18 17:13:01 +0200
commita2fe2786682e626dae25db2d375280c83b615796 (patch)
tree34bc8295ad75b967519959e6300aada5531e2345 /src/GameState.cpp
parent2017-08-17 (diff)
downloadAltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.gz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.bz2
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.lz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.xz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.zst
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.zip
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r--src/GameState.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp
index 025eeda..77b6394 100644
--- a/src/GameState.cpp
+++ b/src/GameState.cpp
@@ -73,7 +73,7 @@ void GameState::UpdatePacket()
entity.yaw = packet->Yaw / 256.0;
entity.pitch = packet->Pitch / 256.0;
entity.renderColor = glm::vec3(0,1,0);
- world.entities.push_back(entity);
+ world.AddEntity(entity);
EventAgregator::PushEvent(EventType::EntityChanged, EntityChangedData{ entity.entityId });
break;
}
@@ -91,7 +91,7 @@ void GameState::UpdatePacket()
entity.yaw = packet->Yaw / 256.0;
entity.pitch = packet->Pitch / 256.0;
entity.renderColor = glm::vec3(0,0,1);
- world.entities.push_back(entity);
+ world.AddEntity(entity);
EventAgregator::PushEvent(EventType::EntityChanged, EntityChangedData{ entity.entityId });
break;
}
@@ -108,7 +108,7 @@ void GameState::UpdatePacket()
entity.renderColor = glm::vec3(1, 0, 0);
entity.height = 1.8;
entity.width = 0.6;
- world.entities.push_back(entity);
+ world.AddEntity(entity);
EventAgregator::PushEvent(EventType::EntityChanged, EntityChangedData{ entity.entityId });
break;
}
@@ -122,8 +122,11 @@ void GameState::UpdatePacket()
break;
case BlockAction:
break;
- case BlockChange:
+ case BlockChange: {
+ auto packet = std::static_pointer_cast<PacketBlockChange>(ptr);
+ world.ParseChunkData(packet);
break;
+ }
case BossBar:
break;
case ServerDifficulty:
@@ -132,8 +135,11 @@ void GameState::UpdatePacket()
break;
case ChatMessageCB:
break;
- case MultiBlockChange:
+ case MultiBlockChange: {
+ auto packet = std::static_pointer_cast<PacketMultiBlockChange>(ptr);
+ world.ParseChunkData(packet);
break;
+ }
case ConfirmTransactionCB:
break;
case CloseWindowCB:
@@ -267,7 +273,7 @@ void GameState::UpdatePacket()
g_PlayerZ = packet->Z;
}
- EventAgregator::PushEvent(EventType::PlayerPosChanged, PlayerPosChangedData{ Vector(g_PlayerX,g_PlayerY,g_PlayerZ) });
+ EventAgregator::PushEvent(EventType::PlayerPosChanged, PlayerPosChangedData{ VectorF(g_PlayerX,g_PlayerY,g_PlayerZ) });
LOG(INFO) << "PlayerPos is " << g_PlayerX << ", " << g_PlayerY << ", " << g_PlayerZ << "\t\tAngle: "
<< g_PlayerYaw << "," << g_PlayerPitch;
@@ -291,12 +297,8 @@ void GameState::UpdatePacket()
break;
case DestroyEntities: {
auto packet = std::static_pointer_cast<PacketDestroyEntities>(ptr);
- for (auto& entityId : packet->EntityIds) {
- auto it = world.entities.begin();
- while (it != world.entities.end() && it->entityId != entityId)
- ++it;
- if (it != world.entities.end())
- world.entities.erase(it);
+ for (unsigned int entityId : packet->EntityIds) {
+ world.DeleteEntity(entityId);
}
break;
}