From 7e554c28b2ebabb24a28514d582305309b86a1f6 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Tue, 21 Jun 2016 13:20:04 +0200 Subject: [PATCH] E Triggers LEVER if hold, only once per second --- Weave/Scene/Boar.cpp | 2 +- Weave/Scene/EventBox.cpp | 21 ++++++++++++--------- Weave/Scene/EventBox.h | 2 +- Weave/Scene/Lever.cpp | 8 +------- Weave/Scene/Lever.h | 1 - 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Weave/Scene/Boar.cpp b/Weave/Scene/Boar.cpp index bc48785..bce2cb2 100644 --- a/Weave/Scene/Boar.cpp +++ b/Weave/Scene/Boar.cpp @@ -31,7 +31,7 @@ void Boar::update(float _deltaT) void Boar::collides(SceneObject * _other, btPersistentManifold * _contactManifold, float _deltaT) { - if (_other->collide_group != COL_MARVIN) + if (_other->collide_group != COL_MARVIN && _other->collide_group != COL_ENEMY) return; if (activated) diff --git a/Weave/Scene/EventBox.cpp b/Weave/Scene/EventBox.cpp index 06b6a0d..f83369b 100644 --- a/Weave/Scene/EventBox.cpp +++ b/Weave/Scene/EventBox.cpp @@ -20,7 +20,7 @@ EventBox::EventBox(const mat4& _modelMat, eventBoxType _EB_TYPE) : eb_type(_EB_TYPE) { collide_group = COL_EVENT; - collide_with = COL_MARVIN; + collide_with = COL_MARVIN ; if (eb_type == EB_LEVER) collide_with = COL_LEVER; @@ -52,13 +52,18 @@ EventBox::~EventBox() void EventBox::update(float _deltaT) { + SceneObject::update(_deltaT); if (activated) { - if (nextFrame) + triggertime += _deltaT; + + if (triggertime >= 1.f) + { activated = false; - else - nextFrame = true; - } + } + + } + } void EventBox::draw(drawTarget _target) const @@ -75,10 +80,7 @@ void EventBox::draw(drawTarget _target) const void EventBox::collides(SceneObject* _other, btPersistentManifold* _contactManifold, float _deltaT) { if (activated) - { - nextFrame = false; return; - } switch (eb_type) { @@ -100,6 +102,7 @@ void EventBox::collides(SceneObject* _other, btPersistentManifold* _contactManif ((Lever*)_other)->trigger(); break; } - + activated = true; + triggertime = 0; } diff --git a/Weave/Scene/EventBox.h b/Weave/Scene/EventBox.h index 814c8a6..78b3bd7 100644 --- a/Weave/Scene/EventBox.h +++ b/Weave/Scene/EventBox.h @@ -25,5 +25,5 @@ protected: eventBoxType eb_type; bool activated = false; - bool nextFrame = true; + float triggertime = 0; }; diff --git a/Weave/Scene/Lever.cpp b/Weave/Scene/Lever.cpp index 8394384..670545f 100644 --- a/Weave/Scene/Lever.cpp +++ b/Weave/Scene/Lever.cpp @@ -1,5 +1,6 @@ #include "Lever.h" #include "Scene.h" +#include "../Message.h" Lever::Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath) : SceneObject(_modelMat, _material, _modelpath, texturepath) { @@ -8,13 +9,6 @@ Lever::Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, st collide_with = COL_EVENT; } -Lever::Lever(const mat4& modelMat, const vec4& material, Model* model, string texturepath) : SceneObject(modelMat, material, model, texturepath) -{ - recipient = nullptr; - collide_group = COL_LEVER; - collide_with = COL_EVENT; -} - Lever::~Lever() { diff --git a/Weave/Scene/Lever.h b/Weave/Scene/Lever.h index 64fd442..f852d6e 100644 --- a/Weave/Scene/Lever.h +++ b/Weave/Scene/Lever.h @@ -10,7 +10,6 @@ class Lever : public SceneObject { public: Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath); - Lever(const mat4& modelMat, const vec4& material, Model* model, string texturepath); ~Lever(); void setup(SceneObject* object); void trigger(); -- 2.47.3