Table of Contents

Class StaticActor<T>

Namespace
Exiled.API.Features.Core.Generic
Assembly
Exiled.API.dll

This is a generic Singleton implementation for components.
Create a derived class where the type T is the script you want to "Singletonize"

public abstract class StaticActor<T> : EActor, IEntity, IWorldSpace, IPosition, IRotation where T : EActor

Type Parameters

T

The type of the class.

Inheritance
StaticActor<T>
Implements
Inherited Members
Extension Methods

Remarks

Do not redefine PostInitialize() OnBeginPlay() or OnEndPlay() in derived classes.
Instead, use protected virtual methods:

PostInitialize_Static()

BeginPlay_Static()

EndPlay_Static()

To perform the initialization and cleanup: those methods are guaranteed to only be called once in the entire lifetime of the component.

Properties

IsDestroyed

Gets a value indicating whether the OnEndPlay() method has already been called by Unity.

public bool IsDestroyed { get; }

Property Value

bool

IsInitialized

Gets a value indicating whether the PostInitialize() method has already been called by Unity.

public bool IsInitialized { get; }

Property Value

bool

IsStarted

Gets a value indicating whether the OnBeginPlay() method has already been called by Unity.

public bool IsStarted { get; }

Property Value

bool

Methods

BeginPlay_Static()

Fired on OnBeginPlay().

protected virtual void BeginPlay_Static()

Remarks

This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.

CreateNewInstance()

Creates a new instance of the StaticActor<T>.

public static T CreateNewInstance()

Returns

T

The created T instance, or null if not found.

EndPlay_Static()

Fired on OnEndPlay().

protected virtual void EndPlay_Static()

Remarks

This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.

FindExistingInstance()

Looks for an existing instance of the StaticActor<T>.

public static T FindExistingInstance()

Returns

T

The existing T instance, or null if not found.

Flush()

Flushes the current actor.

protected virtual void Flush()

Get()

Gets or creates a new instance of StaticActor<T>.

public static T Get()

Returns

T

The found or created T instance.

NotifyInstanceRepeated()

If a duplicated instance of a StaticActor<T> component is loaded into the scene this method will be called instead of PostInitialize_Static().
That way you can customize what to do with repeated instances.

protected virtual void NotifyInstanceRepeated()

Remarks

The default approach is delete the duplicated component.

OnBeginPlay()

Fired after the first fixed tick.

protected override void OnBeginPlay()

OnEndPlay()

Fired before the current EActor instance is destroyed.

protected override void OnEndPlay()

PostInitialize()

Fired after the EActor instance is created.

protected override void PostInitialize()

PostInitialize_Static()

Fired on PostInitialize().

protected virtual void PostInitialize_Static()

Remarks

This method will only be called once even if multiple instances of the StaticActor<T> component exist in the scene.
You can override this method in derived classes to customize the initialization of the component.