RaceTemplate - jimdroberts/FishMMO GitHub Wiki

Description

ScriptableObject template for defining a playable race, including models, attributes, starting abilities, inventory, and equipment. Used to configure race options for player characters in FishMMO.


API Access

Fields

  • public GameObject Prefab

    The prefab for the race.

  • public AssetReference PlaceholderModel

    This model is loaded during ClientPreboot as a static model reference for this Race. It will be replaced by the player's selected model at runtime.

  • public List Models

    The real character model references for this race.

  • public string Description

    Description of the race.

  • public CharacterAttributeTemplateDatabase InitialAttributes

    Initial attribute database for the race.

  • public FactionTemplate InitialFaction

    The initial faction for the race.

  • public List StartingAbilities

    List of starting abilities for the race.

  • public List StartingInventoryItems

    List of starting inventory items for the race.

  • public List StartingEquipment

    List of starting equipment for the race.

Properties

  • public string Name { get; }

    The name of the race (from the ScriptableObject name).

Methods

  • public AssetReference GetModelReference(int index)

    Gets the model reference for the given index, or the placeholder if out of range or models are missing. Parameters:

    • index (int): The model index.* Returns: AssetReference — The asset reference for the model.
  • public override void OnLoad(string typeName, string resourceName, int resourceID)

    Called when the race is loaded. Loads the placeholder model. Parameters:

    • typeName (string): The type name of the resource.
    • resourceName (string): The resource name.
    • resourceID (int): The resource ID.*
  • public override void OnUnload(string typeName, string resourceName, int resourceID)

    Called when the race is unloaded. Unloads the placeholder model. Parameters:

    • typeName (string): The type name of the resource.
    • resourceName (string): The resource name.
    • resourceID (int): The resource ID.*
  • public void LoadPlaceholderModel()

    Loads the placeholder model for the race using Addressables.

  • public void UnloadPlaceholderModel()

    Unloads the placeholder model for the race using Addressables.


Basic Usage

Setup

  1. Create a new RaceTemplate ScriptableObject in the Unity Editor.
  2. Assign a prefab, placeholder model, and list of models in the Inspector.
  3. Set up initial attributes, faction, abilities, inventory, and equipment as needed.
  4. Reference the template in player character creation and race selection systems.

Example

// Example 1: Getting a model reference for a race
RaceTemplate race = ...; // Reference to the ScriptableObject
AssetReference modelRef = race.GetModelReference(0);

// Example 2: Loading and unloading the placeholder model
race.LoadPlaceholderModel();
race.UnloadPlaceholderModel();

Best Practices

  • Use descriptive names and models for each race to improve player experience.
  • Assign initial attributes and starting items to balance gameplay for each race.
  • Always provide a valid placeholder model for loading screens and previews.
  • Use the provided methods to manage model loading and unloading efficiently.
⚠️ **GitHub.com Fallback** ⚠️