srctools.packlist
Handles the list of files which are desired to be packed into the BSP.
-
class
srctools.packlist.
FileType
(value) Bases:
Enum
Different kinds of files for Source, mainly to indicate resources to pack.
If this represents a specific file type, the value is the extension. Otherwise, it’s an arbitrary integer.
-
GENERIC
= 0 Arbitrary file type.
-
SOUNDSCRIPT
= 1 Script file containing soundscripts.
-
GAME_SOUND
= 2 world.blah
sound - lookup the soundscript, and raw files.
-
PARTICLE
= 3 Alias:
PARTICLE_SYSTEM
The name of a particle system.
-
PARTICLE_FILE
= 'pcf' A particle collection file.
-
VSCRIPT_SQUIRREL
= 'nut' Squirrel VScript file.
-
ENTITY
= 4 Classname of another entity that this entity includes. This is only permitted in the FGD file.
-
ENTCLASS_FUNC
= 5 Name of a function to call defined inside the packlist module.
-
BREAKABLE_CHUNK
= 6 Randomised generic chunk gibs. This corresponds to
g_PropDataSystem.GetRandomChunkModel()
.
-
MATERIAL
= 'vmt' Material file.
-
TEXTURE
= 'vtf' VTF texture, implicitly looks for
.hdr.vtf
too.
-
CHOREO
= 'vcd' Choreographed scenes.
-
MODEL
= 'mdl' Source model, implies the
vtx
,vvd
,phy
files too.
-
-
class
srctools.packlist.
FileMode
(value) Bases:
Enum
Mode for files we may want to pack like soundscripts or particles.
-
UNKNOWN
= 'unknown'
-
INCLUDE
= 'include'
-
PRELOAD
= 'preload'
-
EXCLUDE
= 'exclude'
-
is_used
Return if this file should be packed into the map.
-
-
class
srctools.packlist.
PackFile
() Represents a single file we are packing.
data is raw data to pack directly, instead of from the filesystem.
-
class
srctools.packlist.
PackList
(fsys: FileSystemChain) Represents a list of resources for a map.
-
pack_file
(filename: str,) None
data_type: FileType = FileType.GENERIC,
data: Optional[bytes] = None,
skinset: Optional[Set[int]] = None,
optional: bool = False, Queue the given file to be packed.
If data is set, this file will use the given data instead of any on-disk data. The data_type parameter allows specifying the kind of file, which ensures it can be treated appropriately.
If the file is a model, skinset allows restricting which skins are used. If None (default), all skins may be used. Otherwise it is a set of skins. If all uses of a model restrict the skin, only those skins need to be packed. If optional is set, this will be marked as optional so no errors occur if it isn’t in the filesystem.
-
inject_file
(data: bytes, folder: str, ext: str) str Inject a generated file into the map and return the full name.
The file will be named using the format “INJECT_<hex>”. If the same file is requested twice (same folder, extension and data), only one will be included.
-
inject_vscript
(code: str, folder: str = 'inject') str Specialised variant of inject_file() for VScript code specifically.
This returns the script name suitable for passing to Entity Scripts.
-
load_soundscript
() Iterable[Sound] Read in a soundscript and record which files use it.
If always_include is True, it will be included in the manifests even if it isn’t used.
The sounds registered by this soundscript are returned.
-
load_particle_system
() Iterable[Particle] Read in the specified particle system and record the particles for usage checking.
-
load_soundscript_manifest
() None Read the soundscript manifest, and read all mentioned scripts.
If cache_file is provided, it should be a path to a file used to cache the file reading for later use.
-
load_particle_manifest
() None Read the particle manifest, and read all mentioned scripts.
If cache_file is provided, it should be a path to a file used to cache the file reading for later use.
-
write_soundscript_manifest
() None Produce and pack a soundscript manifest file for this map.
It will be packed such that it can override the master manifest with sv_soundemitter_flush.
-
write_particles_manifest
(manifest_name: str) None Write a particles manifest, so that used particles can be loaded.
-
pack_into_zip
(bsp: BSP,) None
*,
whitelist: Iterable[FileSystem] = (),
blacklist: Iterable[FileSystem] = (),
dump_loc: Optional[Path] = None,
only_dump: bool = False,
ignore_vpk: bool = True, Pack all our files into the packfile in the BSP.
The filesys is used to find files to pack. Filesystems must be in the whitelist and not in the blacklist, if provided. If ignore_vpk is True, files in VPK won’t be packed unless that system is in allow_filesys. If dump_loc is set, files will be copied there as well. If only_dump is set, they won’t be packed at all.
-
-
srctools.packlist.
entclass_canonicalize
(classname: str) str Canonicalise classnames - some ents have old classnames for compatibility and the like.
For example func_movelinear was originally momentary_door. This doesn’t include names which have observably different behaviour, like prop_physics_override.
Deprecated: Use FGD.engine_db()
, then check if the entity is an alias.
-
srctools.packlist.
entclass_canonicalise
(classname: str) str Canonicalise classnames - some ents have old classnames for compatibility and the like.
For example func_movelinear was originally momentary_door. This doesn’t include names which have observably different behaviour, like prop_physics_override.
Deprecated: Use FGD.engine_db()
, then check if the entity is an alias.
-
srctools.packlist.
entclass_packfunc
(classname: str) Callable[[PackList, Entity], object] For some entities, they have unique packing behaviour depending on keyvalues.
If the specified classname is one, return a callable that packs it.
Deprecated: Use EntityDef.engine_cls()
thenEntityDef.get_resources()
.
-
srctools.packlist.
entclass_resources
(classname: str) Iterable[Tuple[str, FileType]] Fetch a list of resources this entity class is known to use in code.
Deprecated: Use EntityDef.engine_cls()
thenEntityDef.get_resources()
.
-
srctools.packlist.
entclass_iter
() Collection[str] Yield all classnames with known behaviour.
Deprecated: Use FGD.engine_db()
instead.