Role.ID

From Intrigues Wiki
Revision as of 11:11, 5 January 2024 by Tayfunwiki (talk | contribs) (Created page with "=== Role Class - <code>ID</code> Property === ==== Overview ==== The <code>ID</code> property in the Role class uniquely identifies each role within the game. ==== Syntax ==== <syntaxhighlight lang="c#"> [field: SerializeField] public string ID { get; private set; } </syntaxhighlight> ==== Description ==== This property holds a unique identifier for a role, ensuring that each role can be distinctly recognized and referred to within the game's systems. It's crucial for...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Role Class - ID Property

Overview

The ID property in the Role class uniquely identifies each role within the game.

Syntax

[field: SerializeField] public string ID { get; private set; }

Description

This property holds a unique identifier for a role, ensuring that each role can be distinctly recognized and referred to within the game's systems. It's crucial for managing roles in gameplay, scripting, and data storage.

Usage

Use ID to reference or manipulate specific roles in game logic, such as assigning roles to actors or triggering role-specific events.

Example of Usage

public class RoleManager : MonoBehaviour {
    private Role leaderRole;

    void Start() {
        // Fetching the 'Leader' role
        leaderRole = IM.GetRole("Leader");

        if (leaderRole != null) {
            Debug.Log($"Leader Role ID: {leaderRole.ID}");
        }
    }
}

Remarks

  • The ID is typically used in scenarios where roles need to be identified or processed programmatically.
  • It is crucial for maintaining consistency and accuracy in role management, especially in complex systems involving multiple roles.