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; }
public Config GetConfig() { if (lastConfig != null) return lastConfig; var c = Configs.FirstOrDefault(); if (c == null) { c = new Config(); Configs.InsertOnSubmit(c); } lastConfig = c; return c; }
partial void DeleteConfig(Config instance);
partial void UpdateConfig(Config instance);
partial void InsertConfig(Config instance);