Class WorldLoader
Namespace: ValveResourceFormat.Renderer.World
Assembly: Renderer.dll
Loads and manages Source 2 world data including entities, lighting, and geometry.
public class WorldLoaderInheritance
object ← WorldLoader
Constructors
WorldLoader(World, Scene, EntitySystem, Matrix4x4?)
Initializes a new WorldLoader for the given world resource. Call WorldLoader.Load(ResourceExtRefList?) to begin loading world components into the scene.
public WorldLoader(World world, Scene scene, EntitySystem entitySystem, Matrix4x4? rootTransform = null)Parameters
world World
The world data block to load.
scene Scene
The scene to load the world into.
entitySystem EntitySystem
The entity world this map's entities spawn into.
rootTransform Matrix4x4?
Transform applied to the whole map, identity when null.
Fields
DisabledEntitiesLayerName
Visibility layer of the entities that start disabled, which the game keeps hidden until enabled.
public const string DisabledEntitiesLayerName = "Entities (disabled)"Field Value
string
TemplateLayerName
Visibility layer of the entities a point_template spawns, and of the template itself.
public const string TemplateLayerName = "Template Entities"Field Value
string
Properties
BombDamage
Baked bomb damage data for CS2, null if it doesn't exist. Populated by WorldLoader.LoadBombDamageData().
public BombDamage? BombDamage { get; set; }Property Value
CameraMatrices
Transform matrices corresponding to each entry in WorldLoader.CameraNames.
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
List<string>
DefaultEnabledLayers
Layer names that should be visible by default, populated during loading.
public HashSet<string> DefaultEnabledLayers { get; }Property Value
HashSet<string>
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
IProgress<string>?
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
string
NavFlowMap
The loaded navigation flow map, null if it doesn't exist. Populated by WorldLoader.LoadNavigationFlowMap().
public NavFlowMapFile? NavFlowMap { get; set; }Property Value
NavMesh
The loaded navigation mesh, populated by WorldLoader.LoadNavigationMesh().
public NavMeshFile? NavMesh { get; set; }Property Value
NavSpace
The loaded navigation space, null if it doesn't exist. Populated by WorldLoader.LoadNavigationSpace().
public NavSpaceFile? NavSpace { get; set; }Property Value
NavigationHullNames
The names of the navigation hulls in hull index order, populated by WorldLoader.LoadNavigationMesh().
public string[] NavigationHullNames { get; set; }Property Value
string[]
SpawnCameraMatrix
Camera transform for the best spawn marker entity found, per WorldLoader.SpawnCameraClasses priority, with eye height already applied to ground markers.
public Matrix4x4? SpawnCameraMatrix { get; }Property Value
SpawnGroups
The spawn groups loaded into separate scenes, such as the 3D sky.
public List<SpawnGroup> SpawnGroups { get; }Property Value
World
The world resource being loaded.
public World World { get; }Property Value
Methods
GetSpawnGroupMapName(string)
Converts a targetmapname keyvalue to a map path without extension, e.g. prefabs/misc/team_select to maps/prefabs/misc/team_select.
public static string GetSpawnGroupMapName(string targetMapName)Parameters
targetMapName string
Returns
string
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
string
Load(ResourceExtRefList?)
Loads all world components: lighting, entities, world nodes, physics, visibility, bomb damage data, navigation mesh, navigation space and navigation flow map. Navigation file 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 WorldLoader.BombDamage. Skips loading if WorldLoader.BombDamage 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, EntitySystem, Matrix4x4?)
Loads a map by name, performing a full load of all world components.
public static WorldLoader LoadMap(string mapResourceName, Scene scene, EntitySystem entitySystem, Matrix4x4? rootTransform = null)Parameters
mapResourceName string
Path to the .vmap or .vmap_c resource.
scene Scene
The scene to load the world into.
entitySystem EntitySystem
The entity world this map's entities spawn into.
rootTransform Matrix4x4?
Transform applied to the whole map, identity when null.
Returns
LoadNavigationFlowMap()
Loads the navigation flow map for this world. Populates WorldLoader.NavFlowMap. Skips loading if WorldLoader.NavFlowMap is already set.
public void LoadNavigationFlowMap()LoadNavigationMesh()
Loads the navigation mesh for this world. Populates WorldLoader.NavMesh. Skips loading if WorldLoader.NavMesh is already set.
public void LoadNavigationMesh()LoadNavigationSpace()
Loads the navigation space for this world. Populates WorldLoader.NavSpace. Skips loading if WorldLoader.NavSpace is already set.
public void LoadNavigationSpace()LoadSpawnGroup(RendererContext, EntitySystem, string, string?, Vector3)
Loads a map as a spawn group, moved so the named landmark lands on landmarkOrigin. Landmarks are aligned by origin only, ignoring angles.
public static SpawnGroup? LoadSpawnGroup(RendererContext rendererContext, EntitySystem entitySystem, string targetMapName, string? landmark, Vector3 landmarkOrigin)Parameters
rendererContext RendererContext
entitySystem EntitySystem
targetMapName string
landmark string?
landmarkOrigin Vector3
Returns
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 WorldLoader.Load(ResourceExtRefList?) 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.
ReloadEntities()
Spawns the world's entities again from its entity lumps, as they spawned when it loaded, once the ones it spawned have been removed. The 3D sky and other spawn groups they place load again into WorldLoader.SpawnGroups.
public void ReloadEntities()
