ghf.GameNode.remove = ghf.GameNode.removeFromParent

function randomFromWeightedTable(t)

	-- Calculate the sum of the weights
	local sum = 0
	for _,v in pairs(t) do
		assert(isNumber(v.weight))
		sum = sum + v.weight
	end
	assert(sum > 0)

	-- Get a random index
	local idx = math.Random(sum)
	assert(idx >= 1)
	assert(idx <= sum)

	-- Calculate the value
	local counter = 0
	local result = nil
	for _,v in pairs(t) do
		result = v
		counter = counter + v.weight

		if (counter > idx) then
			break
		end
	end

	return result

end

function toPoint(v, w)
	if (isTable(v)) then
		return {x = v.x or v[1] or 0, y = v.y or v[2] or 0}
	end
	return {x = v or 0, y = w or 0}
end

dofile("script/Constants.lua");
dofile("script/Tasks.lua");
dofile("script/Character.lua")
dofile("script/TaskSystem.lua")
dofile("script/Trophies.lua")
dofile("script/CareLevel.lua")
dofile("script/Values.lua")
dofile("script/shifts/all_shifts.lua")
dofile("script/objects/Object.lua")
dofile("script/objects/Station.lua")
dofile("script/objects/ChangeStation.lua")
dofile("script/objects/CheckOutDesk.lua")
dofile("script/objects/Clock.lua")
dofile("script/objects/WorkStation.lua")
dofile("script/objects/BathRobeStation.lua")
dofile("script/objects/WaterCooler.lua")
dofile("script/objects/Chair.lua")
dofile("script/objects/MicroscopeStation.lua")
dofile("script/objects/StockPillsStation.lua")
dofile("script/objects/PillsStation.lua")
dofile("script/objects/CoffeeMachine.lua")
dofile("script/objects/GameHouseObject.lua")
dofile("script/objects/ToiletStation.lua")
dofile("script/objects/ToiletStation2.lua")
dofile("script/objects/DrawingTable.lua")
dofile("script/objects/MagazineStand.lua")
dofile("script/objects/CosmeticTableStation.lua")
dofile("script/objects/CosmeticChairStation.lua")
dofile("script/objects/YogaMat.lua")
dofile("script/objects/BabyCorner.lua")
dofile("script/objects/DiapersStockStation.lua")
dofile("script/objects/LiceChair.lua")
dofile("script/objects/Blueprints.lua")
dofile("script/objects/View.lua")
dofile("script/objects/GuineaPig.lua")
dofile("script/minigames/MiniGame.lua")
dofile("script/minigames/SoreSpot.lua")
dofile("script/minigames/BloodPressure.lua")
dofile("script/minigames/GermMatch.lua")
dofile("script/minigames/XRay.lua")
dofile("script/minigames/Removal.lua")
dofile("script/minigames/Laser.lua")
dofile("script/minigames/PlaceHair.lua")
dofile("script/minigames/Chart.lua")
dofile("script/minigames/Yoga.lua")
dofile("script/minigames/UltraSound.lua")
dofile("script/minigames/Bandaid.lua")
dofile("script/events/Event.lua")
dofile("script/events/SpecialRoom3.lua")
dofile("script/events/SpecialRoom4.lua")
dofile("script/events/SpecialRoom5.lua")
dofile("script/events/HiddenObjectEvent.lua")
dofile("script/events/FixEvent.lua")
dofile("script/events/QuestionsEvent.lua")
dofile("script/events/SneezeEvent.lua")
dofile("script/events/GestureEvent.lua")
dofile("script/events/SpecialRoom1.lua")
dofile("script/events/QuestionPopupEvent.lua")
dofile("script/events/DanceEvent.lua")
dofile("script/events/SpecialRoom2.lua")
dofile("script/events/PigRace.lua")
