Table of Contents

Engines Overview

The RisingV.Core.Engines namespace comprises a suite of “Engine” classes that orchestrate high‐level, domain‐specific logic within the RisingV framework. Each Engine encapsulates core functionality—such as tracking achievements, processing damage, managing chat, or handling persistence—by coordinating between low‐level game events, shared databases, and the EventBridge. Rather than interacting directly with Unity’s ECS or raw game systems, plugin authors can leverage these Engines to:

  • Centralize gameplay logic for a particular domain (e.g., achievements, buffs, loot, chat), ensuring consistent behavior across multiple plugins.
  • Subscribe to and publish events via the EventBridge to trigger reactive workflows (e.g., awarding rewards, persisting data, or broadcasting notifications).
  • Coordinate with databases (e.g., the EntityComponentDatabase, StatDatabase) for stateful management of game entities and player progress.
  • Simplify plugin development by exposing clear, high‐level methods (e.g., GrantAchievement, ApplyBuff, SpawnLoot) instead of requiring manual event hooking and state management.

How Engines Integrate

  1. Initialization & Registration
    During your plugin’s OnInitialize method, the EngineManager (or a similar central registry) is responsible for creating and registering each Engine. Typically:

    private AchievementEngine  _achievementEngine;
    private BuffEngine         _buffEngine;
    // ... other engines
    
    public void OnInitialize()
    {
        // Register engines
        _achievementEngine = EngineManager.AddEngine<AchievementEngine>(this);
        _buffEngine        = EngineManager.AddEngine<BuffEngine>(this);
        // ... register additional engines
    }
    
  2. Event‐Driven Workflows
    Each Engine subscribes to relevant game events (either directly via Harmony hooks or through the shared EventBridge) and executes domain‐specific logic. For example:

    • AchievementEngine listens for “player completed achievement” events and updates the player’s achievement progress in the database.
    • DamageEngine intercepts damage application events to calculate modified damage, apply resistances, or trigger custom effects.
    • LootEngine responds to “entity death” events, rolls on loot tables, and spawns items accordingly.
  3. Persistence and State Management
    Many Engines coordinate with underlying databases to persist state between sessions or over hot‐reloads. For example, SaveEngine manages serialization of RisingV‐specific data (e.g., custom player progress, clan membership), ensuring that on server restart or plugin reload, no data is lost. The SaveEngine typically integrates with Unity’s save pipeline or a RisingV file system abstraction.

Core Engines and Their Responsibilities

Below is a brief summary of each Engine class provided by RisingV.Core. Clicking its name will take you to the official API reference for detailed method signatures and behaviors.

  • AchievementEngine
    Manages player achievements. Listens for achievement completion events, updates player progress, and persists earned achievements. Provides methods to programmatically grant or revoke achievements.

  • AdminEngine
    Handles administrator‐level commands and permissions. Integrates with AdminAuthSystemHook to enforce who can execute elevated commands (e.g., teleport, kick, spawn). Exposes APIs for checking admin status and executing admin-only operations.

  • BuffEngine
    Oversees buff application and expiration. Subscribes to buff‐related hooks to track active buffs on entities, modify durations, and publish buff events. Provides methods to add, remove, or query buff status on any entity.

  • CastleEngine
    Coordinates castle‐related gameplay (e.g., siege events, ownership claims, defense mechanics). Listens for castle state changes and manages hierarchical relationships between players, clans, and controlled structures.

  • ChatEngine
    Processes in‐game chat messages. Integrates with ClientChatHook and ServerChatHook to filter, format, or broadcast chat. Offers plugin APIs to send system messages or custom announcements to players or channels.

  • ClanEngine
    Manages clan creation, membership, permissions, and inter‐clan relationships. Subscribes to clan‐related events, updates clan rosters, and ensures persistence of clan data. Exposes methods for inviting, promoting, or expelling members.

  • DamageEngine
    Handles damage calculations and event propagation. Applies custom damage modifiers, logs damage statistics to the StatDatabase, and triggers special effects (e.g., critical strikes, damage over time).

  • DeathEngine
    Oversees entity death logic. Subscribes to “unit died” events, manages respawn timers, awards experience or loot via the LootEngine, and publishes post‐death events for plugins to react.

  • EquipmentEngine
    Manages equipping and unequipping items. Enforces equipment restrictions, updates stat modifiers on equip, and notifies other systems (e.g., StatEngine) to recalculate derived stats.

  • ItemEngine
    Handles item spawning, usage, and depletion. Listens for “item used” events, triggers consumable effects, and integrates with the InventoryAspect and LootEngine to maintain item consistency.

  • LootEngine
    Coordinates loot generation and distribution. Registers drop tables, determines drop chances on death, and spawns items or resources in the world. Allows plugins to define custom loot tiers or special event drops.

  • SaveEngine
    Manages serialization and persistence of RisingV plugin data. Hooks into Unity’s save system or a custom file system to write and read data for players, entities, and plugin state. Provides explicit save-and-load methods for on‐demand persistence.

  • SpawnEngine
    Oversees entity spawning procedures. Wraps low‐level spawn hooks to validate spawn conditions, set up initial component data via EntityComponentDatabase, and publish “spawned” events for downstream consumption.

  • StatEngine
    Tracks and manages statistical data (e.g., damage dealt, experience earned, resources gathered). Subscribes to relevant gameplay events, aggregates stats into the StatDatabase, and provides methods for querying or resetting stats.