////////////////////////////////////////////////////////////////////////////////
// VTOL.h
// Declaration of a Vehicle class for VTOLs
// Copyright Bjoern Ganster
// Developed since 2021
////////////////////////////////////////////////////////////////////////////////

#ifndef VTOL__h
#define VTOL__h

#include "CombatVehicle.h"

////////////////////////////////////////////////////////////////////////////////

class VTOL: public Vehicle {
public:
	// Constructor
	VTOL(CombatVehicleTypes subType);

	// Destructor
	~VTOL() OVERRIDE;

	// Load vehicle from XML
	void readSpecialAttributes(XMLTreeConstIterator& iter, const std::vector<RenderableObject*>& geometries, const PathChar* mechDir) OVERRIDE;
	void readSpecialAttributesFromRoot(XMLTreeConstIterator& iter) OVERRIDE;

	// Help function for parsing that translates a section name to a number
	int getSectionByName(const BGCPString& str) OVERRIDE;

	// Show or hide the vehicle's windshiled (cockpit view may require it to be hidden)
	void windshieldVisible(bool newVal) OVERRIDE;

	// Set direction where the vehicle is aiming, by moving the turret (vehicles) or twisting and tilting the torso (mechs)
	void setAim(double turn, double tilt) OVERRIDE;

	// Set current animation matrices
	void setMatrices(double speed, DWORD missionTime) OVERRIDE;

	// Get tilt and turn for current aim direction
	double getAimTilt() const OVERRIDE;
	double getAimTurn() const OVERRIDE;

	// Move aim towards given angles by at most delta
	void adjustAim(double desiredTorsoTwist, double desiredTorsoTilt, double delta) OVERRIDE;

	// Get mesh used for the cockpit
	Mesh* getCockpitMesh() OVERRIDE;

	// Check for a collision with a polygon and handle it
	void checkCollision(const MeshPolygon* poly, Point3D& movement) OVERRIDE;

	// Based on the vehicle type, connect the vehicle to a suitable AI
	virtual AbstractVehicleAI* createAI(bool isPlayer, int environment) OVERRIDE;

	virtual bool reticleMovesVertically() const;

	// Calculate heat for next frame
	void calcNextFrameHeat(DWORD now, double deltaT) OVERRIDE;

	// Get current heat value for vehicle
	double getHeat() const NOEXCEPT OVERRIDE;

	// Calculate movement for next frame
	void calcNextFrameMovement(double deltaT, RenderableObject* scene, DWORD now, double gravity) OVERRIDE;

	// Calculate distance from ground 
	void calcDistFromGround(const Point3D& p, const RenderableObject* obj, double& value);

private:
	double mTurretTurn, mTurretTilt, mTurretTurnLimit, mTurretTiltLimit;
};

#endif

