-- Dump-in-water target
-- Will clear target once center of body is in water

#include "common.lua"
pDepth = GetFloatParam("depth", 0.8)
pRobot = GetBoolParam("robot", false)

function init()
	done = false
	target = FindBody("target")
end


function tick(dt)
	if not done then
		if pRobot then
			if HasTag(target, "disabled") then
				SetTag(target, "target", "cleared")
				done = true
			end
		else
			local pos = GetBodyTransform(target).pos
			local inWater, depth = IsPointInWater(pos)
			if inWater and depth > pDepth then
				SetTag(target, "target", "cleared")
				done = true
			end
		end
	end
end

