
#pragma once

#include "MW4.hpp"
#include "Subsystem.hpp"

namespace MechWarrior4
{
	class Vehicle;
	class HeatObject;
	class HeatManager;

	typedef Subsystem__ClassData						HeatSink__ClassData;
	typedef Subsystem__Message							HeatSink__Message;
	typedef Subsystem__ExecutionStateEngine				HeatSink__ExecutionStateEngine;
	typedef Subsystem__CreateMessage					HeatSink__CreateMessage;


	//##########################################################################
	//######################   HeatSink::GameModel    ##########################
	//##########################################################################

	class HeatSink__GameModel:
		public Subsystem::GameModel
	{
	public:
		typedef Subsystem::GameModel BaseClass;

		Stuff::Scalar
			m_heatSinkPoints;

		enum {
			HeatSinkPointsAttributeID = Subsystem__GameModel::NextAttributeID,
			NextAttributeID
		};

		static bool
			ReadAndVerify(
				HeatSink__GameModel *model,
				ModelAttributeEntry *attribute_entry, 
				const char *data,
				char **error,
				int error_buffer = 128
			);


		static void
			ConstructGameModel(Script *script);
	};


	//##########################################################################
	//###########################   HeatSink    ################################
	//##########################################################################

	class HeatSink:
		public Subsystem
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

	//##########################################################################
	// Inheritance support
	//
	public:
		typedef HeatSink__ClassData						ClassData;
		typedef HeatSink__GameModel						GameModel;
		typedef HeatSink__Message						Message;
		typedef HeatSink__ExecutionStateEngine			ExecutionStateEngine;
		typedef HeatSink__CreateMessage					CreateMessage;


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static HeatSink* 
			Make(
				CreateMessage *message,
				ReplicatorID *base_id
			);

	protected:
		HeatSink(
			ClassData *class_data,
			CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);

		~HeatSink();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Class Data & Game Model Support
	//
	public:
		const GameModel*
			GetGameModel()
				{return Cast_Pointer(const GameModel*, gameModelResource.GetPointer());}


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Shared Data support
	//
	public:
		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//
	public:
		bool
			TakeCriticalHit();
		void
			DestroySubsystem();
		void
			ConnectHeatManager(HeatManager *heat_manager);

		HeatObject *heatSinkObject;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		void
      		TestInstance() const;
	};
}


