fn init_world<'a, 'b>(
    config: Arc<Config>,
    player_count: Arc<PlayerCount>,
    ioman: io::NetworkIoManager,
    level: LevelData,
) -> (World, Dispatcher<'a, 'b>) {
    let mut world = World::new();
    time::init_time(&mut world, &level);
    world.insert(config);
    world.insert(player_count);
    world.insert(ioman);
    world.insert(TickCount::default());

    world.register::<PacketCreatorComponent>();
    world.register::<SerializerComponent>();

    let generator: Arc<dyn WorldGenerator> = match level.generator_type() {
        LevelGeneratorType::Flat => Arc::new(SuperflatWorldGenerator {
            options: level.clone().generator_options.unwrap_or_default(),
        }),
        LevelGeneratorType::Default => {
            Arc::new(ComposableGenerator::default_with_seed(level.seed as u64))
        }
        _ => Arc::new(EmptyWorldGenerator {}),
    };
    world.insert(level);
    world.insert(generator);

    let mut dispatcher = DispatcherBuilder::new();

    dispatcher.add(network::NetworkSystem, NETWORK, &[]);

    blocks::init_logic(&mut dispatcher);
    physics::init_logic(&mut dispatcher);
    entity::init_logic(&mut dispatcher);
    player::init_logic(&mut dispatcher);
    chunk_logic::init_logic(&mut dispatcher);
    time::init_logic(&mut dispatcher);
    lighting::init_logic(&mut dispatcher);

    dispatcher.add_barrier();

    blocks::init_handlers(&mut dispatcher);
    physics::init_handlers(&mut dispatcher);
    entity::init_handlers(&mut dispatcher);
    player::init_handlers(&mut dispatcher);
    chunk_logic::init_handlers(&mut dispatcher);

    // Player init dependency is so that player position is loaded
    // before the join handle runs.
    dispatcher.add(
        joinhandler::JoinHandlerSystem,
        JOIN_HANDLER,
        &[NETWORK, PLAYER_INIT],
    );

    dispatcher.add_barrier();

    player::init_broadcast(&mut dispatcher);
    entity::init_broadcast(&mut dispatcher);

    // Broadcast system needs to run last.
    dispatcher.add_barrier();
    dispatcher.add(util::BroadcasterSystem, BROADCASTER, &[]);

    let mut dispatcher = dispatcher.build();
    dispatcher.setup(&mut world);

    register_components(&mut world);

    (world, dispatcher)
}
/// Initializes the Specs world and dispatchers.
Initializes the Specs world and dispatchers.
Initializes the Specs world and dispatchers .
fn init_world<'a, 'b>(
    config: Arc<Config>,
    player_count: Arc<PlayerCount>,
    ioman: io::NetworkIoManager,
    level: LevelData,
) -> (World, Dispatcher<'a, 'b>) {
    let mut world = World::new();
    time::init_time(&mut world, &level);
    world.insert(config);
    world.insert(player_count);
    world.insert(ioman);
    world.insert(TickCount::default());
    world.register::<PacketCreatorComponent>();
    world.register::<SerializerComponent>();
    let generator: Arc<dyn WorldGenerator> = match level.generator_type() {
        LevelGeneratorType::Flat => Arc::new(SuperflatWorldGenerator {
            options: level.clone().generator_options.unwrap_or_default(),
        }),
        LevelGeneratorType::Default => {
            Arc::new(ComposableGenerator::default_with_seed(level.seed as u64))
        }
        _ => Arc::new(EmptyWorldGenerator {}),
    };
    world.insert(level);
    world.insert(generator);
    let mut dispatcher = DispatcherBuilder::new();
    dispatcher.add(network::NetworkSystem, NETWORK, &[]);
    blocks::init_logic(&mut dispatcher);
    physics::init_logic(&mut dispatcher);
    entity::init_logic(&mut dispatcher);
    player::init_logic(&mut dispatcher);
    chunk_logic::init_logic(&mut dispatcher);
    time::init_logic(&mut dispatcher);
    lighting::init_logic(&mut dispatcher);
    dispatcher.add_barrier();
    blocks::init_handlers(&mut dispatcher);
    physics::init_handlers(&mut dispatcher);
    entity::init_handlers(&mut dispatcher);
    player::init_handlers(&mut dispatcher);
    chunk_logic::init_handlers(&mut dispatcher);
    // Player init dependency is so that player position is loaded
    // before the join handle runs.
    dispatcher.add(
        joinhandler::JoinHandlerSystem,
        JOIN_HANDLER,
        &[NETWORK, PLAYER_INIT],
    );
    dispatcher.add_barrier();
    player::init_broadcast(&mut dispatcher);
    entity::init_broadcast(&mut dispatcher);
    // Broadcast system needs to run last.
    dispatcher.add_barrier();
    dispatcher.add(util::BroadcasterSystem, BROADCASTER, &[]);
    let mut dispatcher = dispatcher.build();
    dispatcher.setup(&mut world);
    register_components(&mut world);
    (world, dispatcher)
}
fn init_world < ' a , ' b > ( config : Arc < Config > , player_count : Arc < PlayerCount > , ioman : io :: NetworkIoManager , level : LevelData , ) -> ( World , Dispatcher < ' a , ' b > ) { let mut world = World :: new ( ) ; time :: init_time ( & mut world , & level ) ; world . insert ( config ) ; world . insert ( player_count ) ; world . insert ( ioman ) ; world . insert ( TickCount :: default ( ) ) ; world . register :: < PacketCreatorComponent > ( ) ; world . register :: < SerializerComponent > ( ) ; let generator : Arc < dyn WorldGenerator > = match level . generator_type ( ) { LevelGeneratorType :: Flat => Arc :: new ( SuperflatWorldGenerator { options : level . clone ( ) . generator_options . unwrap_or_default ( ) , } ) , LevelGeneratorType :: Default => { Arc :: new ( ComposableGenerator :: default_with_seed ( level . seed as u64 ) ) } _ => Arc :: new ( EmptyWorldGenerator { } ) , } ; world . insert ( level ) ; world . insert ( generator ) ; let mut dispatcher = DispatcherBuilder :: new ( ) ; dispatcher . add ( network :: NetworkSystem , NETWORK , & [ ] ) ; blocks :: init_logic ( & mut dispatcher ) ; physics :: init_logic ( & mut dispatcher ) ; entity :: init_logic ( & mut dispatcher ) ; player :: init_logic ( & mut dispatcher ) ; chunk_logic :: init_logic ( & mut dispatcher ) ; time :: init_logic ( & mut dispatcher ) ; lighting :: init_logic ( & mut dispatcher ) ; dispatcher . add_barrier ( ) ; blocks :: init_handlers ( & mut dispatcher ) ; physics :: init_handlers ( & mut dispatcher ) ; entity :: init_handlers ( & mut dispatcher ) ; player :: init_handlers ( & mut dispatcher ) ; chunk_logic :: init_handlers ( & mut dispatcher ) ; // Player init dependency is so that player position is loaded // before the join handle runs. dispatcher . add ( joinhandler :: JoinHandlerSystem , JOIN_HANDLER , & [ NETWORK , PLAYER_INIT ] , ) ; dispatcher . add_barrier ( ) ; player :: init_broadcast ( & mut dispatcher ) ; entity :: init_broadcast ( & mut dispatcher ) ; // Broadcast system needs to run last. dispatcher . add_barrier ( ) ; dispatcher . add ( util :: BroadcasterSystem , BROADCASTER , & [ ] ) ; let mut dispatcher = dispatcher . build ( ) ; dispatcher . setup ( & mut world ) ; register_components ( & mut world ) ; ( world , dispatcher ) }
Initializes the Specs world and dispatchers.
Initializes the Specs world and dispatchers .
config
Arc<Config>
player_count
Arc<PlayerCount>
ioman
io::NetworkIoManager
level
LevelData
config
Arc<Config>
player_count
Arc<PlayerCount>
ioman
io::NetworkIoManager
level
LevelData