ObjectData = 
{
	MotionModel = 
	{
		DefaultAnimation = [[normal]],
		Motions = 
		{
			motion3 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\World\puzzle_shard.anim]],
						Name = [[puzzle_shard]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[toolbar]],
			},
			motion4 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\World\puzzle_shard_obtained.anim]],
						Name = [[puzzle_shard_obtained]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[obtained]],
			},
			motion2 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\World\puzzle_shard.anim]],
						Name = [[puzzle_shard]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[normal]],
			},
			motion1 = 
			{
				Animations = 
				{
					anim1 = 
					{
						Path = [[DATA:Animations\World\blank.anim]],
						Name = [[blank]],
						MinFreq = 1.000000,
						MaxFreq = 1.000000,
					},
				},
				Name = [[blank]],
			},
		},
	},
	Extensions = 
	{
		PositionExtension = 
		{
			foreground = true,
		},
		PhysicsExtension = 
		{
		},
		LevelEditorExtension = 
		{
			locked = true,
		},
	},
}

-- Begin Scripting --

help_text_header = "$00641"
help_text = "$00642"

function OnInit()

	this:EnablePhysics( false )
	this:EnableCollisions( false )
	
	goal = nil

end

function OnCreatorUpdate()

	CheckShine()
	
end

function CheckShine()
	
	if World_ShowPuzzleAsNew() then 
		
		if shine == nil or not shine:IsValid() then
			shine = this:CreateEffect("World/goal_shine")
		end
		
	else
	
		local motion_model = this:GetMotionModel()
		if motion_model:GetCurrentMotionName() ~= "obtained" then
			motion_model:SetDefaultMotion("obtained")
		end
	
	end
	
end

function Update()

	CheckShine()
	
	if goal == nil or not goal:IsValid() then
		if World_ShowPuzzleAsNew() then
			goal = this:CreateEffect("World/goal")
		else
			goal = this:CreateEffect("World/goal_obtained")
		end
	end
	
	local motion_model = this:GetMotionModel()
	if motion_model:GetCurrentMotionName() ~= "blank" then
		motion_model:PushMotion("blank", false, true)
	end
	
	if World_CheckGoal(this) then
		World_SetWinFlag()
		goal:Stop(false)
		
		if shine then shine:Stop(false) end
		
		World_CreateEffect( "World/win_explosion", this:GetPosition() )
	end

end

