1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-10 14:14:05 +00:00
Aquaria/Aquaria/Spore.cpp
fgenesis 49b9e0f05a Rework & cleanup CMake project files
- Building with CMake for development is now actually sane
- Split deps into projects and extra files
- Building against external deps should still work but needs testing
- Can now build out of the box without further adjustments as long as SDL(2) is found properly
- Build Lua in C++ mode (so it can use exceptions instead of setjmp/longjmp)
  - Unfortunately we need to enable exceptions for this :(

- Remove these defines:
  * AQUARIA_BUILD_SCENEEDITOR (now always on)
  * AQUARIA_BUILD_CONSOLE (now always on)
  * BBGE_BUILD_ACHIEVEMENTS_INTERNAL (now always on unless BBGE_BUILD_STEAMWORKS is defined)
  * BBGE_BUILD_OPENGL_DYNAMIC (now always on, define BBGE_BUILD_OPENGL_STATIC if needed)
  * BBGE_BUILD_FMOD_OPENAL_BRIDGE (now always on)
- BBGE_BUILD_STEAMWORKS is not actually implemented (any volunteers?)
- Prepare later removal of SDL & the old vc90 project from the repo. See #74 for extra notes.
2022-04-07 02:38:39 +02:00

123 lines
2.4 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.
*/
#include "Spore.h"
#include "Shot.h"
#include "Game.h"
#include "Avatar.h"
Spore::Spores Spore::spores;
Spore::Spore (const Vector &position) : CollideEntity()
{
spores.push_back(this);
scale = Vector(0.1f, 0.1f);
alpha = 0;
this->position = position;
alpha.interpolateTo(1, 0.5f);
scale.interpolateTo(Vector(1, 1), 4);
setTexture("Spore");
setAllDamageTargets(false);
setEntityType(ET_ENEMY);
setDamageTarget(DT_AVATAR_ENERGYBLAST, true);
setDamageTarget(DT_AVATAR_SHOCK, true);
setDamageTarget(DT_AVATAR_ENERGYROLL, true);
health = maxHealth = 1;
}
bool Spore::isPositionClear(const Vector &position)
{
if (dsq->game->isObstructed(TileVector(position)))
return false;
for (Spores::iterator i = spores.begin(); i != spores.end(); i++)
{
Spore *s = *i;
if (s->position == position)
{
return false;
}
}
return true;
}
void Spore::destroy()
{
spores.remove(this);
CollideEntity::destroy();
}
void Spore::onEndOfLife()
{
spores.remove(this);
}
void Spore::onEnterState(int state)
{
CollideEntity::onEnterState(state);
if (state == STATE_DEAD)
{
setLife(1);
setDecayRate(4);
fadeAlphaWithLife = true;
}
}
void Spore::killAllSpores()
{
Spores sporesToDelete = spores; // copy
for (Spores::iterator it = sporesToDelete.begin(); it != sporesToDelete.end(); it++)
if(Spore *s = *it)
s->safeKill();
spores.clear();
}
void Spore::onUpdate(float dt)
{
CollideEntity::onUpdate(dt);
if (life < 1) return;
if (!(dsq->game->avatar->position - position).isLength2DIn(1024))
{
safeKill();
}
else
{
int sporeCr = 48;
collideRadius = scale.x * sporeCr;
if (touchAvatarDamage(collideRadius, 1, Vector(-1,-1,-1), 500))
{
// YAY!
}
dsq->game->handleShotCollisions(this);
}
}