备份CatanBuilding瘦身独立工程
This commit is contained in:
65
Assets/Scripts/ModuleManager/Base/ModuleManager.cs
Normal file
65
Assets/Scripts/ModuleManager/Base/ModuleManager.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using ModuleModel;
|
||||
|
||||
namespace ModuleManager
|
||||
{
|
||||
public partial class ModuleManager :IManager
|
||||
{
|
||||
private Dictionary<int, IModel> _allModules = new Dictionary<int, IModel>();
|
||||
|
||||
private List<IModel> _updateModules = new List<IModel>();
|
||||
|
||||
public ModuleManager()
|
||||
{
|
||||
this.RegisterAllManager();
|
||||
this.RegisterAllModel();
|
||||
}
|
||||
|
||||
public void DoFrameUpdate(int time, int delta)
|
||||
{
|
||||
foreach (IModel mod in _updateModules)
|
||||
{
|
||||
mod.DoFrameUpdate(time, delta);
|
||||
}
|
||||
}
|
||||
|
||||
public async void ImportFromServer(Dictionary<string, string> userDatas)
|
||||
{
|
||||
foreach (IModel mod in _updateModules)
|
||||
{
|
||||
mod.InitServerData(userDatas);
|
||||
}
|
||||
|
||||
await Awaiters.NextFrame;
|
||||
|
||||
foreach (IModel mod in _updateModules)
|
||||
{
|
||||
mod.AfterServerDataAnalysis();
|
||||
}
|
||||
}
|
||||
private void RegisterMoudle(IModel module)
|
||||
{
|
||||
module.Init();
|
||||
_updateModules.Add(module);
|
||||
if (!_allModules.TryGetValue(module.ModuleId, out IModel value))
|
||||
{
|
||||
_allModules.Add(module.ModuleId,module);
|
||||
}
|
||||
}
|
||||
|
||||
public IModel FindModule(ModuleIdEnum moduleId)
|
||||
{
|
||||
IModel module = null;
|
||||
_allModules.TryGetValue((int)moduleId, out module);
|
||||
return module;
|
||||
}
|
||||
|
||||
public void DisposeData()
|
||||
{
|
||||
foreach (IModel mod in _updateModules)
|
||||
{
|
||||
mod.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user