2016-09-27 16:23:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <glm/vec2.hpp>
|
|
|
|
#include <glm/vec3.hpp>
|
|
|
|
|
2016-09-27 19:16:55 +00:00
|
|
|
#include "missile_hit_type.hpp"
|
|
|
|
|
2016-09-27 16:23:58 +00:00
|
|
|
namespace game {
|
|
|
|
class State;
|
2016-09-27 18:13:09 +00:00
|
|
|
class Ship;
|
|
|
|
class Planet;
|
|
|
|
class Player;
|
|
|
|
class State;
|
|
|
|
class Trace;
|
2016-09-27 16:23:58 +00:00
|
|
|
|
|
|
|
// missile belongs to a player and optionally fills a trace behind it.
|
|
|
|
// trace then belongs to the player.
|
|
|
|
class Missile {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// missile advances to pos. if hit != Nothing, it hits something and
|
|
|
|
// stops existing afterwards.
|
|
|
|
class Event {
|
|
|
|
public:
|
2016-09-27 19:16:55 +00:00
|
|
|
Event(const glm::vec2 &pos) : Event(pos, Hit::Nothing)
|
2016-09-27 16:23:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-27 19:16:55 +00:00
|
|
|
Event(const glm::vec2 &pos, Hit hit)
|
|
|
|
: hit(hit), position(pos)
|
2016-09-27 16:23:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Event(const glm::vec2 &pos, int playerIdKiller, int playerIdVictim)
|
2016-09-27 19:16:55 +00:00
|
|
|
: Event(pos, Hit::Ship)
|
2016-09-27 16:23:58 +00:00
|
|
|
{
|
|
|
|
this->playerIdKiller = playerIdKiller;
|
|
|
|
this->playerIdVictim = playerIdVictim;
|
|
|
|
}
|
|
|
|
|
2016-09-27 19:16:55 +00:00
|
|
|
Hit hit;
|
|
|
|
glm::vec2 position;
|
2016-09-27 16:23:58 +00:00
|
|
|
|
|
|
|
int playerIdKiller;
|
|
|
|
int playerIdVictim;
|
|
|
|
};
|
|
|
|
|
2016-09-27 18:13:09 +00:00
|
|
|
Missile(Player *player, const glm::vec2 &pos, float angle, float speed);
|
2016-09-27 16:23:58 +00:00
|
|
|
~Missile();
|
|
|
|
|
|
|
|
// try to advance. if something will be hit, return the first hit in
|
|
|
|
// time.
|
|
|
|
Missile::Event advance(const game::State *state, float dt);
|
2016-09-27 18:13:09 +00:00
|
|
|
|
|
|
|
Player *player; // owner won't be hit by own missiles
|
|
|
|
glm::vec2 position;
|
|
|
|
glm::vec2 velocity;
|
|
|
|
Trace *trace;
|
2016-09-27 16:23:58 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|