public void SetTransit(CelestialObject targetBody, int warpSpeed, int startTurn, Config conf)
		{
			var start = GetPosition(startTurn, conf.SecondsPerTurn); // init from locations and time
			if (OrbitsObjectID != null) FromObjectID = OrbitsObjectID;
			else FromObjectID = null;
			StartBattleTurn = startTurn;
			CelestialObjectByToObjectID = targetBody;
			FromX = (float)start.X;
			FromY = (float)start.Y;
			Warp = warpSpeed;

			if (FromObjectID == ToObjectID) throw new ApplicationException("Invalid order - from == to");

			var turn = startTurn + 1;

			var failSafe = 1000;
			Position dest;
			do
			{
				dest = targetBody.GetPosition(turn*conf.SecondsPerTurn, conf.SecondsPerTurn);
				var vector = dest - start;
				var curPos = vector.Normalized()*(conf.WarpDistance*warpSpeed*(turn - startTurn));
				var targetToCur = curPos - dest;
				if (targetToCur.X/vector.X >= 0 && targetToCur.Y/vector.Y >= 0) break; // we are "past" target
				turn++;
			} while (failSafe-- > 0);

			if (failSafe == 0) throw new ApplicationException("Erro in fleet settransit logic");

			EndBattleTurn = turn;
			ToX = (float)dest.X;
			ToY = (float)dest.Y;

		}
 partial void DeleteCelestialObject(CelestialObject instance);
 partial void UpdateCelestialObject(CelestialObject instance);
 partial void InsertCelestialObject(CelestialObject instance);
		private void detach_CelestialObjects(CelestialObject entity)
		{
			this.SendPropertyChanging();
			entity.Player = null;
		}
		private void attach_CelestialObjects(CelestialObject entity)
		{
			this.SendPropertyChanging();
			entity.CelestialObject1 = this;
		}
		public Position GetCurrentPosition(CelestialObject body)
		{
			var conf = GetConfig();
			return body.GetPosition(conf.GameSecond, conf.SecondsPerTurn);
		}
        public Position GetCurrentPosition(CelestialObject body)
        {
            var conf = GetConfig();

            return(body.GetPosition(conf.GameSecond, conf.SecondsPerTurn));
        }
		private void detach_ChildCelestialObjects(CelestialObject entity)
		{
			this.SendPropertyChanging();
			entity.ParentCelestialObject = null;
		}
		private CelestialObject GetRandomObject(CelestialObjectType fromType) {
			var o = new CelestialObject();


			o.OrbitInitialAngle = random.NextDouble()*2*Math.PI;

			o.CelestialObjectType = random.Next(3 - (int)fromType) +  fromType+1;

			switch (o.CelestialObjectType) {
				case CelestialObjectType.Planet:
					o.MetalDensity = random.Next(2,16)/10;
					o.FoodDensity = random.Next(0,21)/10;
					o.Size = random.Next(3,7);
					break;

				case CelestialObjectType.Moon:
					o.MetalDensity = random.Next(3,22) / 10;
					o.FoodDensity = random.Next(0,10) / 10;
					o.Size = random.Next(2,5);
					break;

				case CelestialObjectType.Asteroid:
					o.MetalDensity = random.Next(5,35) / 10;
					o.FoodDensity = random.Next(0,5) / 10;
					o.Size = random.Next(1, 4);
					break;
			}
			return o;
		}
		public CelestialObject CreateHomeworld(CelestialObject star) {
			CelestialObject o = new CelestialObject();
			var cnt = o.ChildCelestialObjects.Count;
			o.CelestialObjectType = CelestialObjectType.Planet;
			o.MetalDensity = 1;
			o.FoodDensity = 1;
			o.Size = 5;
			o.Name = string.Format("{0} {1}", star.Name, ToRoman(cnt + 1));

			o.OrbitInitialAngle = random.NextDouble() * 2 * Math.PI;

			o.OrbitDistance = o.ChildCelestialObjects.Max(x => (double?)x.OrbitDistance)??0 +GaussianRandom(5, 15);
			o.OrbitSpeed = 1/o.OrbitDistance/100;
			o.OrbitSpeed = o.OrbitSpeed * (1 + GaussianRandom(-30, 30) / 100);
			star.ChildCelestialObjects.Add(o);
			return o;
		}