FactionTemplate - jimdroberts/FishMMO GitHub Wiki

Description

Defines a ScriptableObject representing a single faction, including its icon, description, and default relationships (allied, neutral, hostile) with other factions. Used for reputation, standing, and UI display in FishMMO.


API Access

Fields

  • public Sprite Icon

    The icon representing this faction in the UI.

  • public const int Minimum

    The minimum possible value for faction reputation or standing.

  • public const int Maximum

    The maximum possible value for faction reputation or standing.

  • public string Description

    Description of the faction, used for tooltips and UI.

  • public FactionHashSet DefaultAllied

    Set of factions that are considered allied by default.

  • public FactionHashSet DefaultNeutral

    Set of factions that are considered neutral by default.

  • public FactionHashSet DefaultHostile

    Set of factions that are considered hostile by default.

Properties

  • public string Name

    The display name of the faction (from the ScriptableObject's name).


Basic Usage

Setup

  1. Create a new FactionTemplate ScriptableObject in your project.
  2. Assign an icon and description for the faction.
  3. Use the DefaultAllied, DefaultNeutral, and DefaultHostile sets to define relationships with other factions.

Example

// Example 1: Creating a new faction in the Unity Editor
// 1. In the Unity Editor, create a new FactionTemplate asset.
// 2. Assign an icon and description.
// 3. Add other FactionTemplate assets to DefaultAllied, DefaultNeutral, and DefaultHostile as needed.

// Example 2: Accessing faction data in code
var faction = Resources.Load<FactionTemplate>("Path/To/Faction");
Debug.Log(faction.Name);
Debug.Log(faction.Description);

Best Practices

  • Use the DefaultAllied, DefaultNeutral, and DefaultHostile sets to clearly define relationships for each faction.
  • Keep the icon and description up to date for accurate UI representation.
  • Use the Minimum and Maximum constants to clamp reputation or standing values in your game logic.
⚠️ **GitHub.com Fallback** ⚠️