mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
41 lines
1007 B
C#
41 lines
1007 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace JNGame.Runtime.Sync
|
|
{
|
|
public abstract class JNSyncService : Feature
|
|
{
|
|
|
|
//系统列表
|
|
protected abstract JNBaseSystem[] AllSystems { get; }
|
|
|
|
//获取当前逻辑帧
|
|
public abstract int DeltaTime { get; }
|
|
|
|
|
|
//获取系统
|
|
public T GetSystem<T>() where T : JNBaseSystem
|
|
{
|
|
foreach (var service in AllSystems)
|
|
{
|
|
if (service is T system) return system;
|
|
}
|
|
|
|
throw new InvalidOperationException($"No Service of type {typeof(T).Name} was found.");
|
|
}
|
|
|
|
public List<T> GetSystems<T>()
|
|
{
|
|
var list = new List<T>();
|
|
foreach (var service in AllSystems)
|
|
{
|
|
if (service is T system)
|
|
{
|
|
list.Add(system);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
}
|
|
} |