bw logo

Chapter 1. Entity Preloads

When the client starts up, it will query each entity Python module for a function named preload. Resource names returned by this function will be loaded on client startup and kept in memory for the entire life-time of the client (i.e. it will be instantly available for use at any time). This is useful for commonly used assets to avoid potentially loading and re-loading at a later time. The tradeoff, however, is that the client will take longer to start and will use more memory (if the resource isn't actually being used at some point).

To use the preloads mechanism, create a global function called preload in the relevant entity module. It must take a single parameter which is a Python list containing resource to preload. Modify this list in place (e.g. using list.append or list concatenation), inserting the string names of each resource to be preloaded by the client.

For example,

# Avatar.py
import BigWorld

class Avatar( BigWorld.Entity ):
    def __init__( self ):
        ...

def preload( list ):
    list.append( "characters/avatars/human_avatar.model" )
    list.append( "system/maps/fx_flare_glow.tga" )
    ...
 

The type of resources which can be preloaded are,

  • Fonts

  • Textures

  • Shaders

  • Models