//-----------------------------------------------------------------------------
//
//  $Logfile:: /game/light.h                                                  $
// $Revision:: 2                                                              $
//   $Author:: Burgermac                                                      $
//     $Date:: 12/27/00 6:49 PM                                               $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// DESCRIPTION:
// Classes for creating and controlling lights.
//

#ifndef __LIGHT_H__
#define __LIGHT_H__

#include "g_local.h"
#include "entity.h"
#include "trigger.h"

extern Event EV_Light_TurnOn;
extern Event EV_Light_TurnOff;
extern Event EV_Light_SetLightStyle;

class BaseLight : public Trigger
{
protected:
	int style;
	str lightstyle;
	str on_style;
	str off_style;

public:
	CLASS_PROTOTYPE( BaseLight );

	BaseLight();
	void                    SetLightStyle( const char* stylestring );
	void                    EventSetLightStyle( Event* ev );
	int               GetStyle( void );
	void                    TurnOn( Event* ev );
	void                    TurnOff( Event* ev );
	virtual void      Archive( Archiver& arc );
	virtual void      Unarchive( Archiver& arc );
};

inline void BaseLight::Archive( Archiver& arc )
{
	Trigger::Archive( arc );

	arc.WriteInteger( style );
	arc.WriteString( lightstyle );
	arc.WriteString( on_style );
	arc.WriteString( off_style );
}

inline void BaseLight::Unarchive( Archiver& arc )
{
	Trigger::Unarchive( arc );

	style = arc.ReadInteger();
	arc.ReadString( &lightstyle );
	arc.ReadString( &on_style );
	arc.ReadString( &off_style );
}

class LightRamp : public BaseLight
{
protected:
	float minlevel;
	float maxlevel;
	float currentlevel;
	float rate;

public:
	CLASS_PROTOTYPE( LightRamp );

	LightRamp();
	void             RampLight( Event* ev );
	void             StartRamp( Event* ev );
	virtual void   Archive( Archiver& arc );
	virtual void   Unarchive( Archiver& arc );
};

inline void LightRamp::Archive( Archiver& arc )
{
	BaseLight::Archive( arc );

	arc.WriteFloat( minlevel );
	arc.WriteFloat( maxlevel );
	arc.WriteFloat( currentlevel );
	arc.WriteFloat( rate );
}

inline void LightRamp::Unarchive( Archiver& arc )
{
	BaseLight::Unarchive( arc );

	minlevel = arc.ReadFloat();
	maxlevel = arc.ReadFloat();
	currentlevel = arc.ReadFloat();
	rate = arc.ReadFloat();
}


class TriggerLightRamp : public LightRamp
{
public:
	CLASS_PROTOTYPE( TriggerLightRamp );
};

class Light : public BaseLight
{
public:
	CLASS_PROTOTYPE( Light );

	void                    ToggleLight( Event* ev );
	Light();
};

class TriggerLightStyle : public Light
{
public:
	CLASS_PROTOTYPE( TriggerLightStyle );
};

#endif /* light.h */
