#include "scripts/common.txt"
#include "scripts/BP_common.txt"

//(2) Health -32768..32767 (Sound Index)
//(7) Params 1 -128..127 (0 = play as many times, 1 = play only once )

class BP_SoundOnce : ScriptObject
{
    kActor @self;
	//------------------------------------------------------------------------------------------------------------------------
    BP_SoundOnce(kActor @actor)
	{
        @self = actor;
    }
	//------------------------------------------------------------------------------------------------------------------------
	void OnActivate()
	{
		self.Flags() &= ~AF_ACTIVATED;
		
		if ((Player.Actor().Flags() & AF_ENTEREDAREAEVENT) != 0)
		{
			return;
		}
		
		uint soundIndex = self.SpawnParams(2);
		switch(soundIndex)
		{
			case 0:
			{
				Game.PlaySound("sounds/shaders/leapoffaith.ksnd");
				Game.PrintLine(LTKey(2), 1, 180);
				break;
			}
			case 1:
			{
				Game.PlaySound("sounds/shaders/robotwarning.ksnd");
				break;
			}
			case 2:
			{
				Game.PlaySound("sounds/shaders/fireborn_attack1.ksnd");
				break;
			}
		}
		
		if (self.SpawnParams(7) == 1)
		{
			self.Remove();
			self.MarkPersistentBit(false);
		}
	}
	//------------------------------------------------------------------------------------------------------------------------
    void OnRestore()
    {
		self.Remove();
    }
	//------------------------------------------------------------------------------------------------------------------------
    void OnTick()
	{
    }
	//------------------------------------------------------------------------------------------------------------------------
    void OnSpawn()
	{
    }
	//------------------------------------------------------------------------------------------------------------------------
}
