diff --git a/src/Core/Crawl/iworld.cpp b/src/Core/Crawl/iworld.cpp index 61df549..f82c12f 100644 --- a/src/Core/Crawl/iworld.cpp +++ b/src/Core/Crawl/iworld.cpp @@ -19,6 +19,7 @@ #include "thread" #include "chrono" #include "diff.h" +#include "eventserver.h" namespace CRAWL { @@ -26,10 +27,13 @@ namespace CRAWL { IWorld::IWorld() { qRegisterMetaType("WorldRule::const_iterator"); connect(this, &IWorld::sigWorldChanged, this, &IWorld::worldChanged, Qt::QueuedConnection); + + _eventServer = new EventServer; } IWorld::~IWorld() { reset(); + delete _eventServer; } void IWorld::init() {prepare();} @@ -50,17 +54,14 @@ void IWorld::render(unsigned int tbfMsec) { for (auto i = _items.begin(); i != _items.end(); ++i) { (*i)->render(tbfMsec); - // intersects event. - if ((*i)->intersects(*_player)) { - _player->onIntersects((*i)); - } + _eventServer->process(*i); } _ItemsMutex.unlock(); updateWorld(); - int waitTime = 1000 / _targetFps - tbfMsec; + int waitTime = 1000 / targetFps() - tbfMsec; if (waitTime > 0) std::this_thread::sleep_for(std::chrono::milliseconds(waitTime)); } diff --git a/src/Core/Crawl/iworld.h b/src/Core/Crawl/iworld.h index 6f8a433..d06fcb7 100644 --- a/src/Core/Crawl/iworld.h +++ b/src/Core/Crawl/iworld.h @@ -32,6 +32,7 @@ class GroundClaster; class IControl; class IAI; class IWorldLight; +class EventServer; /** * @brief WorldObjects This is map list of the avalable objects and its count on a lvl-long point. @@ -482,6 +483,8 @@ private: void removeAnyItemFromGroup(const QString &group, QList* removedObjectsList = nullptr); + EventServer * _eventServer = nullptr; + QHash _items; QMultiHash _itemsGroup; QMultiHash _lastItemsGroup; diff --git a/src/Core/CrawlModule/GraphicItem.qml b/src/Core/CrawlModule/GraphicItem.qml index af312be..6ff4224 100644 --- a/src/Core/CrawlModule/GraphicItem.qml +++ b/src/Core/CrawlModule/GraphicItem.qml @@ -66,6 +66,9 @@ Model { ] rotation: (model)? model.rotation: Qt.quaternion(0, 0, 0, 0) + + + scale: (model)? model.size: Qt.vector3d(0, 0, 0); source: (model)? model.mash: "#Cube"; position: (model) ? model.position: Qt.vector3d(0,0,0); diff --git a/src/Core/Extensions/basemotion.h b/src/Core/Extensions/basemotion.h index 2752458..69da274 100644 --- a/src/Core/Extensions/basemotion.h +++ b/src/Core/Extensions/basemotion.h @@ -22,6 +22,7 @@ class GuiObject; * For Create your own motion alghoritm you need to override two methods: * * renderPosition * * renderRotation + * */ class CRAWL_EXPORT BaseMotion : public virtual IRender { diff --git a/src/Core/private/eventserver.cpp b/src/Core/private/eventserver.cpp new file mode 100644 index 0000000..c4e822b --- /dev/null +++ b/src/Core/private/eventserver.cpp @@ -0,0 +1,27 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "eventserver.h" + +#include + +namespace CRAWL { + +EventServer::EventServer() { + +} + +void EventServer::process(IWorldItem *item) { + // intersects event. + + + +// if ((item)->intersects(*_player)) { +// _player->onIntersects((*i)); +// } +} +} diff --git a/src/Core/private/eventserver.h b/src/Core/private/eventserver.h new file mode 100644 index 0000000..272285b --- /dev/null +++ b/src/Core/private/eventserver.h @@ -0,0 +1,33 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the GPLv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + + +#ifndef EVENTSERVER_H +#define EVENTSERVER_H + +namespace CRAWL { + +class IWorldItem; + +/** + * @brief The EventServer class process all game events. + */ +class EventServer +{ +public: + EventServer(); + + /** + * @brief process This method process al events of an @a item object + * @param item This is processed object. + */ + void process(IWorldItem* item); +}; + +} + +#endif // EVENTSERVER_H