Skip to content

Game.Common.AllowAudioEndBarrier

Assembly:
Namespace: Game.Common

Type: class

Base: GameSystemBase

Summary: A lightweight game system that ensures the audio end-of-frame barrier is allowed each update. It retrieves (or creates) the AudioEndBarrier system from the World on creation and calls AllowUsage() on it every frame. Methods are annotated with [Preserve] to avoid stripping by IL2CPP/optimizer.


Fields

  • private AudioEndBarrier m_AudioEndBarrier
    Holds a reference to the AudioEndBarrier system obtained from the World. This is used to call AllowUsage() each frame. The field is private and managed at runtime (not serialized).

Properties

  • This class exposes no public properties.

Constructors

  • public AllowAudioEndBarrier()
    Default public constructor. The system initialization logic happens in OnCreate rather than the constructor (typical for GameSystemBase-derived systems).

Methods

  • protected override void OnCreate() : System.Void
    Called when the system is created. This override calls base.OnCreate() and then obtains or creates the AudioEndBarrier system via base.World.GetOrCreateSystemManaged(). The method is marked with [Preserve] to prevent code stripping.

  • protected override void OnUpdate() : System.Void
    Called each frame by the game. This override calls m_AudioEndBarrier.AllowUsage() to lift or signal the audio end-frame barrier for the current frame. Also marked with [Preserve]. This method should be lightweight since it runs every frame.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_AudioEndBarrier = base.World.GetOrCreateSystemManaged<AudioEndBarrier>();
}

[Preserve]
protected override void OnUpdate()
{
    m_AudioEndBarrier.AllowUsage();
}

Notes: - The [Preserve] attribute ensures the methods remain available after IL2CPP/minification. - AudioEndBarrier is expected to be another game system that coordinates end-of-frame audio usage; calling AllowUsage() typically signals that audio resources or operations tied to frame boundaries may proceed or be released. - This system is suitable for mods that need to ensure audio end-frame behavior remains enabled each frame or to integrate with the game's audio lifecycle.