From 3ba31b6aa02ab2e87ec710bc888fc910403dcd51 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Thu, 1 Jun 2023 20:23:34 +0200 Subject: [PATCH] remove bool Element::elementActive, use _hidden instead Element is always alone, never has parent or children, and can use the normal RenderObject::_hidden logic to determine visibility and update calls. --- Aquaria/Element.cpp | 7 +++---- Aquaria/Element.h | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index c3ea191..fc7f28d 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -40,7 +40,6 @@ ElementEffectData::ElementEffectData() Element::Element() : Quad() { elementFlag = EF_NONE; - elementActive = true; bgLayer = 0; tag = 0; templateIdx = -1; @@ -307,8 +306,8 @@ static inline const Vector& getTagColor(int tag) void Element::render(const RenderState& rs) const { - if (!elementActive) return; - + // FIXME: this should be part of the layer render, not here + // (not relevant until Elements are batched per-layer) if (game->isSceneEditorActive() && this->bgLayer == game->sceneEditor.bgLayer && game->sceneEditor.editType == ET_ELEMENTS) { @@ -345,7 +344,7 @@ void Element::render(const RenderState& rs) const void Element::fillGrid() { - if (life == 1 && elementActive) + if (life == 1 && !_hidden) { if (elementFlag == EF_SOLID) { diff --git a/Aquaria/Element.h b/Aquaria/Element.h index ce54bfb..db395f5 100644 --- a/Aquaria/Element.h +++ b/Aquaria/Element.h @@ -70,10 +70,10 @@ public: void render(const RenderState& rs) const OVERRIDE; ElementFlag elementFlag; void fillGrid(); - bool isElementActive() const { return elementActive; } + bool isElementActive() const { return !_hidden; } int getElementEffectIndex(); void setElementEffectByIndex(int e); - void setElementActive(bool v) { elementActive = v; } + void setElementActive(bool v) { _hidden = !v; } void doInteraction(Entity *ent, float mult, float touchWidth); void setTag(int tag); protected: @@ -82,10 +82,7 @@ protected: void setGridFromWavy(); ElementEffectData *eff; - void updateEffects(float dt); - - bool elementActive; -}; + void updateEffects(float dt);}; typedef std::vector ElementContainer;