levelDesc = "Red Dwarf"

maxPlayers = 6
player = {}

player[0] = {
  id = 0,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

player[1] = {
  id = 1,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

player[2] = {
  id = 2,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

player[3] = {
  id = 3,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

player[4] = {
  id = 4,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

player[5] = {
  id = 5,
  name = "",
  resources = 1500,
  raceID = 1,
  startPos = 1,
}

function DetermChunk()
	setWorldBoundsInner({0, 0, 0}, {1000000, 1000000, 1000000})
	addPoint("StartPos0", {-30000.5, 0, 0}, {0, 90, 0})
  	addPoint("StartPos1", {-22000.5, 0, 30641.4814}, {0, 145, 0})
  	addPoint("StartPos2", {-22000.5, 0, -30641.4814}, {0, 30, 0})
  	addPoint("StartPos3", {30000.5, 0, 0}, {0, -90, 0})
  	addPoint("StartPos4", {22000.5, 0, -30641.4814}, {0, -40, 0})
  	addPoint("StartPos5", {22000.5, 0, 30641.4814}, {0, -135, 0})
	-- red radiation nebula
	local rdist =
	{
		starw = 2,
		starr = 4,
		starb = 1,
		staro = 3,
		stary = 2,
		stardim = 6,
		stardim2 = 4,
	}

	ringSphereShellAdd({0, 0, 0,}, rdist, 2500, 900000000, 500, 360, 360)
end


function NonDetermChunk()

	fogSetActive(0)
	setGlareIntensity(0.4)
	fogSetColour(0, 0, 0, 1)
	fogSetStart(1000)
	fogSetEnd(50000)
	fogSetType("linear")
	fogSetDensity(1)
	setDustCloudAmbient({ 0.5, 0, 0, 0.5, })
	setLevelShadowColour(0.5, 0, 0, .1)
	loadBackground("darkred")
	setSensorsManagerCameraDistances(5000, 500000)
end

function ringSphereShellAdd(tPosition, rDistribution, iNumResources, fAxis1, fWidth, fArc, farx)
	local rel = 0
	for k, iCount in rDistribution do
		rel = rel + iCount
	end
	local num = floor(iNumResources/rel)
	for k, iCount in rDistribution do
		for i = 1, num*iCount do
			local majA = fAxis1
			local theta = random(0, fArc)
			local phi = random(0, farx)
			local radiusV = majA + random(fWidth/-2, fWidth/2)
			local deltaX = radiusV * cos(phi-20) * sin(theta-20) 
			local deltaY = radiusV * sin(phi) 
			local deltaZ = radiusV * cos(phi) * cos(theta)
			addPebble(k, {tPosition[1] + deltaX, tPosition[2] + deltaZ, tPosition[3] + deltaY,}, 0, 0, 0)
		end
	end
end