Ejemplo n.º 1
0
        public static Universe Create(ILifeCycle lifeCycle, ISimulationTime simulationTime, IEnumerable<IModule> modules = null, Random random = null)
        {
            var universe = new Universe(lifeCycle, simulationTime) { RandomGenerator = random ?? new Random() };

            // TODO: Manage CurrentUniverses.
            CurrentUniverse = universe;

            if (modules != null)
            {
                foreach (var module in modules)
                {
                    universe._modules.Add(module);
                }
            }

            return universe;
        }
        public void SetupSimulation(SimulationParameters simulationParameters)
        {
            PersonCache = _container.GetInstance<IPersonCache>();

            _simulationParameters = simulationParameters;
            _universeFactory = new UniverseFactory(_container);

            _universeFactory.SetRandom(_container.GetInstance<Random>());
            _universeFactory.SetPersonCache(PersonCache);
            _universeFactory.SetPersonBuilder(
                new PersonBuilder(
                    _container.GetInstance<FirstNameGenerator>(),
                    _container.GetInstance<LastNameGenerator>(),
                    _container.GetInstance<Random>()));
            _universeFactory.GenerateRootTerritory();

            _universeFactory.AddLifeEvent<GetMarriedLifeEvent>()
                .AddLifeEvent<StartDatingLifeEvent>()
                .AddLifeEvent<OrphanChildLifeEvent>()
                .AddLifeEvent<GetEngagedLifeEvent>()
                .AddLifeEvent<BreakupLifeEvent>()
                .AddLifeEvent<SwitchJobLifeEvent>()
                .AddLifeEvent<HaveChildrenLifeEvent>()
                .AddLifeEvent<DeathLifeEvent>()
                .AddLifeEvent<SexReassignmentLifeEvent>()
                .AddLifeEvent<GenderChangeLifeEvent>()
                .AddLifeEvent<MoveLifeEvent>()
                .AddLifeEvent<SettleLifeEvent>()
                .AddLifeEvent<GetJobLifeEvent>()
                .AddLifeEvent<FiredLifeEvent>();

            _universe = _universeFactory.Build();

            RootTerritory = _universeFactory.GetRootTerritory();

            // TODO: Move this eventually:
            _universe.Start();
        }