diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-12 17:09:16 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-12 17:09:16 +0200 |
commit | 45de7d0537d2caec7d0a7ede48e2b72301bc9da9 (patch) | |
tree | af17dd093da09dc77a3a07a3d4835a1b5e5b85f6 /src/GameState.cpp | |
parent | 2017-08-07 (diff) | |
download | AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.gz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.bz2 AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.lz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.xz AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.zst AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.zip |
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r-- | src/GameState.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 52b5f0f..18ea722 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -1,5 +1,6 @@ #include "GameState.hpp" #include "Event.hpp" +#include <iomanip> GameState::GameState(NetworkClient *networkClient) : nc(networkClient) { Front = glm::vec3(0.0f, 0.0f, -1.0f); @@ -51,6 +52,8 @@ void GameState::Update(float deltaTime) { vel += resistForce; g_PlayerVelocityX = vel.x; g_PlayerVelocityZ = vel.z; + + world.UpdatePhysics(deltaTime); } } @@ -60,8 +63,19 @@ void GameState::UpdatePacket() auto ptr = nc->ReceivePacket(); if (ptr) { switch ((PacketNamePlayCB)ptr->GetPacketId()) { - case SpawnObject: - break; + case SpawnObject: { + auto packet = std::static_pointer_cast<PacketSpawnObject>(ptr); + Entity entity; + entity.entityId = packet->EntityId; + entity.pitch = packet->Pitch; + entity.pos = VectorF(packet->X, packet->Y, packet->Z); + entity.uuid = packet->ObjectUuid; + entity.vel = Entity::DecodeVelocity(packet->VelocityX, packet->VelocityY, packet->VelocityZ); + entity.yaw = packet->Yaw; + if (entity.vel != VectorF()) + world.entities.push_back(entity); + break; + } case SpawnExperienceOrb: break; case SpawnGlobalEntity: @@ -160,7 +174,7 @@ void GameState::UpdatePacket() break; case EntityLook: break; - case Entity: + case EntityCB: break; case VehicleMove: break; @@ -282,8 +296,7 @@ void GameState::UpdatePacket() case SpawnPosition: { auto packet = std::static_pointer_cast<PacketSpawnPosition>(ptr); g_SpawnPosition = packet->Location; - LOG(INFO) << "Spawn position is " << g_SpawnPosition.GetX() << "," << g_SpawnPosition.GetY() << "," - << g_SpawnPosition.GetZ(); + LOG(INFO) << "Spawn position is " << g_SpawnPosition.x << " " << g_SpawnPosition.y << " " << g_SpawnPosition.z; break; } case TimeUpdate: |