OnSchemeLoaded

From Intrigues Wiki
Revision as of 15:41, 24 December 2023 by Tayfunwiki (talk | contribs) (Created page with "== <code>onSchemeLoaded</code> Event in Actor Class == === Overview === The <code>onSchemeLoaded</code> event in the <code>Actor</code> class is triggered when a scheme is loaded from the Intrigue Save System. This event plays a vital role in games where the persistence and retrieval of schemes are integral to gameplay continuity and narrative progression. === Description === * Event Type: <code>Action<Scheme></code> * Functionality: Activated whenever a previously sa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

onSchemeLoaded Event in Actor Class

Overview

The onSchemeLoaded event in the Actor class is triggered when a scheme is loaded from the Intrigue Save System. This event plays a vital role in games where the persistence and retrieval of schemes are integral to gameplay continuity and narrative progression.

Description

  • Event Type: Action<Scheme>
  • Functionality: Activated whenever a previously saved scheme is loaded from the Intrigue Save System. This event provides a framework for executing specific actions or logic in response to the loading of schemes, ensuring continuity and dynamic adaptation of the game state based on saved data.

Usage

This event is particularly useful for re-establishing game state, updating UI elements, or triggering narrative events upon loading schemes. It is essential for games with complex storylines or strategies where player actions and decisions are saved and restored.

Subscribing to the Event

Subscribe to the onSchemeLoaded event in a MonoBehaviour script to implement custom responses to the loading of schemes. Ensure to unsubscribe appropriately to avoid memory leaks or unwanted behavior.

Example of Usage

public class SchemeLoadListener : MonoBehaviour {
    public Actor actor;

    void Start() {
        if (actor != null) {
            actor.onSchemeLoaded += OnSchemeLoaded;
        }
    }

    private void OnSchemeLoaded(Scheme scheme) {
        Debug.Log($"Loaded scheme: {scheme.SchemeName} from Intrigue Save System");
        // Implement logic to handle the loaded scheme
    }

    void OnDestroy() {
        if (actor != null) {
            actor.onSchemeLoaded -= OnSchemeLoaded;
        }
    }
}

In this example, the SchemeLoadListener script is attached to a Unity GameObject and subscribes to the onSchemeLoaded event of an Actor. When a scheme is loaded, the OnSchemeLoaded method is called, allowing for custom logic to handle the loaded scheme.

Remarks

  • The onSchemeLoaded event is crucial for games that utilize a save system, ensuring smooth gameplay and narrative transitions upon loading schemes.
  • Proper management of event subscriptions is important in Unity to maintain performance and avoid memory leaks.
  • This event enhances the player's experience by allowing for seamless continuity in gameplay and story progression when loading schemes.