6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) + game logic (GameFix/GameDAL/ServerData) + network layer (NetWorkMessage) + data layer (ObjectModel) + utilities (MrWu/Core/Config/CloudAPI/dll) + adapters (zyxAdapter/base) .NET 8.0 C# solution, 16 projects, 958 source files
67 lines
1.3 KiB
C#
67 lines
1.3 KiB
C#
using System;
|
|
using MrWu.Debug;
|
|
|
|
namespace Server.Core
|
|
{
|
|
public abstract class ASingleton : IDisposable
|
|
{
|
|
public abstract void Register();
|
|
|
|
public virtual void Dispose()
|
|
{
|
|
}
|
|
}
|
|
|
|
public abstract class Singleton<T> : ASingleton where T : Singleton<T>
|
|
{
|
|
private bool isDisposed;
|
|
|
|
private static T instance;
|
|
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
private set
|
|
{
|
|
instance = value;
|
|
}
|
|
}
|
|
|
|
public override void Register()
|
|
{
|
|
Instance = (T)this;
|
|
Instance.Awake();
|
|
}
|
|
|
|
public bool IsDisposed()
|
|
{
|
|
return this.isDisposed;
|
|
}
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
protected virtual void Destroy()
|
|
{
|
|
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
if (this.isDisposed)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.isDisposed = true;
|
|
this.Destroy();
|
|
|
|
Instance = null;
|
|
}
|
|
}
|
|
} |