Skip to content

Specs:Content Loading

dekarrin edited this page Feb 25, 2013 · 9 revisions

The content loading system for Yuuki uses selective resource loading from collections of resources called content packs. Every content pack is located in either a directory or a ZIP archive. Because the content loading system can load from a ZIP archive, built-in content may be distributed with Yuuki inside of the game JAR file.

Content Loading and Mod Scanning

The engine begins by loading all built-in content located in the directory yuuki/resource within the package structure. This is done regardless of whether Yuuki is executed from inside a JAR file. Next, the engine scans for a directory called ../mods relative the package structure root; this will be the same folder that contains the JAR file if the engine is being executed from inside of one. If the mods directory exists, it is scanned for mod directories and/or archives, which, if valid, are loaded into memory, but not yet merged with existing content.

Mod Loader use cases

Sound Effects, Music, and Images

Sound effects, music, and images are all loaded using the same process. Each of these types uses an indexing file that maps file names to indexes. The loading of that file is a separate operation from the loading of the files themselves.

Process for loading index file


Process for loading indexed files

Portals, Actions, and Tile

Portals, actions, and tiles are stored in single files that contain multiple definitions. The loading of each type follows the same general process:

Process for loading item definitions

Entities

The loading of entities follows the same pattern as that of portals, actions, and tiles, but with the additional requirement of an ActionFactory:

Process for loading entity definitions

Worlds

World definition files are simply lists that give the land files that must be loaded. Loading a world file follows the general process for loading any list of files:

Process for loading listing file

Lands

Land files are listed in a world file, so they loaded as any listed set of files is loaded:

Process for loading listed files

User Interface

Mod loading adds a view to the options screen that allows users to enable and disable mods. The view displays the detected mods and provides a check box for each that controls enabling and disabling.

Mod activation UI

Mod Activation / Deactivation

When a mod is enabled, its content is added to the current working content set. If it contains duplicate definitions, the old definitions are masked by the new ones.

When a mod is disabled, its content is subtracted from the current working content set. If any content was masked by the content being removed, it is then unmasked.