120 lines
3.1 KiB
C++
120 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "render/Renderer.h"
|
|
#include "Environment.h"
|
|
#include "render/TextureManager.h"
|
|
#include "items/GameObjectLoader.h"
|
|
#include "items/InteractiveObject.h"
|
|
#include "navigation/PathFinder.h"
|
|
#include "render/ShadowMap.h"
|
|
|
|
#include "ScriptEngine.h"
|
|
#include "dialogue/DialogueSystem.h"
|
|
namespace ZL
|
|
{
|
|
|
|
class Location
|
|
{
|
|
public:
|
|
Location(Renderer& iRenderer, Inventory& iInventory, const std::string& locId = "default");
|
|
|
|
|
|
std::shared_ptr<Texture> roomTexture;
|
|
VertexRenderStruct roomMesh;
|
|
|
|
std::unordered_map<std::string, LoadedGameObject> gameObjects;
|
|
|
|
std::vector<InteractiveObject> interactiveObjects;
|
|
|
|
|
|
std::unique_ptr<Character> player;
|
|
std::unique_ptr<Character> girlfriend;
|
|
|
|
std::vector<std::unique_ptr<Character>> npcs;
|
|
|
|
float cameraAzimuth = 0.0f;
|
|
float cameraInclination = M_PI * 30.f / 180.f;
|
|
|
|
PathFinder navigation;
|
|
|
|
std::unique_ptr<ShadowMap> shadowMap;
|
|
Eigen::Matrix4f cameraViewMatrix = Eigen::Matrix4f::Identity();
|
|
InteractiveObject* targetInteractiveObject = nullptr;
|
|
|
|
|
|
std::shared_ptr<Texture> carTexture;
|
|
VertexRenderStruct carMesh;
|
|
std::shared_ptr<Texture> carWheelTexture;
|
|
VertexRenderStruct carWheelMesh;
|
|
Vector3f carPosition = Eigen::Vector3f(0.f, 0.f, 0.f);
|
|
float carRotation = 0.f;
|
|
|
|
float carVelocity = 0.f;
|
|
float carAcceleration = 20.0f;
|
|
float carFriction = 6.0f;
|
|
float carMaxSpeed = 20.0f;
|
|
float carMaxReverseSpeed = 8.0f;
|
|
float carTurnRate = 1.8f;
|
|
|
|
float carSteeringAngle = 0.f;
|
|
float carMaxSteerAngle = 0.6f;
|
|
|
|
bool keyForward = false;
|
|
bool keyBackward = false;
|
|
bool keyLeft = false;
|
|
bool keyRight = false;
|
|
|
|
bool inCar = false;
|
|
|
|
|
|
ScriptEngine scriptEngine;
|
|
Dialogue::DialogueSystem dialogueSystem;
|
|
|
|
//#ifdef SHOW_PATH
|
|
std::vector<VertexRenderStruct> debugNavMeshes;
|
|
void buildDebugNavMeshes();
|
|
void drawDebugNavigation();
|
|
//#endif
|
|
bool rightMouseDown = false;
|
|
int lastMouseX = 0;
|
|
int lastMouseY = 0;
|
|
|
|
|
|
void setup();
|
|
void setupNavigation();
|
|
InteractiveObject* raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir);
|
|
Character* raycastNpcs(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir, float maxDistance = 100.0f);
|
|
|
|
void drawGame();
|
|
void drawShadowDepthPass();
|
|
void drawGameWithShadows();
|
|
|
|
bool setNavigationAreaAvailable(const std::string& areaName, bool available);
|
|
|
|
void update(int64_t deltaMs);
|
|
|
|
void handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
|
void handleUp(int64_t fingerId, int mx, int my);
|
|
void handleMotion(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
|
void handleKeyDown(int sdlKey);
|
|
void handleKeyUp(int sdlKey);
|
|
|
|
bool requestDialogueStart(const std::string& dialogueId);
|
|
void setDialogueFlag(const std::string& flag, int value);
|
|
int getDialogueFlag(const std::string& flag) const;
|
|
|
|
void cleanup();
|
|
void unload();
|
|
|
|
protected:
|
|
Renderer& renderer;
|
|
Inventory& inventory;
|
|
|
|
private:
|
|
std::string locationId;
|
|
std::string roofObjectKey;
|
|
bool roofVisible = true;
|
|
std::vector<Eigen::AlignedBox<float, 2>> roofHideZones;
|
|
};
|
|
|
|
} // namespace ZL
|