#pragma once

#include "vtvsub.h"

//##########################################################################
//#####################    Booster::SubsystemResource    ###################
//##########################################################################

struct Booster__SubsystemResource:
	public VTVSubsystem::SubsystemResource
{
	int boosterCount;
	Scalar
		burnTime,
		boosterAcceleration;
};

//##########################################################################
//############################    Booster    ###############################
//##########################################################################

class Booster:
	public VTVSubsystem
{
	friend class VTV;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Messageing Support
//
public:
	enum {
		ActivateMessageID = VTVSubsystem::NextMessageID,
		ConfigureMappablesMessageID,
		ChooseButtonMessageID,
		NextMessageID
	};

	void
		ActivateMessageHandler(
			ReceiverDataMessageOf<ControlsButton> *message
		);
	void
		ConfigureMappablesMessageHandler(
			ReceiverDataMessageOf<ControlsButton> *message
		);
	void
		ChooseButtonMessageHandler(
			ReceiverDataMessageOf<ControlsButton> *message
		);

protected:
	static const HandlerEntry
		MessageHandlerEntries[];
	static MessageHandlerSet
		MessageHandlers;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data support
//
public:
	static Derivation *GetClassDerivations();
	static SharedData DefaultData;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support
//
public:
	enum {
		BurnTimeRemainingAttributeID = VTVSubsystem::NextAttributeID,
		BoostersRemainingAttributeID,
		ScaleFactorAttributeID,
		SmokeDensityAttributeID,
		PercentDoneAttributeID,
		NextAttributeID
	};

private:
	static const IndexEntry AttributePointers[];

protected:
	////static AttributeIndexSet	AttributeIndex
	static AttributeIndexSet& GetAttributeIndex();

//
// public attribute declarations go here
//
public:
	Scalar 	burnTimeRemaining;
	Scalar 	boostersRemaining;
	Vector3D	scaleFactor;
	Scalar	smokeDensity;
	Scalar	percentDone;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
	enum {
		BoosterBurning = Subsystem::StateCount,
		StateCount
	};

	typedef void
		(Booster::*Performance)(Scalar time_slice);

	void
		BoosterSimulation(Scalar time_slice);

	void
		SetPerformance(Performance performance)
			{
				Check(this);
				activePerformance = (Simulation::Performance)performance;
			}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   Damage Support
//
void
	DeathReset(int reset_command);
void
	DeathShutdown(int shutdown_command);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
	typedef Booster__SubsystemResource SubsystemResource;

	static int
		CreateStreamedSubsystem(
			NotationFile	*model_file,
			const char		*model_name,
			const char						*subsystem_name,
			SubsystemResource				*subsystem_resource,
			NotationFile					*subsystem_file,
			const ResourceDirectories	*directories
		);

	Booster(
		VTV *owner,
		int subsystem_ID,
		SubsystemResource *subsystem_resource
	);
	~Booster();

	Logical
  	TestInstance() const;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local data for the Booster class
//
protected:
	Scalar   burnTimeMax;
	Scalar   acceleration;
	int 		maxBoosters;
};
