summaryrefslogtreecommitdiffstats
path: root/src/Game.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-05-18 15:12:56 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2019-05-18 15:16:09 +0200
commit8c5320a94b4c91f2801c05766f6a1747de42a2e5 (patch)
tree549f3f5978ab9edd160325df52725cefe6366268 /src/Game.cpp
parentIntegrated Optick profiler (diff)
downloadAltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar.gz
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar.bz2
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar.lz
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar.xz
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.tar.zst
AltCraft-8c5320a94b4c91f2801c05766f6a1747de42a2e5.zip
Diffstat (limited to '')
-rw-r--r--src/Game.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Game.cpp b/src/Game.cpp
index d67072e..c69ff5d 100644
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -7,6 +7,7 @@
#include "Render.hpp"
#include "GameState.hpp"
#include "NetworkClient.hpp"
+#include "Plugin.hpp"
bool isRunning = true;
bool isMoving[5] = { 0,0,0,0,0 };
@@ -75,6 +76,12 @@ void InitEvents() {
listener.RegisterHandler("SendChatMessage", [](const Event& eventData) {
auto message = eventData.get<std::string>();
+ if (message[0] == '!' && message[1] != '!') {
+ PluginSystem::Execute(message.substr(1));
+ return;
+ }
+ if (message[0] == '!')
+ message = message.substr(1);
auto packet = std::static_pointer_cast<Packet>(std::make_shared<PacketChatMessageSB>(message));
PUSH_EVENT("SendPacket",packet);
});
@@ -182,8 +189,9 @@ void RunGame() {
SetState(State::MainMenu);
while (isRunning) {
- OPTICK_FRAME("MainThread");
+ OPTICK_FRAME("MainThread");
listener.HandleAllEvents();
+ PluginSystem::CallOnTick(timer->GetRealDeltaS());
if (gs) {
if (GetState() == State::Playing) {
if (isMoving[GameState::FORWARD])
@@ -196,8 +204,7 @@ void RunGame() {
gs->HandleMovement(GameState::RIGHT, timer->GetRealDeltaS());
if (isMoving[GameState::JUMP])
gs->HandleMovement(GameState::JUMP, timer->GetRealDeltaS());
- }
-
+ }
gs->Update(timer->GetRealDeltaS());
}
render->Update();