Playvoi/Assets/ShiroginSDK/Runtime/Services/Base/ServiceBase.cs

34 lines
No EOL
889 B
C#

namespace ShiroginSDK.Runtime.Services.Base
{
/// <summary>
/// Base class for all SDK services. Provides basic lifecycle hooks.
/// </summary>
public abstract class ServiceBase : IShiroginService
{
public bool IsInitialized { get; private set; }
// Called when the service starts up
public virtual void Initialize()
{
if (IsInitialized)
return;
IsInitialized = true;
OnInitialize();
}
// Called when the service shuts down
public virtual void Dispose()
{
if (!IsInitialized)
return;
IsInitialized = false;
OnDispose();
}
// Subclasses override these to define their behavior
protected abstract void OnInitialize();
protected abstract void OnDispose();
}
}