75 lines
2.1 KiB
C++
75 lines
2.1 KiB
C++
#pragma once
|
|
#include "libs.h"
|
|
#include "dynamic_body.h"
|
|
#include "ship_type.h"
|
|
#include "sbre/sbre.h"
|
|
|
|
class SpaceStation;
|
|
|
|
struct shipstats_t {
|
|
int max_capacity;
|
|
int used_capacity;
|
|
int free_capacity;
|
|
int total_mass; /* Cargo, equipment + hull. */
|
|
float hyperspace_range;
|
|
};
|
|
|
|
class Ship : public DynamicBody {
|
|
public:
|
|
Ship(ShipType::Type shipType);
|
|
virtual Object::Type GetType(void) { return Object::SHIP; }
|
|
virtual void SetDockedWith(SpaceStation*);
|
|
SpaceStation* GetDockedWith(void) { return m_dockedWith; }
|
|
void SetNavTarget(Body* const target);
|
|
Body* GetNavTarget(void) const { return m_navTarget; }
|
|
void SetCombatTarget(Body* const target);
|
|
Body* GetCombatTarget(void) const { return m_combatTarget; }
|
|
virtual void Render(const Frame* camFrame);
|
|
void SetThrusterState(enum ShipType::Thruster t, float level);
|
|
void SetAngThrusterState(int axis, float level) { m_angThrusters[axis] = CLAMP(level, -1, 1); }
|
|
void ClearThrusterState(void);
|
|
void SetGunState(int idx, int state);
|
|
const ShipType& GetShipType(void);
|
|
void CalcStats(shipstats_t* stats);
|
|
void UpdateMass(void);
|
|
vector3d CalcRotDamping();
|
|
void SetWheelState(bool down);
|
|
float GetDockingTimer(void) { return dockingTimer; }
|
|
void SetDockingTimer(float t) { dockingTimer = t; }
|
|
virtual void TimeStepUpdate(const float timeStep);
|
|
virtual void NotifyDeath(const Body* const dyingBody);
|
|
virtual bool OnCollision(Body* b, Uint32 flags);
|
|
|
|
class LaserObj : public Object {
|
|
public:
|
|
virtual Object::Type GetType(void) { return Object::LASER; }
|
|
Ship* owner;
|
|
};
|
|
|
|
EquipSet m_equipment;
|
|
protected:
|
|
void RenderLaserfire(void);
|
|
|
|
SpaceStation* m_dockedWith;
|
|
bool m_isLanded;
|
|
enum ShipType::Type m_shipType;
|
|
Uint32 m_gunState[ShipType::GUNMOUNT_MAX];
|
|
private:
|
|
bool IsFiringLasers(void);
|
|
void TestLanded(void);
|
|
|
|
bool m_testLanded;
|
|
float m_wheelState;
|
|
float m_wheelTransition;
|
|
|
|
float m_thrusters[ShipType::THRUSTER_MAX];
|
|
float m_angThrusters[3];
|
|
float dockingTimer;
|
|
dGeomID m_tempLaserGeom[ShipType::GUNMOUNT_MAX];
|
|
|
|
LaserObj m_laserCollisionObj;
|
|
Body* m_navTarget;
|
|
Body* m_combatTarget;
|
|
};
|
|
|