New game works almost as intended, quest system
This commit is contained in:
155
Game.cpp
155
Game.cpp
@@ -17,6 +17,7 @@
|
||||
#include "TerrainModule.h"
|
||||
#include "GUIModuleCommon.h"
|
||||
#include "AppModule.h"
|
||||
#include "GUIModule.h"
|
||||
#include "sound.h"
|
||||
class App;
|
||||
class SkyRenderer : public Ogre::SceneManager::Listener {
|
||||
@@ -470,16 +471,10 @@ public:
|
||||
// TODO: implement rough water level calculation
|
||||
float getWaterLevel(const Ogre::Vector3 &position)
|
||||
{
|
||||
Ogre::Vector3::UNIT_Y;
|
||||
float etime =
|
||||
Ogre::ControllerManager::getSingleton().getElapsedTime();
|
||||
return 0.0f;
|
||||
}
|
||||
void updateWorld(float delta)
|
||||
{
|
||||
#if 0
|
||||
mDynWorld->getBtWorld()->stepSimulation(delta, 3);
|
||||
#endif
|
||||
if (!ECS::get().has<ECS::GUI>())
|
||||
goto end;
|
||||
{
|
||||
@@ -495,13 +490,9 @@ public:
|
||||
}
|
||||
end:
|
||||
ECS::update(delta);
|
||||
|
||||
#if 0
|
||||
if (ECS::get<ECS::EngineData>().enableDbgDraw)
|
||||
mDbgDraw->update();
|
||||
#endif
|
||||
}
|
||||
class InputListenerChainFlexible : public OgreBites::InputListener {
|
||||
#if 0
|
||||
class InputListenerChainFlexible : public OgreBites::InputListener {
|
||||
protected:
|
||||
std::vector<OgreBites::InputListener *> mListenerChain;
|
||||
|
||||
@@ -604,6 +595,7 @@ end:
|
||||
bool
|
||||
mousePressed(const OgreBites::MouseButtonEvent &evt) override
|
||||
{
|
||||
std::cout << mListenerChain.size() << std::endl;
|
||||
for (auto listner : mListenerChain) {
|
||||
if (listner->mousePressed(evt))
|
||||
return true;
|
||||
@@ -628,6 +620,7 @@ end:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
flecs::entity input_update;
|
||||
flecs::entity find_wait_gui;
|
||||
void setupInput()
|
||||
@@ -652,108 +645,44 @@ end:
|
||||
"Skybox/Dynamic", "General");
|
||||
OgreAssert(m, "Sky box material not found.");
|
||||
m->load();
|
||||
ECS::get().component<ECS::RenderWindow>().add(flecs::Singleton);
|
||||
ECS::get().set<ECS::RenderWindow>(
|
||||
{ getRenderWindow(), getDisplayDPI() });
|
||||
ECS::setupExteriorScene(mScnMgr,
|
||||
/*mDynWorld.get(), */ mCameraNode,
|
||||
mCamera, getRenderWindow());
|
||||
ECS::get().set<ECS::RenderWindow>(
|
||||
{ getRenderWindow(), getDisplayDPI() });
|
||||
ECS::get()
|
||||
.observer<ECS::GUI>("UpdateGrab")
|
||||
.event(flecs::OnSet)
|
||||
.each([this](ECS::GUI &gui) {
|
||||
if (gui.grabChanged)
|
||||
setWindowGrab(gui.grab);
|
||||
std::cout << "grab: " << gui.grab << "\n";
|
||||
std::cout << "GUI enabled: " << gui.enabled
|
||||
<< "\n";
|
||||
});
|
||||
ECS::get()
|
||||
.observer<ECS::App>("UpdateInputListener")
|
||||
.event(flecs::OnSet)
|
||||
.each([this](ECS::App &app) {
|
||||
if (app.mInput)
|
||||
removeInputListener(app.mInput);
|
||||
delete app.mInput;
|
||||
app.mInput =
|
||||
OGRE_NEW OgreBites::InputListenerChain(
|
||||
app.listeners);
|
||||
addInputListener(app.mInput);
|
||||
});
|
||||
#if 0
|
||||
ECS::get()
|
||||
.observer<ECS::GUI, ECS::App>("SetInputListener2")
|
||||
.event(flecs::OnSet)
|
||||
.each([this](ECS::GUI &gui, ECS::App &app) {
|
||||
if (gui.mGuiInpitListener &&
|
||||
app.listeners.size() == 1) {
|
||||
app.listeners.clear();
|
||||
app.listeners.push_back(
|
||||
gui.mGuiInpitListener);
|
||||
app.listeners.push_back(&mKbd);
|
||||
ECS::modified<ECS::App>();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
#if 0
|
||||
input_update =
|
||||
ECS::get()
|
||||
.system<ECS::GUI, ECS::App>("SetInputListener")
|
||||
.kind(flecs::OnUpdate)
|
||||
.each([this](ECS::GUI &gui, ECS::App &app) {
|
||||
if (app.listeners.size() < 2 &&
|
||||
gui.mGuiInpitListener) {
|
||||
OgreBites::InputListener *guiListener =
|
||||
gui.mGuiInpitListener;
|
||||
if (guiListener) {
|
||||
app.listeners.clear();
|
||||
app.listeners.push_back(
|
||||
guiListener);
|
||||
app.listeners.push_back(
|
||||
&mKbd);
|
||||
std::cout
|
||||
<< "input update complete\n";
|
||||
gui.mGuiInpitListener =
|
||||
guiListener;
|
||||
if (app.mInput)
|
||||
removeInputListener(
|
||||
app.mInput);
|
||||
delete app.mInput;
|
||||
app.mInput = new OgreBites::
|
||||
InputListenerChain(
|
||||
app.listeners);
|
||||
addInputListener(
|
||||
app.mInput);
|
||||
std::cout
|
||||
<< "update listeners: "
|
||||
<< app.listeners
|
||||
.size()
|
||||
<< "\n";
|
||||
if (app.listeners
|
||||
.size() ==
|
||||
2)
|
||||
OgreAssert(
|
||||
app.listeners.size() ==
|
||||
2,
|
||||
"");
|
||||
input_update.disable();
|
||||
OgreAssert(false, "");
|
||||
} else {
|
||||
app.listeners.clear();
|
||||
app.listeners.push_back(
|
||||
&mKbd);
|
||||
}
|
||||
} else
|
||||
input_update.disable();
|
||||
std::cout << "input update "
|
||||
<< app.listeners.size()
|
||||
<< "\n";
|
||||
});
|
||||
#endif
|
||||
ECS::get().set<ECS::App>(
|
||||
{ initialiseImGui(),
|
||||
nullptr,
|
||||
{ getImGuiInputListener(), &mKbd } });
|
||||
Sound::setup();
|
||||
ECS::get()
|
||||
.observer<ECS::App>("UpdateInputListener")
|
||||
.event(flecs::OnSet)
|
||||
.each([this](ECS::App &app) {
|
||||
if (app.mInput)
|
||||
removeInputListener(app.mInput);
|
||||
delete app.mInput;
|
||||
app.mInput =
|
||||
OGRE_NEW OgreBites::InputListenerChain(
|
||||
app.listeners);
|
||||
addInputListener(app.mInput);
|
||||
});
|
||||
ECS::get().set<ECS::App>(
|
||||
{ initialiseImGui(),
|
||||
nullptr,
|
||||
{ getImGuiInputListener(), &mKbd } });
|
||||
/* FIXME: this is bad */
|
||||
ECS::GUIModule::configure();
|
||||
ECS::get()
|
||||
.observer<ECS::GUI>("UpdateGrab")
|
||||
.event(flecs::OnSet)
|
||||
.each([this](ECS::GUI &gui) {
|
||||
if (gui.grabChanged)
|
||||
setWindowGrab(gui.grab);
|
||||
std::cout << "grab: " << gui.grab << "\n";
|
||||
std::cout << "GUI enabled: " << gui.enabled
|
||||
<< "\n";
|
||||
});
|
||||
ECS::get_mut<ECS::GUI>().grab = false;
|
||||
ECS::get_mut<ECS::GUI>().grabChanged = true;
|
||||
ECS::modified<ECS::GUI>();
|
||||
Sound::setup();
|
||||
Sound::ding();
|
||||
}
|
||||
void create_entity_node(const Ogre::String &name, int key)
|
||||
@@ -786,10 +715,6 @@ end:
|
||||
{
|
||||
return mCamera;
|
||||
}
|
||||
flecs::entity getPlayer() const
|
||||
{
|
||||
return ECS::player;
|
||||
}
|
||||
void enableDbgDraw(bool enable)
|
||||
{
|
||||
ECS::get_mut<ECS::EngineData>().enableDbgDraw = enable;
|
||||
|
||||
Reference in New Issue
Block a user