summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-07-04 14:47:44 +0200
committerGitHub <noreply@github.com>2021-07-04 14:47:44 +0200
commit8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a (patch)
tree1e9510a1c2ff7f6c0eaaba211c38e0a855b36ca9 /src/GameState.cpp
parentMerge pull request #64 from LaG1924/ftr/render-optimization (diff)
parentAdded screenshot-mode (diff)
downloadAltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.gz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.bz2
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.lz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.xz
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.tar.zst
AltCraft-8a4075c58b4a078cdbbe8b394eb5ae761fdaff6a.zip
Diffstat (limited to '')
-rw-r--r--src/GameState.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp
index be408dd..89743e4 100644
--- a/src/GameState.cpp
+++ b/src/GameState.cpp
@@ -6,6 +6,8 @@
#include "Event.hpp"
#include "Packet.hpp"
+#include "Game.hpp"
+#include "Plugin.hpp"
void GameState::Update(double deltaTime) {
OPTICK_EVENT();
@@ -167,7 +169,7 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) {
case ChatMessageCB: {
auto packet = std::static_pointer_cast<PacketChatMessageCB>(ptr);
LOG(INFO) << "Message (" << int(packet->Position) << "): " << packet->JsonData.ToPlainText();
- PUSH_EVENT("ChatMessageReceived", std::make_tuple(packet->JsonData, packet->Position));
+ PluginSystem::CallOnChatMessage(packet->JsonData, packet->Position);
break;
}
@@ -383,7 +385,6 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) {
auto packetResponse = std::make_shared<PacketTeleportConfirm>(packet->TeleportId);
PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetResponse));
-
break;
}
@@ -418,6 +419,9 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) {
gameStatus.dimension = packet->Dimension;
gameStatus.difficulty = packet->Difficulty;
gameStatus.levelType = packet->LevelType;
+ SetState(State::Loading);
+ gameStatus.isGameStarted = false;
+ receivedEnoughChunks = false;
break;
}
case EntityHeadLook:
@@ -453,9 +457,8 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) {
auto packet = std::static_pointer_cast<PacketUpdateHealth>(ptr);
playerStatus.health = packet->Health;
if (playerStatus.health <= 0) {
- LOG(INFO) << "Player is dead. Respawning...";
- auto packetPerformRespawn = std::make_shared<PacketClientStatus>(0);
- PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetPerformRespawn));
+ LOG(INFO) << "Player is dead. Need respawn...";
+ SetState(State::NeedRespawn);
}
break;
}
@@ -678,4 +681,9 @@ void GameState::PlaceBlock() {
auto packet = std::static_pointer_cast<Packet>(packetPlace);
PUSH_EVENT("SendPacket", packet);
-} \ No newline at end of file
+}
+
+void GameState::PerformRespawn() {
+ auto packetPerformRespawn = std::make_shared<PacketClientStatus>(0);
+ PUSH_EVENT("SendPacket", std::static_pointer_cast<Packet>(packetPerformRespawn));
+}