From d82553d6a762e28145eda48f7b16d433359e0449 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 13 Sep 2014 16:33:32 +0200 Subject: [PATCH] Fixes to element interaction. It now works with multiple entities doing interaction, and the correct update list is used, which should save a bit more CPU. --- Aquaria/Avatar.cpp | 2 +- Aquaria/Element.cpp | 5 +---- Aquaria/Game.cpp | 1 + Aquaria/ScriptInterface.cpp | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 43d334c..6642d42 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -7127,7 +7127,7 @@ void Avatar::onUpdate(float dt) if(!core->particlesPaused && elementEffectMult > 0) { - ElementUpdateList& elems = dsq->game->elementUpdateList; + ElementUpdateList& elems = dsq->game->elementInteractionList; for (ElementUpdateList::iterator it = elems.begin(); it != elems.end(); ++it) { (*it)->doInteraction(this, elementEffectMult, 16); diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index 9c8cc51..c18bac7 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -84,12 +84,8 @@ void Element::doInteraction(Entity *ent, float mult, float touchWidth) eff->hitPerc = hitPerc; eff->touchVel = ent->vel; eff->effectMult = mult; - return; } } - //eff->touchVel = Vector(0, 0); - //eff->hitPerc = 0; - eff->touching = false; } void Element::updateEffects(float dt) @@ -110,6 +106,7 @@ void Element::updateEffects(float dt) if (eff->touching) { + eff->touching = false; float ramp = eff->touchVel.getLength2D()/800.0f; if (ramp < 0) ramp = 0; if (ramp > 1) ramp = 1; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index f9e1c85..00e92e3 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -10824,6 +10824,7 @@ void Game::removeState() core->particlesPaused = false; elementUpdateList.clear(); + elementInteractionList.clear(); dsq->setCursor(CURSOR_NORMAL); dsq->darkLayer.toggle(0); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 6eaa708..4d6a5fa 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -5525,7 +5525,7 @@ luaFunc(entity_doElementInteraction) if (!touchWidth) touchWidth = 16; - ElementUpdateList& elems = dsq->game->elementUpdateList; + ElementUpdateList& elems = dsq->game->elementInteractionList; for (ElementUpdateList::iterator it = elems.begin(); it != elems.end(); ++it) { (*it)->doInteraction(e, mult, touchWidth);