first work action

This commit is contained in:
Andrei Yankovich 2021-08-09 18:30:18 +03:00
parent 109d7c5f25
commit f0162efaab
50 changed files with 33 additions and 168 deletions

View File

@ -167,9 +167,6 @@ public:
} }
} }
protected:
void onIntersects(const IWorldItem *) override {};
private: private:
float lengthToSpeed(float length) const { float lengthToSpeed(float length) const {
return (2 * M_PI * radius()) / length; return (2 * M_PI * radius()) / length;

View File

@ -24,7 +24,4 @@ void DefaultLight::init() {
} }
void DefaultLight::onIntersects(const IWorldItem *) {
}
} }

View File

@ -26,10 +26,6 @@ public:
void render(unsigned int tbfMsec) override; void render(unsigned int tbfMsec) override;
void init() override; void init() override;
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -19,8 +19,7 @@ Fire::Fire(): ParticleEffect(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Fire.q
setLifeSpanVariation(500); setLifeSpanVariation(500);
setColor("#ffaf2c"); setColor("#ffaf2c");
setSize({1, 1, 1}); setposition({0,0,1});
setposition({0,0,10});
setEnabled(true); setEnabled(true);
setParticleDelegate("qrc:/CrawlModule/particles/FireParticel.qml"); setParticleDelegate("qrc:/CrawlModule/particles/FireParticel.qml");

View File

@ -36,6 +36,10 @@ void GuiObject::generateId() {
setGuiId(id++); setGuiId(id++);
} }
void GuiObject::setContainerSize(const QVector3D &newContainerSize) {
_containerSize = newContainerSize;
}
bool GuiObject::visible() const { bool GuiObject::visible() const {
return _visible; return _visible;
} }
@ -132,14 +136,14 @@ QVector3D GuiObject::center() const {
} }
bool GuiObject::intersects(const QVector3D &point) const { bool GuiObject::intersects(const QVector3D &point) const {
auto radius = _size / 2; auto radius = _containerSize / 2;
float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3; float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3;
return center().distanceToPoint(point) < thisMidRadius ; return center().distanceToPoint(point) < thisMidRadius ;
} }
bool GuiObject::intersects(const GuiObject &object) const { bool GuiObject::intersects(const GuiObject &object) const {
auto radius = _size / 2; auto radius = _containerSize / 2;
auto objRadius = object.size() / 2; auto objRadius = object._containerSize / 2;
float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3; float thisMidRadius = (radius.z() + radius.y() + radius.x()) / 3;
float objMidRadius = (objRadius.z() + objRadius.y() + objRadius.x()) / 3; float objMidRadius = (objRadius.z() + objRadius.y() + objRadius.x()) / 3;

View File

@ -157,6 +157,13 @@ public:
int guiId() const; int guiId() const;
void setGuiId(int guiId); void setGuiId(int guiId);
/**
* @brief containerSize This method sets container size of object. Change this propertye for setting correct work the GuiObject::intersects method.
* @param newContainerSize new is new value of the object contaier cube.
* @see GuiObject::intersects
*/
void setContainerSize(const QVector3D &newContainerSize);
signals: signals:
void guiIdChanged(int guiId); void guiIdChanged(int guiId);
void colorChanged(QString color); void colorChanged(QString color);
@ -213,6 +220,7 @@ private:
QVector3D _position; QVector3D _position;
QVector3D _size; QVector3D _size;
QVector3D _containerSize = {1,1,1};
QQuaternion _rotation; QQuaternion _rotation;
QString _mash; QString _mash;
QString _className; QString _className;

View File

@ -86,12 +86,6 @@ public:
protected: protected:
/**
* @brief onIntersects This is intersect event betwin this and subscribet objects.
* @param item This is pointer to the event object.
*/
virtual void onIntersects(const IWorldItem *item) = 0;
/** /**
* @brief getItem This method return item world by id. If object is not exits then return nullptr. * @brief getItem This method return item world by id. If object is not exits then return nullptr.
* @return constant pointer tot the item world. * @return constant pointer tot the item world.

View File

@ -17,6 +17,7 @@ ParticleEffect::ParticleEffect(const QString &name,
QObject *ptr): QObject *ptr):
IWorldItem(name, viewTempalte, ptr) { IWorldItem(name, viewTempalte, ptr) {
setFDecorative(true);
} }
bool ParticleEffect::enabled() const { bool ParticleEffect::enabled() const {

View File

@ -131,6 +131,8 @@ private:
QVector3D* _vectors; QVector3D* _vectors;
float _speed; float _speed;
int _hp = 100;
}; };
} }

View File

@ -13,8 +13,6 @@ namespace CRAWL {
Wint::Wint(): Affector(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Wint.qml") { Wint::Wint(): Affector(AUTO_CLASS_NAME, "qrc:/CrawlModule/particles/Wint.qml") {
} }
void Wint::onIntersects(const IWorldItem *) {}
float Wint::magnitude() const { float Wint::magnitude() const {
return _magnitude; return _magnitude;
} }

View File

@ -66,8 +66,7 @@ signals:
void directionChanged(); void directionChanged();
void magnitudeChanged(); void magnitudeChanged();
protected: private:
void onIntersects(const IWorldItem *item) override;
QVector3D _direction = {1, 0, 0}; QVector3D _direction = {1, 0, 0};
float _magnitude = 10; float _magnitude = 10;

View File

@ -41,7 +41,7 @@ void EventServer::handleAvailableObjectChanges(const Diff &diff) {
for (int added: diff.addedIds) { for (int added: diff.addedIds) {
auto obj = _worldInstance->getItem(added); auto obj = _worldInstance->getItem(added);
if (!obj->isDecorative()) { if (obj->isDecorative()) {
continue; continue;
} }

View File

@ -30,8 +30,5 @@ AbsLvlSnake::AbsLvlSnake(): Snake(AUTO_CLASS_NAME) {
registerItemType<AbsLvlSnakeItem>(); registerItemType<AbsLvlSnakeItem>();
} }
void AbsLvlSnake::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -19,10 +19,6 @@ class AbsLvlSnake : public CRAWL::Snake {
public: public:
AbsLvlSnake(); AbsLvlSnake();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -15,9 +15,4 @@ AbsLvlSnakeItem::AbsLvlSnakeItem():CRAWL::SnakeItem(AUTO_CLASS_NAME) {
setSize({1,1,1}); setSize({1,1,1});
} }
void AbsLvlSnakeItem::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -19,9 +19,6 @@ class AbsLvlSnakeItem: public CRAWL::SnakeItem {
public: public:
AbsLvlSnakeItem(); AbsLvlSnakeItem();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -17,8 +17,5 @@ Baff::Baff() : IWorldItem(AUTO_CLASS_NAME) {
setZ(0); setZ(0);
} }
void Baff::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -14,10 +14,6 @@ namespace AbstractLvl {
class Baff: public CRAWL::IWorldItem { class Baff: public CRAWL::IWorldItem {
public: public:
Baff(); Baff();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -16,8 +16,4 @@ ObstacleBlue::ObstacleBlue() : IWorldItem(AUTO_CLASS_NAME) {
setZ(0); setZ(0);
} }
void ObstacleBlue::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -14,10 +14,6 @@ namespace AbstractLvl {
class ObstacleBlue: public CRAWL::IWorldItem { class ObstacleBlue: public CRAWL::IWorldItem {
public: public:
ObstacleBlue(); ObstacleBlue();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -16,8 +16,4 @@ ObstacleRed::ObstacleRed() : IWorldItem(AUTO_CLASS_NAME) {
setZ(0); setZ(0);
} }
void ObstacleRed::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -15,9 +15,6 @@ class ObstacleRed: public CRAWL::IWorldItem {
public: public:
ObstacleRed(); ObstacleRed();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -14,10 +14,6 @@ Background::Background(): CRAWL::GroundClaster("TestBackground") {
registerItemType<Plate>(); registerItemType<Plate>();
} }
void Background::onIntersects(const IWorldItem *item) {
Q_UNUSED(item)
}
unsigned int Background::itemsCount() const { unsigned int Background::itemsCount() const {
return 3; return 3;
} }

View File

@ -19,13 +19,6 @@ class Background: public CRAWL::GroundClaster
{ {
public: public:
Background(); Background();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// AutoGenerateClaster interface
public:
unsigned int itemsCount() const override; unsigned int itemsCount() const override;
}; };

View File

@ -24,9 +24,16 @@ Box::Box(): IWorldItem("Box") {
setposition({static_cast<float>(rand() % 100) - 50, setposition({static_cast<float>(rand() % 100) - 50,
static_cast<float>(rand() % 100) - 50, static_cast<float>(rand() % 100) - 50,
0 }); 0 });
setFDecorative(false);
setContainerSize({4, 4, 4});
} }
void Box::onIntersects(const IWorldItem *item) { void Box::action(IWorldItem *item) {
Q_UNUSED(item); if (item->className() == getPlayer()->className()) {
respawn();
} }
} }
}

View File

@ -16,10 +16,7 @@ class Box: public CRAWL::IWorldItem {
public: public:
Box(); Box();
void action(IWorldItem *item) override;
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }
#endif // BOX_H #endif // BOX_H

View File

@ -18,10 +18,6 @@ Plate::Plate(): CRAWL::GroundTile("TestPlate")
setZ(0); setZ(0);
} }
void Plate::onIntersects(const IWorldItem *item) {
Q_UNUSED(item)
}
void Plate::render(unsigned int){ void Plate::render(unsigned int){
} }

View File

@ -19,10 +19,6 @@ class Plate: public CRAWL::GroundTile {
public: public:
Plate(); Plate();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// IRender interface // IRender interface
public: public:
void render(unsigned int tbfMsec) override; void render(unsigned int tbfMsec) override;

View File

@ -18,11 +18,7 @@ TestSnake::TestSnake(): Snake("Snake") {
setSize({2,1,1}); setSize({2,1,1});
registerItemType<TestSnakeItem>(); registerItemType<TestSnakeItem>();
setContainerSize({2, 2, 2});
}
void TestSnake::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
} }

View File

@ -19,10 +19,6 @@ class TestSnake : public CRAWL::Snake {
public: public:
TestSnake(); TestSnake();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// AutoGenerateClaster interface // AutoGenerateClaster interface
public: public:

View File

@ -15,8 +15,4 @@ TestSnakeItem::TestSnakeItem():CRAWL::SnakeItem("TestSnakeItem") {
} }
void TestSnakeItem::onIntersects(const IWorldItem *item) {
Q_UNUSED(item);
}
} }

View File

@ -19,10 +19,6 @@ class TestSnakeItem: public CRAWL::SnakeItem
Q_OBJECT Q_OBJECT
public: public:
TestSnakeItem(); TestSnakeItem();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -31,7 +31,7 @@ CRAWL::WorldRule *World::initWorldRules() {
using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>; using Day = CRAWL::Day<CRAWL::Sun, CRAWL::Moon>;
return new CRAWL::WorldRule { return new CRAWL::WorldRule {
{0, {{registerObject<Box>(), 100}, {0, {{registerObject<Box>(), 1000},
{registerObject<CRAWL::Fire>(), 10}, {registerObject<CRAWL::Fire>(), 10},
{registerObject<CRAWL::DynamicWint>(), 1}, {registerObject<CRAWL::DynamicWint>(), 1},

View File

@ -16,8 +16,6 @@ AbsalutePlate::AbsalutePlate(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setColor("#000000"); setColor("#000000");
} }
void AbsalutePlate::onIntersects(const IWorldItem *) {}
void AbsalutePlate::render(unsigned int ) { void AbsalutePlate::render(unsigned int ) {
setposition(getPlayer()->position() + QVector3D{0,0,-100}); setposition(getPlayer()->position() + QVector3D{0,0,-100});
} }

View File

@ -11,10 +11,6 @@ class AbsalutePlate : public CRAWL::IWorldItem
public: public:
AbsalutePlate(); AbsalutePlate();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// IRender interface // IRender interface
public: public:
void render(unsigned int tbfMsec) override; void render(unsigned int tbfMsec) override;

View File

@ -17,8 +17,4 @@ Grees::Grees(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
} }
void Grees::onIntersects(const IWorldItem *) {
}
} }

View File

@ -23,10 +23,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT Grees: public CRAWL::IWorldItem
Q_OBJECT Q_OBJECT
public: public:
Grees(); Grees();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }
#endif // GREES_H #endif // GREES_H

View File

@ -13,10 +13,6 @@ Ground::Ground() : CRAWL::GroundClaster("JungelGroud") {
registerItemType<GroundPlate>(); registerItemType<GroundPlate>();
} }
void Ground::onIntersects(const IWorldItem *) {
}
unsigned int Ground::itemsCount() const { unsigned int Ground::itemsCount() const {
return 3; return 3;
} }

View File

@ -20,13 +20,6 @@ class Ground : public CRAWL::GroundClaster
{ {
public: public:
Ground(); Ground();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
// AutoGenerateClaster interface
public:
unsigned int itemsCount() const override; unsigned int itemsCount() const override;
}; };

View File

@ -21,10 +21,6 @@ GroundPlate::GroundPlate(): CRAWL::GroundTile("JungleGroundTile",
} }
void GroundPlate::onIntersects(const IWorldItem *) {
}
int GroundPlate::tiliesCount() const { int GroundPlate::tiliesCount() const {
return _tiliesCount; return _tiliesCount;
} }

View File

@ -30,9 +30,6 @@ public:
signals: signals:
void tiliesCountChanged(); void tiliesCountChanged();
protected:
void onIntersects(const IWorldItem *item) override;
private: private:
int _tiliesCount = 1; int _tiliesCount = 1;
}; };

View File

@ -15,7 +15,4 @@ LongGress::LongGress(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)})); setRotation(QQuaternion::fromEulerAngles({0,0, static_cast<float>(rand() % 360)}));
} }
void LongGress::onIntersects(const IWorldItem *) {
}
} }

View File

@ -22,9 +22,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT LongGress: public CRAWL::IWorldItem
public: public:
LongGress(); LongGress();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -31,10 +31,6 @@ Snake::Snake(): CRAWL::Snake("JungleSnake") {
{1, 0.5}}); {1, 0.5}});
} }
void Snake::onIntersects(const IWorldItem *) {
}
unsigned int Snake::itemsCount() const { unsigned int Snake::itemsCount() const {
return 50; return 50;
} }

View File

@ -26,7 +26,6 @@ public:
// IWorldItem interface // IWorldItem interface
protected: protected:
void onIntersects(const IWorldItem *) override;
unsigned int itemsCount() const override; unsigned int itemsCount() const override;
}; };

View File

@ -19,8 +19,4 @@ void SnakeItem::init() {
} }
void SnakeItem::onIntersects(const IWorldItem *) {
}
} }

View File

@ -18,10 +18,6 @@ class SnakeItem : public CRAWL::SnakeItem
public: public:
SnakeItem(); SnakeItem();
void init() override; void init() override;
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *item) override;
}; };
} }

View File

@ -31,7 +31,4 @@ Tree::Tree(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
setZ(-static_cast<float>(rand() % 10)); setZ(-static_cast<float>(rand() % 10));
} }
void Tree::onIntersects(const IWorldItem *) {
}
} }

View File

@ -21,10 +21,6 @@ class CRAWL_JUNGLE_LEVEL_EXPORT Tree : public CRAWL::IWorldItem
Q_OBJECT Q_OBJECT
public: public:
Tree(); Tree();
// IWorldItem interface
protected:
void onIntersects(const IWorldItem *) override;
}; };
} }
#endif // TREE_H #endif // TREE_H

View File

@ -19,8 +19,6 @@ public:
TestGroupObject(): CRAWL::IWorldItem(AUTO_CLASS_NAME) { TestGroupObject(): CRAWL::IWorldItem(AUTO_CLASS_NAME) {
} }
protected:
void onIntersects(const IWorldItem *) override {};
// IRender interface // IRender interface
void render(unsigned int tbfMsec) override { void render(unsigned int tbfMsec) override {
@ -40,8 +38,6 @@ public:
TestGroupObjectItem(): CRAWL::ClasterItem(AUTO_CLASS_NAME) { TestGroupObjectItem(): CRAWL::ClasterItem(AUTO_CLASS_NAME) {
} }
protected:
void onIntersects(const IWorldItem *) override {};
}; };
GroupObjectTest::GroupObjectTest() { GroupObjectTest::GroupObjectTest() {