class ToggleMaterialOverlayEffector extends Effector
{
	private var m_effectPath : String;
	private var m_effectTag : CName;
	private var m_owner : weak< GameObject >;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_effectPath = TweakDBInterface.GetString( record + T".effectPath", "" );
		m_effectTag = TweakDBInterface.GetCName( record + T".effectTag", '' );
	}

	protected override function ActionOn( owner : GameObject )
	{
		m_owner = owner;
		ToggleEffect( true );
	}

	protected override function ActionOff( owner : GameObject )
	{
		ToggleEffect( false );
	}

	protected override function Uninitialize( game : GameInstance )
	{
		ToggleEffect( false );
	}

	private function ToggleEffect( enable : Bool )
	{
		var effectInstance : EffectInstance;
		if( m_owner )
		{
			effectInstance = GameInstance.GetGameEffectSystem( m_owner.GetGame() ).CreateEffectStatic( StringToName( m_effectPath ), m_effectTag, m_owner );
			EffectData.SetEntity( effectInstance.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.entity, m_owner );
			EffectData.SetBool( effectInstance.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.renderMaterialOverride, false );
			EffectData.SetBool( effectInstance.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.enable, enable );
			effectInstance.Run();
		}
	}

}

