class ChangeAppearanceEffector extends Effector
{
	private var m_appearanceName : CName;
	private var m_resetAppearance : Bool;
	private var m_previousAppearance : CName;
	private var m_owner : weak< GameObject >;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_appearanceName = TweakDBInterface.GetCName( record + T".appearanceName", '' );
		m_resetAppearance = TweakDBInterface.GetBool( record + T".resetAppearance", true );
	}

	protected override function ActionOn( owner : GameObject )
	{
		m_owner = owner;
		if( m_resetAppearance == true )
		{
			m_previousAppearance = m_owner.GetCurrentAppearanceName();
		}
		else
		{
			m_previousAppearance = '';
		}
		if( IsNameValid( m_appearanceName ) )
		{
			m_owner.ScheduleAppearanceChange( m_appearanceName );
		}
	}

	protected override function Uninitialize( game : GameInstance )
	{
		if( IsNameValid( m_previousAppearance ) )
		{
			m_owner.ScheduleAppearanceChange( m_previousAppearance );
		}
	}

}

