Class WorldLoader
Namespace: ValveResourceFormat.Renderer.World
Assembly: Renderer.dll
Loads and manages Source 2 world data including entities, lighting, and geometry.
public class WorldLoaderInheritance
Constructors
WorldLoader(World, Scene)
Initializes a new for the given world resource. Call to begin loading world components into the scene.
public WorldLoader(World world, Scene scene)Parameters
world World
The world data block to load.
scene Scene
The scene to load the world into.
Properties
BombDamage
Baked bomb damage data for CS2, null if it doesn't exist. Populated by .
public BombDamage? BombDamage { get; set; }Property Value
CameraMatrices
Transform matrices corresponding to each entry in .
public List<Matrix4x4> CameraMatrices { get; }Property Value
CameraNames
Names of info_camera_link entities found in the world.
public List<string> CameraNames { get; }Property Value
DefaultEnabledLayers
Layer names that should be visible by default, populated during loading.
public HashSet<string> DefaultEnabledLayers { get; }Property Value
Entities
All entities parsed from the world's entity lumps.
public List<EntityLump.Entity> Entities { get; }Property Value
LoadingProgress
Loading screen hints.
public IProgress<string>? LoadingProgress { get; set; }Property Value
MainWorldNode
The first world node encountered during loading.
public WorldNode? MainWorldNode { get; }Property Value
MapName
The directory path of the map, e.g. maps/de_dust2.
public string MapName { get; }Property Value
NavMesh
The loaded navigation mesh, populated by .
public NavMeshFile? NavMesh { get; set; }Property Value
Skybox2D
The 2D skybox, if one was found during entity loading.
public SceneSkybox2D? Skybox2D { get; set; }Property Value
SkyboxScene
The 3D skybox scene, if one was found during entity loading.
public Scene? SkyboxScene { get; set; }Property Value
SpawnCameraMatrix
Camera transform for the best spawn marker entity found, per priority, with eye height already applied to ground markers.
public Matrix4x4? SpawnCameraMatrix { get; }Property Value
World
The world resource being loaded.
public World World { get; }Property Value
WorldOffset
Translation offset applied to the world, used when compositing multiple maps.
public Vector3 WorldOffset { get; set; }Property Value
WorldScale
Uniform scale applied to the world.
public float WorldScale { get; set; }Property Value
Methods
FindEntityByTargetName(string)
Finds the first entity which matches its name with the given pattern.
public EntityLump.Entity? FindEntityByTargetName(string pattern)Parameters
pattern string
Targetname to match against, may contain wildcards: * and ? (e.g. door_*).
Returns
The matching , or null if not found.
GetEntityWorldTransform(Entity)
Gets the world transform of an entity, composing the transform of the point_template that spawned it when it came from a template child lump.
public Matrix4x4 GetEntityWorldTransform(EntityLump.Entity entity)Parameters
entity EntityLump.Entity
The entity to place.
Returns
The entity's transform in world space.
GetWorldNameFromMap(string)
Returns the path to the world resource (.vwrld) for a given map name.
public static string GetWorldNameFromMap(string mapName)Parameters
mapName string
Path to the map, with or without the compiled file suffix.
Returns
Load(ResourceExtRefList?)
Loads all world components: lighting, entities, world nodes, physics, visibility, bomb damage data, and navigation mesh. Navigation mesh loading is parallelized with resource preloading when references are provided.
public void Load(ResourceExtRefList? mapResourceReferences = null)Parameters
mapResourceReferences ResourceExtRefList?
Optional external reference list from the map resource, used to preload assets in parallel.
LoadBombDamageData()
Loads CS2 baked bomb damage data for this world. Populates . Skips loading if is already set.
public void LoadBombDamageData()LoadEntities()
Loads all entities from the world's entity lumps into the scene.
public void LoadEntities()LoadMap(string, Scene)
Loads a map by name, performing a full load of all world components.
public static WorldLoader LoadMap(string mapResourceName, Scene scene)Parameters
mapResourceName string
Path to the .vmap or .vmap_c resource.
scene Scene
The scene to load the world into.
Returns
LoadNavigationMesh()
Loads the navigation mesh for this world. Populates . Skips loading if is already set.
public void LoadNavigationMesh()LoadWorldLightingInfo()
Loads lightmap and lighting information from the world into the scene.
public void LoadWorldLightingInfo()LoadWorldNodes()
Loads all world nodes (.vwnod_c) referenced by the world into the scene.
public void LoadWorldNodes()LoadWorldPhysics()
Loads world physics collision geometry into the scene.
public void LoadWorldPhysics()LoadWorldVisibility()
Loads world voxel visibility (.vvis_c) into the scene.
public void LoadWorldVisibility()ParallelPreloadResources(ResourceExtRefList?)
Preloads referenced resources in parallel using the map's external reference list. This is called automatically by and does not need to be called manually.
public void ParallelPreloadResources(ResourceExtRefList? mapResourceReferences = null)Parameters
mapResourceReferences ResourceExtRefList?
External reference list from the map resource, used to preload models and entity icons.

