Schemes.ID: Difference between revisions

From Intrigues Wiki
(Created page with "== <code>ID</code> Property in Scheme Class == === Overview === The <code>ID</code> property in the Scheme class represents a unique identifier for each scheme instance in the game. === Property Definition === <syntaxhighlight lang="c#"> [field: SerializeField] public string ID { get; private set; } </syntaxhighlight> === Description === * Attribute: <code>[field: SerializeField]</code> - This attribute allows the <code>ID</code> field to be serialized by Unity, enab...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 12: Line 12:
=== Description ===
=== Description ===


* Attribute: <code>[field: SerializeField]</code> - This attribute allows the <code>ID</code> field to be serialized by Unity, enabling it to be set and viewed in the Unity Editor.
* Type: <code>string</code>
* Type: <code>string</code>
* Accessibility: The property is publicly accessible for getting its value but is privately settable, meaning it can only be modified internally within the class or its methods.
* Accessibility: The property is publicly accessible for getting its value but is privately settable, meaning it can only be modified internally within the class or its methods.
Line 26: Line 25:
=== Example of Usage ===
=== Example of Usage ===
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
public class SchemeManager : MonoBehaviour {
public class SchemeInteractionManager : MonoBehaviour {
     void Start() {
     void Start() {
         Scheme currentScheme = IM.Player.GetScheme("Assassination");
         // Iterate through all active schemes of the player and log their ID's
        if (currentScheme != null) {
        foreach (Scheme scheme in IM.Player.Schemes) {
             Debug.Log($"Current scheme ID: {currentScheme.ID}");
             Debug.Log($"Scheme ID: {scheme.ID}");
         }
         }
     }
     }
Line 38: Line 37:
==== Description: ====
==== Description: ====


* The <code>Start</code> method in this <code>SchemeManager</code> class demonstrates how to access the <code>ID</code> property of a <code>Scheme</code> object. It logs the unique ID of the current scheme to the console.
* In the <code>Start</code> method of the <code>SchemeInteractionManager</code> class, the example demonstrates iterating through all active schemes associated with the player and logging each scheme's id.


=== Remarks ===
=== Remarks ===

Latest revision as of 18:30, 4 January 2024

ID Property in Scheme Class

Overview

The ID property in the Scheme class represents a unique identifier for each scheme instance in the game.

Property Definition

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

Description

  • Type: string
  • Accessibility: The property is publicly accessible for getting its value but is privately settable, meaning it can only be modified internally within the class or its methods.

Functionality

  • The ID serves as a unique identifier for schemes, ensuring that each scheme instance can be distinctly recognized and referenced.
  • It is particularly important for managing and tracking different schemes in the game, especially when dealing with multiple instances and types of schemes.

Usage

This property is used to access the unique identifier of a scheme. It's crucial in scenarios where specific schemes need to be identified, compared, or tracked throughout the gameplay.

Example of Usage

public class SchemeInteractionManager : MonoBehaviour {
    void Start() {
        // Iterate through all active schemes of the player and log their ID's
        foreach (Scheme scheme in IM.Player.Schemes) {
            Debug.Log($"Scheme ID: {scheme.ID}");
        }
    }
}

Description:

  • In the Start method of the SchemeInteractionManager class, the example demonstrates iterating through all active schemes associated with the player and logging each scheme's id.

Remarks

  • The ID property is a critical aspect of the Scheme class, providing a means to uniquely identify each scheme instance.
  • Proper management of scheme IDs is essential for the integrity of game logic, particularly in complex systems involving multiple schemes and interactions.