1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-03 16:35:45 +00:00
Aquaria/Aquaria/Element.h
2016-05-05 19:57:50 +02:00

91 lines
2 KiB
C++

/*
Copyright (C) 2007, 2010 - Bit-Blot
This file is part of Aquaria.
Aquaria is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __element__
#define __element__
#include "../BBGE/Quad.h"
class Entity;
enum ElementFlag
{
EF_NONE = 0,
EF_SOLID = 1,
EF_MOVABLE = 2,
EF_HURT = 3,
EF_SOLID2 = 4,
EF_SOLID3 = 5,
EF_MAX = 6
/*
EF_GLASS = 0x00000020,
EF_FORCEBREAK = 0x00000100,
EF_HURT = 0x00000200
*/
};
struct ElementEffectData
{
ElementEffectData();
int elementEffectType;
float wavyAngleOffset, wavyMagnitude, wavyLerpIn;
float wavyMin, wavyMax;
float hitPerc, effectMult;
bool wavyWaving, wavyFlip, touching;
Vector touchVel;
std::vector<Vector> wavy, wavySave;
int elementEffectIndex; // used by editor only
};
class Element : public Quad
{
public:
Element();
~Element();
void destroy();
void update(float dt);
int templateIdx;
int bgLayer;
Element *bgLayerNext;
void render();
ElementFlag elementFlag;
void fillGrid();
bool isElementActive() { return elementActive; }
int getElementEffectIndex();
void setElementEffectByIndex(int e);
void setElementActive(bool v) { elementActive = v; }
void doInteraction(Entity *ent, float mult, float touchWidth);
protected:
void ensureEffectData();
void freeEffectData();
void setGridFromWavy();
ElementEffectData *eff;
void updateEffects(float dt);
bool elementActive;
};
typedef std::vector<Element*> ElementContainer;
#endif