ISource2ModSpawnGroups

Extra spawn groups: another map, a prefab or a skybox loaded into the running map, wherever it is wanted.

A spawn group is what the engine loads a world into: the map itself is one, its skybox and every point_prefab are more (the "spawngroups" list of the status command). Loading one more puts its world geometry, its resources and -- unless told otherwise -- its entities into the running map, at an offset, and the clients load it on their own.

The world name is the map's path the way the engine takes it: "de_mirage" for a whole map, "maps/prefabs/de_dust2/de_dust2_skybox" or "prefabs/misc/team_select" for a prefab. It has to be on the server and the clients alike (the game's own files, or the server's workshop addon).

A plugin's spawn groups are unloaded when it unloads; the engine itself unloads them all when the map changes.

Loads and unloads spawn groups.

SpawnGroupLoadInfo info;
info.worldName = "maps/prefabs/de_mirage/de_mirage_skybox";
info.origin = Vector(0, 0, -4000);
g_pSource2ModSpawnGroups->Load(info, [](Source2ModSpawnGroup group, bool loaded) {
    META_CONPRINTF("spawn group %u %s\n", group, loaded ? "ready" : "gone");
});

Interface id ISource2ModSpawnGroups001 (SOURCE2MOD_SPAWNGROUPS_INTERFACE) · Global g_pSource2ModSpawnGroups · Header source2mod/ISource2ModSpawnGroups.h

Types

Source2ModSpawnGroup

using Source2ModSpawnGroup = uint32_t;

SpawnGroupHandle_t; 0 is none (the engine's SPAWN_GROUP_HANDLE_INVALID is 0xFFFFFFFF and never returned here).

SpawnGroupCallback

using SpawnGroupCallback = Source2ModCallback<void(Source2ModSpawnGroup group, bool loaded)>;

Told once when a spawn group a plugin loaded is ready (@p loaded true, its entities spawned), and once when it is gone again (@p loaded false: it was unloaded, or the map changed under it). A group unloaded by Unload() or by the plugin unloading is not reported.

Methods

Load

virtual Source2ModSpawnGroup Load(const SpawnGroupLoadInfo& info, SpawnGroupCallback callback = SpawnGroupCallback()) = 0;

Starts loading a spawn group into the running map.

ParameterTypeDefaultDescription
infoconst SpawnGroupLoadInfo&What to load and where
callbackSpawnGroupCallbackSpawnGroupCallback()Told when it is ready and when it is gone; may be empty

Returns Source2ModSpawnGroup — The group, 0 when there is no map running, the world does not exist (no maps/<world>.vpk or maps/<world>/world.vwrld_c -- the engine would take it and fail the next map load with it) or the engine refused it.

Unload

virtual bool Unload(Source2ModSpawnGroup group) = 0;

Unloads a spawn group with its entities -- one of this plugin's, or any other the engine has, the map's own included (careful with that).

ParameterType
groupSource2ModSpawnGroup

Returns bool — false when there is no such group.

FindByName

virtual Source2ModSpawnGroup FindByName(const char* name) = 0;

A loaded or loading group by the name it was loaded under through Source2Mod (SpawnGroupLoadInfo::name), else by its world name -- the map's own ("de_dust2"), its skybox, the engine's prefabs; 0 for none.

ParameterType
nameconst char*

IsLoaded

virtual bool IsLoaded(Source2ModSpawnGroup group) = 0;

Whether the group is fully loaded, entities spawned.

ParameterType
groupSource2ModSpawnGroup

IsLoading

virtual bool IsLoading(Source2ModSpawnGroup group) = 0;

Whether the group is still on its way.

ParameterType
groupSource2ModSpawnGroup

MakeActive

virtual bool MakeActive(Source2ModSpawnGroup group) = 0;

Makes the group the active one, like SPAWNGROUP_LOAD_SET_ACTIVE.

ParameterType
groupSource2ModSpawnGroup

GetEntitySpawnGroup

virtual Source2ModSpawnGroup GetEntitySpawnGroup(CEntityInstance* entity) = 0;

The group an entity belongs to; 0 for none.

ParameterType
entityCEntityInstance*

SpawnGroupLoadInfo

One spawn group to load.

Fields

FieldTypeDescription
worldNameconst char*The world: "de_mirage", "maps/prefabs/de_dust2/de_dust2_skybox", ... Required.
nameconst char*The name the status command lists and FindByName() looks up; worldName when null.
flagsuint32_tSpawnGroupLoadFlags.
entityLumpNameconst char*An entity lump other than the world's main one; null for that one.
entityFilterNameconst char*Entity filter the world's entities go through; null for none.
localNameFixupconst char*Prefix the group's own targetnames get ("" or null for none), so two copies of one world do not answer to each other's inputs.

Vector

Vector origin = Vector(0.0f, 0.0f, 0.0f);

Where the world's origin goes in the running map, and how it is turned.

ParameterType
—0.0f

QAngle

QAngle angles = QAngle(0.0f, 0.0f, 0.0f);
ParameterType
—0.0f

Enums

SpawnGroupLoadFlags

enum SpawnGroupLoadFlags : uint32_t

What SpawnGroupLoadInfo::flags may hold.

NameValueDescription
SPAWNGROUP_LOAD_NONE0
SPAWNGROUP_LOAD_DONT_SPAWN_ENTITIES(1 << 0)Loads the world and its resources, but none of its entities.
SPAWNGROUP_LOAD_SUPPRESS_MAP_ENTITIES(1 << 1)Spawns no entity of the map's own entity lump (entities a prefab adds still come).
SPAWNGROUP_LOAD_BLOCK_UNTIL_LOADED(1 << 2)Asks the engine to load it in one go. On CS2 14197 Load() still returns before the group is ready (it is a frame later): wait for the callback.
SPAWNGROUP_LOAD_SET_ACTIVE(1 << 3)Makes it the active spawn group once loaded (what the map itself is).
SPAWNGROUP_LOAD_DISABLE_BASE_LAYER(1 << 4)Leaves the world_layer_base layer of the new world disabled.
SPAWNGROUP_LOAD_NO_STREAMING_DATA(1 << 5)Does not load the world's streaming data (static props, lighting).

On this page