Skip to end of metadata
Go to start of metadata


The Game Rules Precache is a game subsystem designed to centralize the preloading and caching of assets.

During LevelSystem's LoadLevel, the PrecacheLevel function for the GameRules system is called. During this phase, the resources listed in the XML file Scripts/GameRules/PrecacheLists.xml file are precached.

The assets listed in the XML file are organized by asset type, game mode, and level name. If an asset is only needed for Singleplayer, or if it's only needed for a specific multiplayer mode or level, it can be marked to only be preloaded for that mode or level.

Supported Asset Types




Animation Database Files.


Mannequin Database Files.


Animation Graph Files.


Character Definition Files.


Geometry Files.


Animated Geometry Files.


Character Files.


Particle Effect Names.


Sound Names.


Game Audio Hint Names.


Vehicle XML Files.


Texture Files.


Ammo XML Files.


Weapon XML files.


BodyDamage or BodyDestruction XML files .


Flash Files.


Material Files.


Mannequin Controller Definition Files.

The name listed on the table corresponds to the XML tag in the PrecacheLists.xml file. See example below.

Code Location

The code handling the processing of the XML and the preloading of its resources can be found in GameRulesPrecache.cpp.

Lifetime and Ownership

The GameRulesPrecache module is owned by the GameRules. Its lifetime is tied to the lifetime of the GameRules, which means that the GameRulesPrecache is created when starting to load a level, and destroyed when a level is unloaded.

Unloading of assets

The handling of unloading of assets depends on their specific type, and in most cases it's not handled by the GameRulesPrecache class directly.

For example:

  • CGFs and CGAs are managed by the Item Geometry Cache, which will also take care of their unloading when a level unloads.
  • DBAs are managed by the CharacterManager, which by default releases all resources and gets destroyed during level unload, and recreated during level load.
  • For some other asset types the GameRulesPrecache may keeps a list of smart pointers to each of the preloaded assets to increment their refcount and making sure assets are not unloaded while the level is running, and when the GameRules gets destroyed during level unload, the vectors will get destructed.

Example File

			<FlashTex name='textures/sprites/hud/dirt1_bullet.tif' />
			<FlashTex name='textures/sprites/hud/dirt2_bullet.tif' />
			<FlashTex name='textures/sprites/hud/dirt3_bullet.tif' />
			<FlashTex name='textures/weapons/damage_blurmask.tif' />
			<FlashTex name='textures/weapons/ironzoom_blurmask.tif' />
			<GFX name='/libs/ui/Menus_Background.gfx' />
			<GFX name='/libs/ui/Menus_Confirmation.gfx' />
			<GFX name='/libs/ui/Menus_Dialogs.gfx' />
			<GFX name='/libs/ui/Menus_Startmenu.gfx' />
			<ADBTagDef name='Animations/Mannequin/ADB/blendRagdollTags.xml'/>
	<GameMode name='Multiplayer'>
			<CDF name='Objects/characters/human/sdk_player/sdk_player.cdf' />
			<DBA name='animations/human/male/locomotion.dba' />
			<DBA name='animations/human/male/locomotion/vault.dba' />
			<DBA name='animations/human/male/locomotion/rifle.dba' />
			<DBA name='animations/human/male/locomotion/pistol.dba' />
			<DBA name='animations/human/male/locomotion/slide.dba' />
			<DBA name='animations/human/male/locomotion/jump.dba' />
			<DBA name='animations/human/male/smartObjects/coophuman.dba' />
			<DBA name='animations/human/male/weapons/generic_1p.dba' />
			<DBA name='animations/human/male/weapons/generic.dba' />
			<DBA name='animations/human/male/weapons/pickable/pickable_1p.dba' />
			<DBA name='animations/human/male/weapons/pickable/pickable_3p.dba' />
			<CGF name='objects/weapons/attachments/silencer/silencer_scar_tp.cgf' />
			<CGF name='objects/weapons/attachments/rifle_magazine/rifle_magazine.cgf' />
			<Particle name='Explosions.grenade_air.explosion' />
			<VehicleXML name='Scripts/Entities/Vehicles/Implementations/Xml/HMMWV.xml'/>
			<VehicleXML name='Scripts/Entities/Vehicles/Implementations/Xml/MH60_Blackhawk.xml'/>
			<VehicleXML name='Scripts/Entities/Vehicles/Implementations/Xml/SpeedBoat.xml'/>
			<VehicleXML name='Scripts/Entities/Vehicles/Implementations/Xml/Abrams.xml'/>
			<FlashTex name='libs/ui/textures/menus_startmenu_noise.tif' />
			<FlashTex name='textures/sprites/glow/' />
			<Ammo name="PistolBullet" />
			<Ammo name="RifleBullet" />
			<Ammo name="Tank125" />
			<Ammo name="MGbullet" />
			<BodyDamage body="Libs/BodyDamage/BodyDamage_MP.xml" parts="Libs/BodyDamage/BodyParts_HumanMaleShared.xml" />
			<BodyDestruction name="Libs/BodyDamage/BodyDestructibility_Default.xml" />
			<GFX name='/libs/ui/Menus_Background.gfx' />
			<GFX name='/libs/ui/Menus_Confirmation.gfx' />
			<GFX name='/libs/ui/Menus_Dialogs.gfx' />
			<GFX name='/libs/ui/Menus_Startmenu.gfx' />
			<ADB name='Animations/Mannequin/ADB/humanSlaveAnims3P.adb'/>
	<GameMode name='SinglePlayer'>
			<CGF name='objects/weapons/rifle/rifle_fp.cgf' />
			<CGF name='objects/weapons/attachments/silencer/silencer_scar_tp.cgf' />
			<CGF name='objects/weapons/attachments/rifle_magazine/rifle_magazine.cgf' />
			<FlashTex name='libs/ui/textures/menus_startmenu_noise.tif' />
			<GFX name='/libs/ui/Menus_Background.gfx' />
			<GFX name='/libs/ui/Menus_Confirmation.gfx' />
			<GFX name='/libs/ui/Menus_Dialogs.gfx' />
			<GFX name='/libs/ui/Menus_Startmenu.gfx' />
	<Level name='Forest'>
			<CGF name='Objects/weapons/equipment/binoculars/binoculars_tp.cgf' />
  • No labels