Skip to content

Game.Assets.IContentPrerequisite

Assembly:
Game (not specified in the source file; in the game's managed assemblies this typically appears in Assembly-CSharp.dll)

Namespace: Game.Assets

Type:
Interface

Base:
None

Summary:
Defines a simple contract for assets that declare other content they depend on. Implementing types expose a string array of content prerequisites (IDs, keys or package names) that can be used by loaders or validation tools to ensure required content is present before the asset is used or instantiated. This is useful for modders to express dependencies between custom assets or between mods and base-game content.


Fields

  • None
    Implementing types may have private fields to back the property, but the interface itself declares no fields.

Properties

  • string[] contentPrerequisites { get; set; }
    An array of strings identifying content this asset requires. Conventions for the strings (package GUIDs, internal IDs, workshop item IDs, human-readable names) depend on the consuming code. Implementers should return null or an empty array when there are no prerequisites. Loaders/validators should handle null/empty arrays as "no dependencies."

Constructors

  • None
    Interfaces do not define constructors. Implementing classes/structs provide their own constructors.

Methods

  • None
    This interface only contains a single property. Dependency-checking and loading logic should be implemented elsewhere (for example, in asset loaders, content managers, or utility classes).

Usage Example

// Simple implementation of the interface
public class MyCustomAsset : IContentPrerequisite
{
    public string[] contentPrerequisites { get; set; }

    public MyCustomAsset()
    {
        // Example: list package names or IDs that must be present
        contentPrerequisites = new[] { "BaseRoads", "StreetLightsPackage" };
    }
}

// Example checker (pseudo-code: replace ContentManager.HasContent with the actual game API)
public static bool ArePrerequisitesAvailable(IContentPrerequisite asset)
{
    if (asset?.contentPrerequisites == null || asset.contentPrerequisites.Length == 0)
        return true;

    foreach (var id in asset.contentPrerequisites)
    {
        // ContentManager.HasContent(id) is placeholder; use the game's content API
        if (!ContentManager.HasContent(id))
            return false;
    }

    return true;
}

Additional notes: - Choose a consistent identifier format for prerequisites (e.g., package GUIDs or workshop IDs) and document it for consumers of your assets. - Avoid circular dependencies between assets. Validate prerequisites at build time or when loading to provide clear warnings/errors to users. - The interface does not enforce semantics of the strings; integration code must interpret them and resolve them against the game's content system.