space-game001/src/Game.h
2026-04-17 14:23:56 +06:00

88 lines
1.9 KiB
C++

#pragma once
#include "Character.h"
#include "BoneAnimatedModel.h"
#include "render/Renderer.h"
#include "Environment.h"
#include "render/TextureManager.h"
#include "SparkEmitter.h"
#include "UiManager.h"
#include "utils/TaskManager.h"
#include "items/GameObjectLoader.h"
#include "items/Item.h"
#include "items/InteractiveObject.h"
#include <queue>
#include <vector>
#include <string>
#include <memory>
#include <cstdint>
#include <render/TextRenderer.h>
#include "MenuManager.h"
#include <unordered_map>
#include <unordered_set>
#include "Location.h"
#include "AudioPlayerAsync.h"
namespace ZL {
class Game {
public:
Game();
~Game();
void setup();
void setupPart2();
void update();
void render();
bool shouldExit() const { return Environment::exitGameLoop; }
Renderer renderer;
TaskManager taskManager;
MainThreadHandler mainThreadHandler;
std::shared_ptr<Texture> loadingTexture;
VertexRenderStruct loadingMesh;
bool loadingCompleted = false;
std::shared_ptr<Location> currentLocation;
Inventory inventory;
InteractiveObject* pickedUpObject = nullptr;
bool inventoryOpen = false;
MenuManager menuManager;
private:
bool rightMouseDown = false;
int lastMouseX = 0;
int lastMouseY = 0;
std::unique_ptr<AudioPlayerAsync> audioPlayer;
int64_t getSyncTimeMs();
void processTickCount();
void drawScene();
void drawUI();
void drawLoading();
void handleDown(int64_t fingerId, int mx, int my);
void handleUp(int64_t fingerId, int mx, int my);
void handleMotion(int64_t fingerId, int mx, int my);
#ifdef EMSCRIPTEN
static Game* s_instance;
static void onResourcesZipLoaded(const char* filename);
static void onResourcesZipError(const char* filename);
#endif
int64_t newTickCount;
int64_t lastTickCount;
static const size_t CONST_TIMER_INTERVAL = 10;
static const size_t CONST_MAX_TIME_INTERVAL = 1000;
};
} // namespace ZL