MCPcopy Create free account
hub / github.com/crownengine/crown / load_level

Method load_level

src/world/world.cpp:858–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

856}
857
858Level *World::load_level(StringId64 name, u32 flags, const Vector3 &pos, const Quaternion &rot)
859{
860 const LevelResource *lr = (LevelResource *)_resource_manager->get(RESOURCE_TYPE_LEVEL, name);
861 const UnitResource *ur = level_resource::unit_resource(lr);
862
863 Level *level = level::create(*_allocator, lr);
864
865 // Create IDs for units.
866 for (u32 i = 0; i < ur->num_units; ++i)
867 level->_unit_lookup[i] = _unit_manager->create();
868
869 create_components(*this, ur, level->_unit_lookup, flags, pos, rot, VECTOR3_ONE);
870
871 array::push(_units, level->_unit_lookup, ur->num_units);
872#if CROWN_CAN_RELOAD
873 array::push_back(_unit_resources, ur);
874 for (u32 i = 0; i < ur->num_units - 1; ++i)
875 array::push_back(_unit_resources, (const UnitResource *)NULL);
876#endif
877
878 post_unit_spawned_events(level->_unit_lookup, ur->num_units);
879 script_world::spawned(*_script_world, level->_unit_lookup, ur->num_units);
880
881 spawn_skydome(lr->skydome_unit);
882
883 for (u32 i = 0; i < lr->num_sounds; ++i) {
884 const LevelSound *ls = level_resource::get_sound(lr, i);
885 play_sound(ls->name, ls->loop, ls->volume, ls->range, PlaySoundFlags::ENABLE_ATTENUATION, ls->position, ls->group);
886 }
887
888 list::add(level->_node, _levels);
889
890 post_level_loaded_event();
891 return level;
892}
893
894void World::destroy_level(Level &level)
895{

Callers 1

load_apiFunction · 0.80

Calls 7

create_componentsFunction · 0.85
pushFunction · 0.85
spawnedFunction · 0.85
createFunction · 0.70
addFunction · 0.70
getMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected