Example #1
0
        public void CreateDefaultFaction(string name, string password)
        {
            Entity factionEntity = DefaultStartFactory.DefaultHumans(_game, name);

            AuthProcessor.StorePasswordAsHash(_game, factionEntity, password);
            SetFaction(factionEntity);
        }
Example #2
0
        public Game([NotNull] NewGameSettings newGameSettings) : this()
        {
            if (newGameSettings == null)
            {
                throw new ArgumentNullException(nameof(newGameSettings));
            }

            GalaxyGen = new GalaxyFactory(true, newGameSettings.MasterSeed);

            Settings = newGameSettings;
            GameLoop.GameGlobalDateTime = newGameSettings.StartDateTime;

            // Load Static Data
            if (newGameSettings.DataSets != null)
            {
                foreach (string dataSet in newGameSettings.DataSets)
                {
                    StaticDataManager.LoadData(dataSet, this);
                }
            }
            if (StaticData.LoadedDataSets.Count == 0)
            {
                StaticDataManager.LoadData("Pulsar4x", this);
            }
            // Create SM


            SpaceMaster.ChangePassword(new AuthenticationToken(SpaceMaster, ""), newGameSettings.SMPassword);
            GameMasterFaction = FactionFactory.CreatePlayerFaction(this, SpaceMaster, "SpaceMaster Faction");

            if (newGameSettings.CreatePlayerFaction ?? false)
            {
                Player defaultPlayer = AddPlayer(newGameSettings.DefaultPlayerName, newGameSettings.DefaultPlayerPassword);

                foreach (var kvp in newGameSettings.DefaultHaltOnEvents)
                {
                    defaultPlayer.HaltsOnEvent.Add(kvp.Key, kvp.Value);
                }

                if (newGameSettings.DefaultSolStart ?? false)
                {
                    DefaultStartFactory.DefaultHumans(this, defaultPlayer, newGameSettings.DefaultFactionName);
                }
                else
                {
                    FactionFactory.CreatePlayerFaction(this, defaultPlayer, newGameSettings.DefaultFactionName);
                }
            }

            // Temp: This will be reworked later.
            GenerateSystems(new AuthenticationToken(SpaceMaster, newGameSettings.SMPassword), newGameSettings.MaxSystems);

            /*
             * GlobalManager.ManagerSubpulses.Init(GlobalManager);
             * foreach (StarSystem starSys in this.Systems.Values)
             * {
             *  starSys.ManagerSubpulses.Init(starSys);
             * }*/

            // Fire PostLoad event
            PostLoad += (sender, args) => { InitializeProcessors(); };
        }