Пример #1
0
            public static ObjectBuilder<SolarSystem> Build(StarCluster starCluster, SolarSystemState state)
            {
                var solarSystem = new SolarSystem
                {
                    Id = state.ObjectId,
                    Name = state.Name,
                    Position = new Position(starCluster, state.LocalCoordinates),
                };

                var builder = new ObjectBuilder<SolarSystem>(solarSystem)
                    .Resolve((target, resolver) => BuildOrbits(state, target));

                builder
                    .Dependents(state.Ships)
                    .Build(Echo.Ships.Ship.Builder.Build)
                    .Resolve((resolver, target, dependent) => target.Ships.Add(dependent));

                builder
                    .Dependents(state.JumpGates)
                    .Build(Echo.JumpGates.JumpGate.Builder.Build)
                    .Resolve((resolver, target, dependent) => target.JumpGates.Add(dependent));

                builder
                    .Dependents(state.Satellites)
                    .Build((target, dependent) => CelestialObject.Builder.For(dependent).Build(solarSystem))
                    .Resolve((resolver, target, dependent) => target.Satellites.Add(dependent));

                builder
                    .Dependents(state.Structures)
                    .Build((target, dependent) => Structure.Builder.For(dependent).Build(solarSystem))
                    .Resolve((resolver, target, dependent) => target.Structures.Add(dependent));

                return builder;
            }
Пример #2
0
 /// <summary>
 /// Creates IMovableGameObject by the given typeName and arguments. 
 /// Inserts the object to given SolarSystem and registers it in HitTest.
 /// </summary>
 /// <param name="typeName">The type of the creating object.</param>
 /// <param name="args">The arguments of the creating object.</param>
 /// <param name="solSyst">The creating object SolarSystem.</param>
 /// <returns>Returns created IMovableGameObject.</returns>
 public IMovableGameObject CreateImgo(string typeName, object[] args, SolarSystem solSyst)
 {
     IMovableGameObject imgo = xmlLoader.CreateIMGO(typeName, args);
     solSyst.AddIMGO(imgo);
     Game.HitTest.RegisterIMGO(imgo);
     return imgo;
 }
Пример #3
0
 /// <summary>
 /// Creates IStaticGameObject by the given typeName and arguments. 
 /// Inserts the object to given SolarSystem and registers it in HitTest.
 /// </summary>
 /// <param name="typeName">The type of the creating object.</param>
 /// <param name="args">The arguments of the creating object.</param>
 /// <param name="solSyst">The creating object SolarSystem.</param>
 /// <returns>Returns created IStaticGameObject.</returns>
 public IStaticGameObject CreateIsgo(string typeName, object[] args, SolarSystem solSyst)
 {
     IStaticGameObject isgo = xmlLoader.CreateISGO(typeName, args);
     solSyst.AddISGO(isgo);
     Game.HitTest.RegisterISGO(isgo);
     return isgo;
 }
Пример #4
0
 private void MoveFleetToSolarSystem(SolarSystem system)
 {
     if (selectedFleet != null)
     {
         selectedFleet.MoveToSolarSystem(system);
     }
 }
Пример #5
0
 public void ArriveAtSolarSystem(SolarSystem arriveSystem)
 {
     arriveSystem.AddFleet(this);
     currentSolarSystem = arriveSystem;
     destinationSolarSystem = null;
     this.transform.position = arriveSystem.transform.position;
 }
Пример #6
0
        /// <summary>
        /// Gets the best possible path (approximate solution) using a A* alogrithm.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="target"></param>
        /// <param name="criteria"></param>
        /// <param name="minSecurityLevel">The minimum, inclusive, security level.</param>
        /// <param name="maxSecurityLevel">The maximum, inclusive, security level.</param>
        /// <returns></returns>
        private static PathFinder FindBestPathCore(SolarSystem start, SolarSystem target, PathSearchCriteria criteria,
            float minSecurityLevel, float maxSecurityLevel)
        {
            Dictionary<SolarSystem, int> bestDepths = new Dictionary<SolarSystem, int>();
            SortedList<int, PathFinder> paths = new SortedList<int, PathFinder>();
            PathFinder root = new PathFinder(start);
            bestDepths.Add(start, -1);
            paths.Add(0, root);

            while (true)
            {
                if (paths.Count == 0)
                    return null;

                PathFinder best;
                int depth;

                // Pick the best candidate path, but ensures it matches the best depth found so far
                while (true)
                {
                    // Picks the best one, returns if we found our target
                    best = paths.Values[0];

                    if (best.m_system == target)
                        return best;

                    // Removes it from the list
                    paths.RemoveAt(0);

                    int bestDepth;
                    depth = best.Depth;
                    bestDepths.TryGetValue(best.m_system, out bestDepth);

                    if (bestDepth == depth || best.m_system == start)
                        break;
                }

                // Gets the subpaths for the best path so far
                depth++;
                foreach (PathFinder child in best.GetChildren(depth, bestDepths))
                {
                    // Gets the heuristic key based on path search criteria
                    int criteriaValue = criteria == PathSearchCriteria.ShortestDistance
                        ? child.m_system.GetSquareDistanceWith(target)
                        : 1;
                    int key = criteriaValue * depth * depth;
                    if (child.m_system.SecurityLevel < minSecurityLevel || child.m_system.SecurityLevel > maxSecurityLevel)
                        key *= 100;

                    while (paths.ContainsKey(key))
                    {
                        key++;
                    }

                    // Stores it in the sorted list
                    paths.Add(key, child);
                }
            }
        }
Пример #7
0
 public void ArriveAtPlanet(Planet planet)
 {
     planet.AddFleet(this);
     currentPlanet = planet;
     currentSolarSystem = planet.solarSystem;
     destinationPlanet = null;
     this.transform.position = planet.transform.position;
 }
Пример #8
0
        public int GetJumpCount(SolarSystem from, SolarSystem to)
        {
            JumpEntry entry;
            if (_jumpCountTable.TryGetValue(from, out entry))
                return entry.GetJumpCount(to);

            throw new ItemNotFoundException("Solar System", from);
        }
        public static void OldWay()
        {
            var system = new SolarSystem();
            system[1] = "Mercury";
            system[3] = "Earth";
            system[6] = "Saturn (I guess)";

            system.Dump("Old way");
        }
Пример #10
0
 void HoverOverSolarSystem(SolarSystem solarSystem)
 {
     if (hoverSolarSystem != null && hoverSolarSystem != solarSystem)
     {
         //leave old solar system
         hoverSolarSystem.OnHoverLeave();
     }
     hoverSolarSystem = solarSystem;
 }
Пример #11
0
 /// <summary>
 /// Creates traveler from its current SolarSystem to new given SolarSystem.
 /// Object is removed and insert to new one by Traveler class.
 /// Also playes travel sound.
 /// </summary>
 /// <param name="from">The current object SolarSystem.</param>
 /// <param name="to">The future object SolarSystem.</param>
 /// <param name="gameObject">The traveling game object.</param>
 public static void CreateTraveler(SolarSystem from, SolarSystem to, object gameObject)
 {
     if (gameObject is IMovableGameObject) {
         if (from != to) {
             IMovableGameObject imgo = (IMovableGameObject)gameObject;
             Game.IEffectPlayer.PlayEffect(travelSound);
             travelerList.Add(new Traveler(from, to, (IMovableGameObject)imgo));
         }
     }
 }
Пример #12
0
 public void AddSystem(SolarSystem s)
 {
     SolarSystemsById.Add(s.Id, s);
     SolarSystemsByName.Add(s.Name, s);
     if (!RegionsById.ContainsKey(s.Region.Id))
     {
         RegionsById.Add(s.Region.Id, s.Region);
     }
     s.Region.Systems.Add(s);
 }
Пример #13
0
    public bool CreateStartingPlanet(CampaignFaction faction, SolarSystem system)
    {
        if (system.planets.Count == 0)
        {
            return false;
        }

        system.AddStationToPlanet(system.planets[Random.Range(0, system.planets.Count - 1)], faction);
        return true;
    }
Пример #14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="contract">The contract.</param>
        /// <exception cref="System.ArgumentNullException">contract</exception>
        public ContractDetailsWindow(Contract contract)
            : this()
        {
            contract.ThrowIfNull(nameof(contract));

            RememberPositionKey = "ContractDetailsWindow";
            m_startingSize = new Size(Width, Height);
            m_contract = contract;
            m_contractItems = contract.ContractItems;
            m_characterLastSolarSystem = m_contract.Character.LastKnownSolarSystem;
        }
        public static void NewWay()
        {
            var system = new SolarSystem()
            {
                [1] = "Mercury",
                [3] = "Earth",
                [6] = "Saturn (I guess)"
            };

            system.Dump("New way");
        }
Пример #16
0
 public static SolarSystemState Save(SolarSystem solarSystem)
 {
     return new SolarSystemState
     {
         ObjectId = solarSystem.Id,
         Name = solarSystem.Name,
         LocalCoordinates = solarSystem.Position.LocalCoordinates,
         Satellites = solarSystem.Satellites.Save(),
         Structures = solarSystem.Structures.Save(),
         Ships = solarSystem.Ships.Save(),
     };
 }
Пример #17
0
        /// <summary>
        /// Gets the best possible path (approximate solution) using a A* alogrithm.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="target"></param>
        /// <param name="minSecurityLevel">The mininmum, inclusive, security level.</param>
        /// <returns></returns>
        public static List<SolarSystem> FindBestPath(SolarSystem start, SolarSystem target, float minSecurityLevel)
        {
            var result = FindBestPathCore(start, target, minSecurityLevel);

            // Transforms the result into a list
            var list = new List<SolarSystem>();
            for (var item = result; item != null; item = item.m_parent)
            {
                list.Insert(0, item.m_system);
            }

            return list;
        }
Пример #18
0
 public void TestCaseSetUp()
 {
     Region r = new Region(1);
     one = new SolarSystem(1, "One", r, 1.0f);
     two = new SolarSystem(2, "Two", r, 0.9f);
     three = new SolarSystem(3, "Three", r, 0.8f);
     zero = new SolarSystem(0, "Zero", r, 0.0f);
     one.AddGateTo(two);
     two.AddGateTo(one);
     two.AddGateTo(three);
     three.AddGateTo(two);
     three.AddGateTo(one); // you can go from three to one, but not one to three
     // there are no gates to or from zero
 }
Пример #19
0
        public void CanUndockWithShipSkill()
        {
            var solarSystem = new SolarSystem();
            var structure = new Manufactory { Position = new Position(solarSystem, Vector.Parse("0,1,0")) };
            var ship = new Ship { Position = new Position(structure, Vector.Zero), ShipInfo = GetShipInfo() };
            var pilot = new Agent { Skills = { { SkillCode.SpaceshipCommand, new Echo.Agents.Skills.SkillLevel { Level = 5 } } } };

            _task.SetParameters(new UndockShipParameters(ship, pilot));

            var result = _task.Execute();
            Assert.That(result.Success, Is.True, result.StatusCode);
            Assert.That(ship.Position.LocalCoordinates, Is.EqualTo(structure.Position.LocalCoordinates));
            Assert.That(ship.Position.Location, Is.EqualTo(solarSystem));
        }
Пример #20
0
        /// <summary>
        /// Gets the best possible path (approximate solution) using a A* alogrithm.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="target"></param>
        /// <param name="criteria"></param>
        /// <param name="minSecurityLevel">The minimum, inclusive, security level.</param>
        /// <param name="maxSecurityLevel">The maximum, inclusive, security level.</param>
        /// <returns></returns>
        public static IEnumerable<SolarSystem> FindBestPath(SolarSystem start, SolarSystem target, PathSearchCriteria criteria,
            float minSecurityLevel, float maxSecurityLevel)
        {
            PathFinder result = FindBestPathCore(start, target, criteria, minSecurityLevel, maxSecurityLevel);

            // Transforms the result into a list
            List<SolarSystem> list = new List<SolarSystem>();
            for (PathFinder item = result; item != null; item = item.m_parent)
            {
                list.Insert(0, item.m_system);
            }

            return list;
        }
Пример #21
0
 public void TestCaseSetUp()
 {
     map = TestObjectFactory.CreateMap();
     highSec1 = map.GetSystem("HighSec1");
     highSec2 = map.GetSystem("HighSec2");
     highSec3 = map.GetSystem("HighSec3");
     highSec4 = map.GetSystem("HighSec4");
     highSec5 = map.GetSystem("HighSec5");
     highSec6 = map.GetSystem("HighSec6");
     deadEnd1 = map.GetSystem("DeadEnd1");
     lowSec1 = map.GetSystem("LowSec1");
     lowSec2 = map.GetSystem("LowSec2");
     highSecIsolated1 = map.GetSystem("HighSecIsolated");
     isolated1 = map.GetSystem("Isolated1");
 }
Пример #22
0
  public Galaxy()
  {

    // Init all solar systems
    m_systems = new SolarSystem[numSystems];
    for (int i = 0; i < numSystems; ++i)
    {
      m_systems[i] = new SolarSystem();
    }

    // Find system coordinates
    SplatSystems(gridSize);
    // Generate lists of neighbours
    FindNeighbours();

  }
Пример #23
0
            public static ObjectBuilder<JumpGate> Build(SolarSystem location, JumpGateState state)
            {
                var jumpGate = new JumpGate
                {
                    Id = state.ObjectId,
                    Name = state.Name,
                    Position = new Position(location, state.LocalCoordinates),
                };

                return new ObjectBuilder<JumpGate>(jumpGate)
                    .Resolve(
                        (resolver, target) =>
                        target.ConnectsTo = state.ConnectsTo == 0
                                                ? null
                                                : resolver.GetById<JumpGate>(state.ConnectsTo)
                    );
            }
Пример #24
0
        /// <summary>
        /// Gets the best possible path (approximate solution) using a A* alogrithm.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="target"></param>
        /// <param name="minSecurityLevel">The mininmum, inclusive, security level.</param>
        /// <returns></returns>
        private static PathFinder FindBestPathCore(SolarSystem start, SolarSystem target, float minSecurityLevel)
        {
            var bestDepthes = new Dictionary<SolarSystem, int>();
            var paths = new SortedList<float, PathFinder>();
            PathFinder root = new PathFinder(start);
            bestDepthes.Add(start, -1);
            paths.Add(0, root);

            while (true)
            {
                if (paths.Count == 0) return null;
                PathFinder best = null;
                int depth = 0;

                // Pick the best candidate path, but ensures it matches the best depth found so far
                while (true)
                {
                    // Picks the best one, returns if we found our target
                    best = paths.Values[0];
                    if (best.m_system == target) return best;

                    // Removes it from the list
                    paths.RemoveAt(0);

                    int bestDepth;
                    depth = best.Depth;
                    bestDepthes.TryGetValue(best.m_system, out bestDepth);
                    if (bestDepth == depth || best.m_system == start) break;
                }

                // Gets the subpaths for the best path so far.
                depth++;
                foreach (var child in best.GetChildren(depth, bestDepthes))
                {
                    // Gets the heuristic key: the shorter, the better the candidate.
                    var key = child.m_system.GetSquareDistanceWith(target) * (float)(depth * depth);
                    if (child.m_system.SecurityLevel < minSecurityLevel) key *= 100.0f;
                    while (paths.ContainsKey(key)) key++;

                    // Stores it in the sorted list.
                    paths.Add(key, child);
                }
            }

        }
        public static IEnumerable<SolarSystem> DijkstrasJumpAlgorithm(SolarSystem startSystem, SolarSystem endSystem, float shipJumpRange)
        {
            //Get all system in the universe life and everything
            List<SolarSystem> _fullSystems = GetSystems();

            //The complete path
            List<long> shortestPath = new List<long>();
            List<SolarSystem> shortestPathSystems = new List<SolarSystem>();

            //Adds the start system to array, not needed but nice to know where your coming from
            shortestPath.Add(startSystem.SolarSystemID);

            //Set the "active" node to the start
            SolarSystem currentNode = startSystem;
            while (true)
            {
                //Get all systems within jump range, can be swapped with GetSystemNeighbours function to get directly connected nodes
                List<SolarSystem> currentNodeNeighbours = GetSystemsInJumpRange(_fullSystems, currentNode, shipJumpRange);
                //If the system in the neighbours has been added to the complete route, ignore it. Were not backtracking
                IEnumerable<SolarSystem> unresolvedNeighbours = from system in currentNodeNeighbours
                                                                where !shortestPath.Contains(system.SolarSystemID)
                                                                select system;

                //No  neighbours left? .. Welp we have hit a dead end.
                if (unresolvedNeighbours.Count() == 0)
                    break;
                //If the neighbour system list has the end desto in it, we have made it!
                if (unresolvedNeighbours.Select(x => x.SolarSystemID).Contains(endSystem.SolarSystemID))
                {
                    shortestPath.Add(endSystem.SolarSystemID);
                    break;
                }

                //If we get this far, the destination has not been met, so get the next nearest node to end, and repeat
                SolarSystem nextAdjacentNode = GetNearestSystem(unresolvedNeighbours.ToList(), endSystem);

                //Add the next node to the complete path as it is where we are going next on our stepping stone journey.
                shortestPath.Add(nextAdjacentNode.SolarSystemID);
                currentNode = nextAdjacentNode;
            }
            foreach (long systemID in shortestPath)
                shortestPathSystems.Add(_fullSystems.Where(x => x.SolarSystemID == systemID).FirstOrDefault());
            return shortestPathSystems;
        }
Пример #26
0
		public void SetUp()
		{
			_a = new SolarSystem { Name = "A" };
			_b = new SolarSystem { Name = "B" };
			_c = new SolarSystem { Name = "C" };
			_d = new SolarSystem { Name = "D" };
			_e = new SolarSystem { Name = "E" };
			_f = new SolarSystem { Name = "F" };
			_g = new SolarSystem { Name = "G" };
			_solarSystems = new[] { _a, _b, _c, _d, _e, _f, _g, };

			var fields = GetFields();
			var states = 
					fields.Values
					.Where(x => x.FieldType == typeof (JumpGate))
					.Select((f, i) => new JumpGateState { Name = f.Name, ObjectId = (ulong)(i + 1), ConnectsTo = 0 })
					.ToArray();

			SetConnections(states.ToDictionary(s => s.Name));

			var register = new JumpGateRegister();
			var builders = new List<ObjectBuilder<JumpGate>>();
			
			foreach (var state in states)
			{
				var solarSystem = (SolarSystem) fields[state.Name.Substring(0, 2)].GetValue(this);
				var builder = JumpGate.Builder.Build(solarSystem, state);
				register.Register(builder.Target);

				builders.Add(builder);
			}

			foreach (var builder in builders)
			{
				var jumpGate = builder.Build(register);
				fields[builder.Target.Name].SetValue(this, jumpGate);
				jumpGate.SolarSystem.JumpGates.Add(jumpGate);
			}

			foreach ( var x in _solarSystems.Select((s, i) => new { s, i }) )
			{
				x.s.Id = (ulong)(x.i + 10);
			}
		}
Пример #27
0
    public void OpenSolarSystemFile()
    {
        string loadedFile = "";

        StandaloneFileBrowser.OpenFilePanelAsync("Open World File",
                                                 "",
                                                 "",
                                                 false,
                                                 paths => {
            if (!string.IsNullOrEmpty(paths[0]))
            {
                loadedFile = File.ReadAllText(paths[0]);
            }
        });
        loadedSolarSystem = ValidateSolarSystem(loadedFile);
        if (loadedSolarSystem != null)
        {
            openDialog.SetActive(true);
        }
    }
        public SolarSystem LoadGalaxy()
        {
            SolarSystem   Sol        = new SolarSystem();
            SqlConnection connection = new SqlConnection(Settings.GetSQLConnectionString());

            using (connection)
            {
                connection.Open();
                SqlCommand    command = new SqlCommand("Select Name from Planets", connection);
                SqlDataReader Reader  = command.ExecuteReader();
                while (Reader.Read())
                {
                    Sol.Planets.Add(new Planet {
                        Name = Reader.GetString(0)
                    });
                }
                connection.Close();
            }
            return(Sol);
        }
Пример #29
0
        /// <summary>
        /// Creates instance at given position and traveling to given target (position).
        /// </summary>
        /// <param name="position">The bullet start position.</param>
        /// <param name="solSystem">The bullet SolarSystem.</param>
        /// <param name="targetPosition">The taget position.</param>
        /// <param name="rec">The bullet't hit reciever.</param>
        public Missile2(Vector3 position, SolarSystem solSystem, Vector3 targetPosition, IBulletStopReciever rec)
        {
            this.position    = position;
            this.name        = Game.IGameObjectCreator.GetUnusedName(typeof(Missile2).ToString());
            this.solarSystem = solSystem;
            this.reciever    = rec;

            // Calucalates a distance and a direction.
            direction = targetPosition - position;
            distance  = direction.Normalise();

            // Registers IBullet and SolarSystem set visibility.
            solarSystem.AddIBullet(this);

            // Caluculate constants for hidden collision.
            a = -(targetPosition.z - position.z);
            b = (targetPosition.x - position.x);
            c = -a * targetPosition.x - b * targetPosition.z;
            destinationDevider = (float)System.Math.Sqrt(a * a + b * b);
        }
Пример #30
0
        /// <summary>
        /// Creates instance at given position and traveling to given target (position).
        /// </summary>
        /// <param name="position">The bullet start position.</param>
        /// <param name="solSystem">The bullet SolarSystem.</param>
        /// <param name="targetPosition">The taget position.</param>
        /// <param name="rec">The bullet't hit reciever.</param>
        public Missile2(Vector3 position, SolarSystem solSystem, Vector3 targetPosition, IBulletStopReciever rec)
        {
            this.position = position;
            this.name = Game.IGameObjectCreator.GetUnusedName(typeof(Missile2).ToString());
            this.solarSystem = solSystem;
            this.reciever = rec;

            // Calucalates a distance and a direction.
            direction = targetPosition - position;
            distance = direction.Normalise();

            // Registers IBullet and SolarSystem set visibility.
            solarSystem.AddIBullet(this);

            // Caluculate constants for hidden collision.
            a = -(targetPosition.z - position.z);
            b = (targetPosition.x - position.x);
            c = -a * targetPosition.x - b * targetPosition.z;
            destinationDevider = (float)System.Math.Sqrt(a * a + b * b);
        }
Пример #31
0
    public void Load()
    {
        // Load Player Information
        BinaryFormatter bf = new BinaryFormatter();

        FileStream file = File.Open(Application.persistentDataPath + "/player.dat", FileMode.Open);

        pData = bf.Deserialize(file) as PlayerData;
        file.Close();

        SurrogateSelector             surrogateSelector = new SurrogateSelector();
        Vector2SerializationSurrogate vector2SS         = new Vector2SerializationSurrogate();

        surrogateSelector.AddSurrogate(typeof(Vector2), new StreamingContext(StreamingContextStates.All), vector2SS);
        bf.SurrogateSelector = surrogateSelector;

        file  = File.Open(Application.persistentDataPath + "/solar_system.dat", FileMode.Open);
        sData = bf.Deserialize(file) as SolarSystem;
        file.Close();
    }
Пример #32
0
        public FormMain()
        {
            InitializeComponent();

            Rectangle bounds = Screen.AllScreens.Last().Bounds;

            Top   = bounds.Top;
            Left  = bounds.Left;
            Width = bounds.Width;

            _CitadelLogs = new DataTable();
            _CitadelLogs.Columns.Add("Text", typeof(string));
            _CitadelLogs.Columns.Add("System", typeof(string));

            dataGridIntel.DataSource = _CitadelLogs;

            logWatcherIntel.LogName         = Settings.Default.intelLogName;
            comboLogs.DataSource            = LogWatcher.GetLogNames();
            comboLogs.SelectedItem          = Settings.Default.intelLogName;
            comboLogs.SelectedIndexChanged += comboLogs_SelectedIndexChanged;

            numMaxVisibleSystems.Value         = Settings.Default.maxVisibleSystems;
            numMaxVisibleSystems.ValueChanged += numMaxVisibleSystems_ValueChanged;

            _ComboBoxSystemsSetValue   = true;
            comboBoxSystems.DataSource = DbHelper.DataContext.SolarSystems.ToArray();
            _ComboBoxSystemsSetValue   = false;
            if (Settings.Default.currentSystemId != 0)
            {
                SolarSystem solarSystem = DbHelper.DataContext.SolarSystems.First(o => o.Id == Settings.Default.currentSystemId);
                map.CurrentSystemName        = solarSystem.SolarSystemName;
                _ComboBoxSystemsSetValue     = true;
                comboBoxSystems.SelectedItem = solarSystem;
                _ComboBoxSystemsSetValue     = false;
            }


            hotkeyControlKosCheck.Hotkey          = Settings.Default.kosCheckKey & ~cModifiers;
            hotkeyControlKosCheck.HotkeyModifiers = Settings.Default.kosCheckKey & cModifiers;
            InitHook();
        }
Пример #33
0
        private static void ImportSolarSystems()
        {
            MassDefectContext            context      = new MassDefectContext();
            string                       json         = File.ReadAllText(Constants.SolarSystemsPath);
            IEnumerable <SolarSystemDTO> solarSystems = JsonConvert.DeserializeObject <IEnumerable <SolarSystemDTO> >(json);

            foreach (var solarSystem in solarSystems)
            {
                if (solarSystem.Name == null)
                {
                    Console.WriteLine(Constants.ErrorMessage);
                    continue;
                }

                var solarSystemEntity = new SolarSystem(solarSystem.Name);
                context.SolarSystems.Add(solarSystemEntity);
                context.SaveChanges();

                Console.WriteLine(Constants.SuccessMessage, "Solar system", solarSystem.Name);
            }
        }
Пример #34
0
    public void ShowSolarSystem(int solarSystemID)
    {
        // First, clean up the solar system by deleting any old graphics.
        while (transform.childCount > 0)
        {
            Transform c = transform.GetChild(0);
            c.SetParent(null);
            Destroy(c.gameObject);
        }

        orbitalGameObjectMap = new Dictionary <Orbital, GameObject> ();

        solarSystem = gc.Galaxy.SolarSystems [solarSystemID];

        // Spawn a graphic for each object in the solar system.
        for (int i = 0; i < solarSystem.Children.Count; i++)
        {
            //Orbital o = solarSystem.Children [i];
            MakeSpritesForOrbital(this.transform, solarSystem.Children[i]);
        }
    }
Пример #35
0
    private bool RayCastForSystem(Ray ray)
    {
        RaycastHit raycastHit;
        bool       potentialEnemyHit = Physics.Raycast(ray, out raycastHit, maxRaycastDepth);

        if (potentialEnemyHit) // if hit no priority object
        {
            SolarSystem system = raycastHit.collider.gameObject.GetComponent <SolarSystem>();
            if (!system)
            {
                system = raycastHit.transform.GetComponentInParent <SolarSystem>();
            }
            if (system)
            {
                Cursor.SetCursor(systemCursor, cursorHotspot, CursorMode.Auto);
                onMouseOverSystem(system);
                return(true);
            }
        }
        return(false);
    }
Пример #36
0
    private void GenerateSolarSystem()
    {
        ClearSolarSystem();

        SolarSystem curSolarSystem = ConstellationHandler.Constellation.SolarSystems[ShipHandler.Instance.ActiveShip.Position.SolarID];

        SolarsystemNameDisplay.text = curSolarSystem.Name;

        CreateSun(curSolarSystem.Sun);

        foreach (var planet in curSolarSystem.Planets)
        {
            CreatePlanet(planet);
        }

        CreateStargates(curSolarSystem);

        CreateShip();

        CreateAIShips();
    }
 public static SolarSystem BuildSolarSystem(ref SQLiteDataReader reader)
 {
     SolarSystem solarSystem = new SolarSystem()
     {
         RegionID = Convert.ToInt32(reader["RegionID"]),
         ConstellationID = Convert.ToInt32(reader["ConstellationID"]),
         SolarSystemID = Convert.ToInt32(reader["SolarSystemID"]),
         SolarSystemName = reader["SolarSystemName"].ToString(),
         X = Convert.ToDecimal(reader["x"]),
         Y = Convert.ToDecimal(reader["y"]),
         Z = Convert.ToDecimal(reader["z"]),
         xMax = Convert.ToDecimal(reader["xMax"]),
         xMin = Convert.ToDecimal(reader["xMin"]),
         yMax = Convert.ToDecimal(reader["yMax"]),
         yMin = Convert.ToDecimal(reader["yMin"]),
         zMax = Convert.ToDecimal(reader["zMax"]),
         zMin = Convert.ToDecimal(reader["zMin"]),
         Security = Convert.ToDecimal(reader["security"])
     };
     return solarSystem;
 }
Пример #38
0
        public void HandleMessage(GoToWarpMessage msg, object extra)
        {
            Client client = (Client)extra;

            msg.Rotation = client.Player.Rotation;

            Vector3 systemPos = client.Player.SolarSystem.Pos;
            Vector3 startPos  = new Vector3(systemPos.X * Galaxy.EXPAND_FACTOR, systemPos.Y * Galaxy.EXPAND_FACTOR, systemPos.Z * Galaxy.EXPAND_FACTOR);

            startPos         += Vector3.Transform(Vector3.Forward * .3f, client.Player.Rotation);
            client.Player.Pos = startPos;

            //client has left, clear em out
            SolarSystem system = client.Player.SolarSystem;

            MoveClientToWarp(client);

            msg.Pos = client.Player.Pos;

            GalaxyServer.AddToSendQueue(client, msg);
        }
Пример #39
0
        public bool LoadUnloadedSolarSystems()
        {
            // Get all the solarSystems not loaded and load them
            List <int> solarSystems = this.mGeneralDB.GetUnloadedSolarSystems();

            // Load the not-loaded solar systems
            foreach (int solarSystemID in solarSystems)
            {
                // create the solar system object
                SolarSystem solarSystem = new SolarSystem(
                    this.mItemFactory.ItemDB.LoadItem(solarSystemID),
                    this.mItemFactory.ItemDB.GetSolarSystemInfo(solarSystemID)
                    );

                if (LoadSolarSystem(solarSystem) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
        public void AddStarsInRange(IEnumerable <IStarDto> stars)
        {
            IList <Star> starEntities = new List <Star>();

            IList <IStarDto> starDtos = stars.ToList();

            foreach (IStarDto starDto in starDtos)
            {
                int?sollarSystemId;
                if (starDto.SollarSystemId == null)
                {
                    SolarSystem sollarSystem =
                        this.unitOfWork.SolarSystemsDbRepository.GetAll(ss => ss.Name == starDto.SolarSystem)
                        .FirstOrDefault();
                    if (sollarSystem == default(SolarSystem))
                    {
                        sollarSystemId = null;
                    }
                    else
                    {
                        sollarSystemId = sollarSystem.Id;
                    }
                }
                else
                {
                    sollarSystemId = int.Parse(starDto.SollarSystemId.ToString());
                }

                Star starEntity = new Star()
                {
                    Name           = starDto.Name,
                    SollarSystemId = sollarSystemId
                };

                starEntities.Add(starEntity);
            }

            this.unitOfWork.StarsDbRepository.AddRange(starEntities);
        }
        public async void UpdateWithValidData_Ok()
        {
            //Arrange
            var solarSystem = new SolarSystem
            {
                Id              = Guid.NewGuid(),
                Name            = "A-1",
                DistanceToEarth = 4.38F,
                SpacePosition   = new SpaceCoordinates(12323.54F, 53432.24F, 23131.01F)
            };

            m_repositoryMock.Setup(t => t.SearchAsync(It.IsAny <Pagination>(), It.IsAny <Ordering>(), It.IsAny <IFilter <SolarSystem> >()))
            .ReturnsAsync(new Tuple <int, List <SolarSystem> >(1, new List <SolarSystem> {
                solarSystem
            }));

            //Act
            await m_solarSystemService.UpdateSolarSystemAsync(solarSystem);

            //Assert
            m_repositoryMock.Verify(t => t.UpdateAsync(It.IsAny <SolarSystem>()), Times.Once);
        }
Пример #42
0
    private void Attack(SolarSystem system)
    {
        float defence = system.GetDefence();

        if (GetFleetStrength() <= 0)
        {
            DestroyFleet();
            return;
        }
        else
        {
            if (FightBattle(system))
            {
                system.SetEmpire(empire);
                DisbandFleet(system);
            }
            else
            {
                DestroyFleet();
            }
        }
    }
Пример #43
0
        private static void ImportSolarSystems()
        {
            var context      = new MassDefectContext();
            var json         = File.ReadAllText(SolarSystemsPath);
            var solarSystems = JsonConvert.DeserializeObject <IEnumerable <SolarSystemDTO> >(json);

            foreach (var solarSystem in solarSystems)
            {
                if (solarSystem.Name == null)
                {
                    Console.WriteLine("Error: Invalid data.");
                    continue;
                }
                var solarSystemEntity = new SolarSystem
                {
                    Name = solarSystem.Name
                };
                context.SolarSystems.Add(solarSystemEntity);
                Console.WriteLine($"Successfully imported Solar System {solarSystemEntity.Name}.");
            }
            context.SaveChanges();
        }
Пример #44
0
        public void TestMethodSuccessful()
        {
            SolarSystem       solarSystem    = new SolarSystem(new System.DateTime(2020, 5, 8, 14, 0, 0));
            LatitudeLongitude declinationGHA = BodyCoordinates.CurrentCoordinates(new LatitudeLongitude(66.101462f, 88.567594f), solarSystem.CurrentData);

            Assert.AreEqual(89.263105126223, declinationGHA.Lat, 0.000001, "déclinaison Polaris");
            Assert.AreEqual(39.312794344624, declinationGHA.Lon, 0.00001, "GHA Polaris");
            LatitudeLongitude declinationRA = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(66.101462f, 88.567594f), solarSystem.CurrentData);

            System.Diagnostics.Debug.WriteLine("déclinaison Polaris = " + declinationRA.Lat.ToString("F6") + " RA = " + declinationRA.Lon.ToString("F6"));
            //déclinaison Polaris = 89,2642550 RA Polaris = 321,7556219
            declinationRA = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(72.987596f, 133.319476f), solarSystem.CurrentData);//KOCHAB
            System.Diagnostics.Debug.WriteLine("déclinaison Kochab = " + declinationRA.Lat.ToString("F6") + " RA = " + declinationRA.Lon.ToString("F6"));
            //déclinaison Kochab = 74,155377 RA = 137,050408
            declinationRA = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(29.303462f, 301.776416f), solarSystem.CurrentData);//Altair
            System.Diagnostics.Debug.WriteLine("déclinaison Altair = " + declinationRA.Lat.ToString("F6") + " RA = " + declinationRA.Lon.ToString("F6"));
            //déclinaison Altair = 8,868497 RA = 62,030192
            declinationRA = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(-2.054489f, 203.841358f), solarSystem.CurrentData);//Spica
            System.Diagnostics.Debug.WriteLine("déclinaison Spica = " + declinationRA.Lat.ToString("F6") + " RA = " + declinationRA.Lon.ToString("F6"));
            //déclinaison Spica = -11,161515 RA = 158,427728
            declinationRA = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(68.913693f, 12.778110f), solarSystem.CurrentData);//Alderamin
            System.Diagnostics.Debug.WriteLine("déclinaison Alderamin = " + declinationRA.Lat.ToString("F6") + " RA = " + declinationRA.Lon.ToString("F6"));
            //déclinaison Alderamin = 62,585805 RA = 40,081317
            //+aberration, déclinaison Alderamin = 62,580290 RA = 40,081288
            LatitudeLongitude declinationGhaDubhe = BodyCoordinates.CurrentDeclinationGHA(new LatitudeLongitude(49.680301f, 135.197385f), solarSystem.CurrentData);//Dubhe

            System.Diagnostics.Debug.WriteLine("déclinaison Dubhe = " + declinationGhaDubhe.Lat.ToString("F6") + " GHA = " + declinationGhaDubhe.Lon.ToString("F6"));
            AltitudeAzimuth dubhe = new AltitudeAzimuth(new LatitudeLongitude(60, 30), declinationGhaDubhe);

            System.Diagnostics.Debug.WriteLine("alt Dubhe = " + dubhe.Al.ToString("F6") + " Z = " + dubhe.Az.ToString("F6"));
            //alt Dubhe = 40,385227 Z = 32,897923
            AltitudeAzimuth dubhe2 = new AltitudeAzimuth(new LatitudeLongitude(-10, -45.5), declinationGhaDubhe);

            System.Diagnostics.Debug.WriteLine("-10N-45.5E, alt Dubhe = " + dubhe2.Al.ToString("F6") + " Z = " + dubhe2.Az.ToString("F6"));
            LatitudeLongitude declinationGhaPolaris = BodyCoordinates.CurrentCoordinates(new LatitudeLongitude(66.101462f, 88.567594f), solarSystem.CurrentData);
            AltitudeAzimuth   polaris = new AltitudeAzimuth(new LatitudeLongitude(-10, -45.5), declinationGhaPolaris);

            System.Diagnostics.Debug.WriteLine("-10N-45.5E, alt Polaris = " + polaris.Al.ToString("F6") + " Z = " + polaris.Az.ToString("F6"));
        }
Пример #45
0
        public ActionResult Edit(int?id)
        {
            SolarSystem system = new SolarSystem();

            ViewBag.SourceFactions = new List <Faction>();
            using (var session = DB.Instance.GetSession())
            {
                var groups = session.Query <SolarSystemGroup>().OrderBy(x => x.Name).ToList();
                if (CommanderSystemGroups.Count > 0)
                {
                    groups.RemoveAll(x => !CommanderSystemGroups.Contains(x.Id));
                }
                ViewBag.SourceGroups = groups;

                if (id.HasValue)
                {
                    system = session.Load <SolarSystem>(id.Value);
                    ViewBag.SourceFactions = session.Query <Faction>().Where(x => x.SolarSystems.Any(s => s.Id == id.Value)).ToList();
                }
            }
            return(View(system));
        }
Пример #46
0
    void AddSystem(SolarSystem system, Coordinate coord)
    {
        Vector3 pos = new Vector3(coord.x, coord.y, 0);

        GameObject v = Instantiate(vert);

        v.transform.SetParent(transform);
        v.transform.localPosition = pos;
        v.layer = (int)AppInfo.Layer.StarMap;
        v.SetActive(true);

        v.AddComponent <SolarSystemComponent>();
        system.register(v.GetComponent <SolarSystemComponent>());


        GameObject g = new GameObject("text");

        g.transform.SetParent(v.transform);
        g.AddComponent <TextMesh>().text = system.Name;
        g.transform.localPosition        = new Vector3(0.4f, 0.4f, 0);
        g.layer = (int)AppInfo.Layer.StarMap;
    }
Пример #47
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            SolarSystemContext context    = new SolarSystemContext();
            Repository         repository = new Repository();
            StringBuilder      result     = new StringBuilder();

            var json         = File.ReadAllText(fileLocation);
            var solarSystems = JsonConvert.DeserializeObject <IEnumerable <SolarSystemDTO> >(json);

            foreach (var solarSystem in solarSystems)
            {
                string solarSystemName = solarSystem.Name;

                if (solarSystemName == null)
                {
                    result.AppendLine("Solar system name is required.");
                }
                else
                {
                    var solarSystemEntity = new SolarSystem()
                    {
                        Name = solarSystemName
                    };

                    if (repository.GetSolarSystemByName(solarSystemName, context) == null)
                    {
                        context.SolarSystems.Add(solarSystemEntity);
                        result.AppendLine($"Successfully imported Solar System {solarSystemName}.");
                    }
                    else
                    {
                        result.AppendLine("Attempt for duplicate record insertion.");
                    }
                }
            }
            Logger.Text = result.ToString();
            context.SaveChanges();
        }
Пример #48
0
        public static void LoadConfig()
        {
            var appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EveMarket\\config.xml");
            var exePath     = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "config.xml");

            if (File.Exists(exePath))
            {
                AppConfig = Files <AppConfig> .LoadXml(exePath);

                AppConfig.ActualConfigFolder = Path.GetDirectoryName(exePath);
            }
            else if (File.Exists(appDataPath))
            {
                AppConfig = Files <AppConfig> .LoadXml(appDataPath);

                AppConfig.ActualConfigFolder = Path.GetDirectoryName(appDataPath);
            }
            else
            {
                Files <AppConfig> .SaveXml(exePath, AppConfig);

                AppConfig.ActualConfigFolder = Path.GetDirectoryName(exePath);
            }

            var marketSettingsPath = Path.Combine(AppConfig.ActualConfigFolder, "MarketConfig.xml");

            if (File.Exists(marketSettingsPath))
            {
                MarketConfiguration = Files <MarketConfiguration> .LoadXml(marketSettingsPath);
            }
            else
            {
                Files <MarketConfiguration> .SaveXml(marketSettingsPath, MarketConfiguration);
            }

            SystemIds = SolarSystem.LoadFromCsv(Path.Combine(AppConfig.ActualConfigFolder, AppConfig.SystemIdsFileName));
            TypeIds   = Utility.TypeIds.GetTypeIds();
        }
Пример #49
0
    /*Function called from SolarSystem.cs (GeneratePlanets function)
     * Override of the SolarBody parent class' GenerateStats function since stars will have their own unique stats */
    public void GenerateStats(SolarSystem systemData_, Vector3 orbitDimensions_, float orbitTime_ = 1, bool spinClockwise_ = true)
    {
        base.GenerateStats(spinClockwise_);

        //Setting the XYZ dimensions of the orbit
        this.orbitDimensions = orbitDimensions_;

        //Setting the length of time of the orbit in seconds
        this.orbitTime = orbitTime_;


        //Rotates the Orbit Center for a more random look
        this.transform.Rotate(0, Random.Range(0, 360), 0);

        //Sets the displayed gameobject to the crest of it's rotation
        this.displayObject.transform.localPosition = new Vector3(this.orbitDimensions.x, this.orbitDimensions.y, this.orbitDimensions.z);

        //Sets the trail renderer data of the display object if it has the component
        if (this.displayObject.GetComponent <TrailRenderer>() != null)
        {
            this.displayObject.GetComponent <TrailRenderer>().time = 0.5f * this.orbitTime;
        }

        //Determines if this planet has water
        if (Random.value <= this.chanceOfWater)
        {
            this.hasWater = true;
        }

        //Sets this planet's mesh material to a random color from surfaceColors gradient
        this.displayObject.GetComponent <MeshRenderer>().materials[0].color = this.surfaceColors.Evaluate(Random.value);

        //Fills this planet with resources for the player to gather
        this.GenerateResources(systemData_);

        //Creates all of the moons that orbit this planet
        this.GenerateMoons();
    }
Пример #50
0
        public static void AddPlanets(IEnumerable <PlanetDto> planets)
        {
            using (MassDefectContext context = new MassDefectContext())
            {
                foreach (var planet in planets)
                {
                    // Validate input
                    if (planet.Name == null || planet.Sun == null || planet.SolarSystem == null)
                    {
                        Console.WriteLine("Error: Invalid data.");
                        continue;
                    }

                    // Validate Solar System & Sun
                    SolarSystem solarSystem = CommandHelpers.GetSolarSystemByName(context, planet.SolarSystem);
                    Star        sun         = CommandHelpers.GetSunByName(context, planet.Sun);
                    if (solarSystem == null || sun == null)
                    {
                        Console.WriteLine("Error: Invalid data.");
                        continue;
                    }

                    // Create Entity & add to DB
                    Planet planetEntity = new Planet()
                    {
                        Name          = planet.Name,
                        SunId         = sun.Id,
                        SolarSystemId = solarSystem.Id
                    };
                    context.Planets.Add(planetEntity);

                    // Success notification
                    Console.WriteLine($"Successfully imported Planet {planet.Name}.");
                }

                context.SaveChanges();
            }
        }
Пример #51
0
        private static void ImportSolarSystem()
        {
            var context      = new MassDefectContext();
            var json         = File.ReadAllText(SOLAR_SYSTEMS_ROUTE);
            var solarSystems = JsonConvert.DeserializeObject <IEnumerable <SolarSystemDTO> >(json);

            foreach (var solarSystem in solarSystems)
            {
                if (solarSystem.Name == null)
                {
                    Console.WriteLine("Error: Invalid data.");
                    continue;
                }

                var solarSystemEntity = new SolarSystem
                {
                    Name = solarSystem.Name
                };

                context.SolarSystems.Add(solarSystemEntity);
                Console.WriteLine($"Successfully imported Solar System {solarSystemEntity.Name}.");
            }

            try
            {
                context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var ms in ex.EntityValidationErrors)
                {
                    foreach (var m in ms.ValidationErrors)
                    {
                        Console.WriteLine(m.ErrorMessage);
                    }
                }
            }
        }
Пример #52
0
        private void LoadLocationInfo()
        {
            Log.DebugFormat("[Pilot.LoadLocationInfo] starting for Id = {0}", Id);

            try
            {
                if (Location == null)
                {
                    Location = new SolarSystem();
                }

                dynamic locationInfo = CrestData.GetLocation(Id);

                if (Location.Id != locationInfo.SelectToken("solarSystem.id").Value)
                {
                    Location.Id   = locationInfo.SelectToken("solarSystem.id").Value;
                    Location.Name = locationInfo.SelectToken("solarSystem.name").Value.ToString();

                    if (Location.Name.Contains("J"))
                    {
                        GetAllWormholeInformation(Location.Name.Replace("J", ""));
                    }
                    else
                    {
                        Location.ReLoad();
                        Location.Class  = "";
                        Location.Effect = "";
                    }
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("[Pilot.LoadLocationInfo] pilot Id = {0} not login in game.", Id);

                Location.Id   = 0;
                Location.Name = "unknown";
            }
        }
Пример #53
0
        public MainGameScreen()
            : base()
        {
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();

            SystemCore.AddNewUpdateRenderSubsystem(new SkyDome(Color.Black, Color.Black, Color.Black));


            ship = new Ship("ship");
            SystemCore.SetActiveCamera(ship.shipCameraObject.GetComponent <ComponentCamera>());



            Model           geoDesicModel = SystemCore.ContentManager.Load <Model>("Models/geodesic2");
            ProceduralShape geodesicShape = ModelMeshParser.GetShapeFromModelWithUVs(geoDesicModel);

            geodesicShape.Scale(1f);
            geodesicShape.InsideOut();

            ship.AddComponent(new RenderGeometryComponent(geodesicShape));
            //var cockpitEffectComponent = new EffectRenderComponent(EffectLoader.LoadEffect("cockpitscreen"));
            //cockpitEffectComponent.DrawOrder = 100;
            //ship.AddComponent(cockpitEffectComponent);

            oldPos = ship.GetComponent <HighPrecisionPosition>().Position;
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(ship);


            testPlanetSurfacePosition           = new PlanetSurfacePosition();
            testPlanetSurfacePosition.Latitude  = 40;
            testPlanetSurfacePosition.Longitude = -90;

            solarSystem            = new SolarSystem();
            solarSystem.PlayerShip = ship;
            ship.SolarSystem       = solarSystem;
            SystemCore.AddNewGameComponent(solarSystem);
            ship.Transform.Rotate(Vector3.Up, MathHelper.PiOver2);
        }
Пример #54
0
        public async Task CreateSolarSystemAsync(SolarSystem solarSystem)
        {
            try
            {
                var validationError = solarSystem.Validate();
                if (validationError.Any())
                {
                    throw new ValidationException($"A validation exception was raised while trying to create a solar system : {JsonConvert.SerializeObject(validationError, Formatting.Indented)}");
                }

                await m_repository.CreateAsync(solarSystem);
            }
            catch (ValidationException e)
            {
                m_logger.LogWarning(e, "A validation failed");
                throw;
            }
            catch (Exception e) when(e.GetType() != typeof(ValidationException))
            {
                m_logger.LogCritical(e, $"Unexpected Exception while trying to create a solar system with the properties : {JsonConvert.SerializeObject(solarSystem, Formatting.Indented)}");
                throw;
            }
        }
Пример #55
0
        private static void ImportSolarSystems(MassDefectContext context)
        {
            string json = File.ReadAllText(SolarSystemsPath);
            IEnumerable <SolarSystemDTO> solarSystemDtos =
                JsonConvert.DeserializeObject <IEnumerable <SolarSystemDTO> >(json);

            foreach (SolarSystemDTO solarSystemDto in solarSystemDtos)
            {
                if (solarSystemDto.Name == null)
                {
                    Console.WriteLine(ErrorMessage);
                    continue;
                }

                SolarSystem solarSystemEntity = Mapper.Map <SolarSystem>(solarSystemDto);

                Console.WriteLine(SuccessfullyImportMessageGlobal, nameof(SolarSystem), solarSystemEntity.Name);

                context.SolarSystems.Add(solarSystemEntity);
            }

            context.SaveChanges();
        }
Пример #56
0
 /// <summary>
 /// Constructor from the API.
 /// </summary>
 /// <param name="src"></param>
 internal IndustryJob(SerializableJobListItem src)
 {
     m_state = GetState(src);
     m_jobID = src.JobID;
     m_installedItemID = src.InstalledItemTypeID;
     m_installedItem = StaticBlueprints.GetBlueprintByID(src.InstalledItemTypeID);
     m_outputItemID = src.OutputTypeID;
     m_outputItem = GetOutputItem(src.OutputTypeID);
     m_runs = src.Runs;
     m_activity = (BlueprintActivity) Enum.ToObject(typeof (BlueprintActivity), src.ActivityID);
     m_blueprintType = (BlueprintType) Enum.ToObject(typeof (BlueprintType), src.InstalledItemCopy);
     m_installation = GetInstallation(src.OutputLocationID);
     m_solarSystem = StaticGeography.GetSystem(src.SolarSystemID);
     m_installedTime = src.InstallTime;
     m_installedItemME = src.InstalledItemMaterialLevel;
     m_installedItemPE = src.InstalledItemProductivityLevel;
     m_beginProductionTime = src.BeginProductionTime;
     m_endProductionTime = src.EndProductionTime;
     m_pauseProductionTime = src.PauseProductionTime;
     m_lastStateChange = DateTime.UtcNow;
     m_issuedFor = src.IssuedFor;
     m_activeJobState = GetActiveJobState();
 }
Пример #57
0
        private static void ImportSolarSystems(MassDefectContext context)
        {
            string jsonString = GetJsonString(SolarSystemsPath);
            List <SolarSystemDTO> solarSystemsDtos = JsonConvert.DeserializeObject <List <SolarSystemDTO> >(jsonString);

            foreach (var solarSystemDto in solarSystemsDtos)
            {
                if (string.IsNullOrEmpty(solarSystemDto.Name))
                {
                    Console.WriteLine(ErrorMessage);
                }
                else
                {
                    SolarSystem system = new SolarSystem()
                    {
                        Name = solarSystemDto.Name
                    };
                    context.SolarSystems.Add(system);
                    Console.WriteLine($@"Successfully imported Solar System {solarSystemDto.Name}");
                }
            }
            context.SaveChanges();
        }
Пример #58
0
 /// <summary>
 /// Constructor from the API.
 /// </summary>
 /// <param name="src"></param>
 internal IndustryJob(SerializableJobListItem src)
 {
     m_state               = GetState(src);
     m_jobID               = src.JobID;
     m_installedItemID     = src.InstalledItemTypeID;
     m_installedItem       = StaticBlueprints.GetBlueprintByID(src.InstalledItemTypeID);
     m_outputItemID        = src.OutputTypeID;
     m_outputItem          = GetOutputItem(src.OutputTypeID);
     m_runs                = src.Runs;
     m_activity            = (BlueprintActivity)Enum.ToObject(typeof(BlueprintActivity), src.ActivityID);
     m_blueprintType       = (BlueprintType)Enum.ToObject(typeof(BlueprintType), src.InstalledItemCopy);
     m_installation        = GetInstallation(src.OutputLocationID);
     m_solarSystem         = StaticGeography.GetSystem(src.SolarSystemID);
     m_installedTime       = src.InstallTime;
     m_installedItemME     = src.InstalledItemMaterialLevel;
     m_installedItemPE     = src.InstalledItemProductivityLevel;
     m_beginProductionTime = src.BeginProductionTime;
     m_endProductionTime   = src.EndProductionTime;
     m_pauseProductionTime = src.PauseProductionTime;
     m_lastStateChange     = DateTime.UtcNow;
     m_issuedFor           = src.IssuedFor;
     m_activeJobState      = GetActiveJobState();
 }
Пример #59
0
        /// <summary>
        /// Gets the post data.
        /// </summary>
        /// <param name="idsToQuery">The ids to query.</param>
        /// <returns></returns>
        private static string GetPostData(IReadOnlyCollection <int> idsToQuery)
        {
            StringBuilder sb = new StringBuilder();

            foreach (int i in idsToQuery)
            {
                sb.Append($"typeid={i}");

                if (idsToQuery.Last() != i)
                {
                    sb.Append("&");
                }
            }

            SolarSystem jitaSolarSystem = StaticGeography.GetSolarSystemByName("Jita");

            if (jitaSolarSystem != null)
            {
                sb.Append($"&usesystem={jitaSolarSystem.ID}");
            }

            return(sb.ToString());
        }
Пример #60
0
 /// <summary>
 /// Constructor for a child.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="system"></param>
 private PathFinder(PathFinder parent, SolarSystem system)
 {
     m_parent = parent;
     m_system = system;
 }