2020-12-31 07:32:16 -08:00
|
|
|
// Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
|
2012-09-15 17:59:15 -07:00
|
|
|
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
2012-09-12 04:38:30 -07:00
|
|
|
|
2009-09-12 10:25:15 -07:00
|
|
|
#ifndef _PROJECTILE_H
|
|
|
|
#define _PROJECTILE_H
|
|
|
|
|
|
|
|
#include "Body.h"
|
|
|
|
|
2017-01-06 10:22:40 -08:00
|
|
|
struct ProjectileData {
|
2019-01-02 08:59:07 -08:00
|
|
|
ProjectileData() :
|
|
|
|
lifespan(0.0f),
|
|
|
|
damage(0.0f),
|
|
|
|
length(0.0f),
|
|
|
|
width(0.0f),
|
|
|
|
speed(0.0f),
|
|
|
|
color(Color::WHITE),
|
|
|
|
mining(false),
|
|
|
|
beam(false) {}
|
2017-01-06 10:22:40 -08:00
|
|
|
float lifespan;
|
|
|
|
float damage;
|
|
|
|
float length;
|
|
|
|
float width;
|
|
|
|
float speed;
|
|
|
|
Color color;
|
2018-01-21 09:04:02 -08:00
|
|
|
bool mining;
|
|
|
|
bool beam;
|
2017-01-06 10:22:40 -08:00
|
|
|
};
|
|
|
|
|
2009-09-12 10:25:15 -07:00
|
|
|
class Frame;
|
2019-01-18 11:49:54 -08:00
|
|
|
|
2012-02-21 02:04:06 -08:00
|
|
|
namespace Graphics {
|
2019-10-16 12:10:22 -07:00
|
|
|
class Material;
|
2012-02-21 02:04:06 -08:00
|
|
|
class Renderer;
|
2019-01-18 11:49:54 -08:00
|
|
|
class RenderState;
|
2012-02-21 07:53:31 -08:00
|
|
|
class VertexArray;
|
2019-01-02 08:59:07 -08:00
|
|
|
} // namespace Graphics
|
2009-09-12 10:25:15 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
class Projectile : public Body {
|
2009-09-12 10:25:15 -07:00
|
|
|
public:
|
|
|
|
OBJDEF(Projectile, Body, PROJECTILE);
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
static void Add(Body *parent, float lifespan, float dam, float length, float width, bool mining, const Color &color, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel);
|
2019-01-27 07:30:50 -08:00
|
|
|
static void Add(Body *parent, const ProjectileData &prData, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel);
|
2009-09-12 10:25:15 -07:00
|
|
|
|
2019-01-27 07:30:50 -08:00
|
|
|
Projectile() = delete;
|
|
|
|
Projectile(Body *parent, const ProjectileData &prData, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel);
|
|
|
|
Projectile(const Json &jsonObj, Space *space);
|
2012-02-12 04:45:23 -08:00
|
|
|
virtual ~Projectile();
|
2019-01-02 08:59:07 -08:00
|
|
|
virtual void Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) override final;
|
2018-01-23 09:26:05 -08:00
|
|
|
void TimeStepUpdate(const float timeStep) override final;
|
|
|
|
void StaticUpdate(const float timeStep) override final;
|
2019-01-02 08:59:07 -08:00
|
|
|
virtual void NotifyRemoved(const Body *const removedBody) override final;
|
2018-01-23 09:26:05 -08:00
|
|
|
virtual void UpdateInterpTransform(double alpha) override final;
|
|
|
|
virtual void PostLoadFixup(Space *space) override final;
|
2012-12-15 21:32:11 -08:00
|
|
|
|
2012-12-17 13:28:33 -08:00
|
|
|
static void FreeModel();
|
2012-12-17 13:42:07 -08:00
|
|
|
|
2009-09-12 10:25:15 -07:00
|
|
|
protected:
|
2018-10-11 08:10:23 -07:00
|
|
|
virtual void SaveToJson(Json &jsonObj, Space *space) override final;
|
2015-02-16 15:30:19 -08:00
|
|
|
|
2009-09-12 10:25:15 -07:00
|
|
|
private:
|
2009-09-14 04:16:15 -07:00
|
|
|
float GetDamage() const;
|
2012-02-14 17:37:56 -08:00
|
|
|
double GetRadius() const;
|
2009-09-12 10:25:15 -07:00
|
|
|
Body *m_parent;
|
2009-09-14 04:16:15 -07:00
|
|
|
vector3d m_baseVel;
|
|
|
|
vector3d m_dirVel;
|
2009-09-12 10:25:15 -07:00
|
|
|
float m_age;
|
2014-04-14 14:05:51 -07:00
|
|
|
float m_lifespan;
|
|
|
|
float m_baseDam;
|
|
|
|
float m_length;
|
|
|
|
float m_width;
|
|
|
|
bool m_mining;
|
|
|
|
Color m_color;
|
2011-05-12 05:31:08 -07:00
|
|
|
|
|
|
|
int m_parentIndex; // deserialisation
|
2012-02-12 03:20:17 -08:00
|
|
|
|
2012-12-15 21:32:11 -08:00
|
|
|
static void BuildModel();
|
|
|
|
|
2013-10-29 04:44:49 -07:00
|
|
|
static std::unique_ptr<Graphics::VertexArray> s_sideVerts;
|
|
|
|
static std::unique_ptr<Graphics::VertexArray> s_glowVerts;
|
|
|
|
static std::unique_ptr<Graphics::Material> s_sideMat;
|
|
|
|
static std::unique_ptr<Graphics::Material> s_glowMat;
|
2014-01-26 12:11:27 -08:00
|
|
|
static Graphics::RenderState *s_renderState;
|
2009-09-12 10:25:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _PROJECTILE_H */
|