public void Start(int ticks) { Tester.Instance.Log(TesterBaseApp.LOG, IsStarted, "warning: ShipDockApplication has started"); if (IsStarted) { return; } Notificater = new Notifications <int>(); ABs = new AssetBundles(); Servers = new Servers(OnServersInit); Datas = new DataWarehouse(); AssetsPooling = new AssetsPooling(); StateMachines = new StateMachines { FSMFrameUpdater = OnFSMFrameUpdater, StateFrameUpdater = OnStateFrameUpdater }; mFSMUpdaters = new KeyValueList <IStateMachine, IUpdate>(); mStateUpdaters = new KeyValueList <IState, IUpdate>(); if (ticks > 0) { TicksUpdater = new TicksUpdater(ticks); } ShipDockConsts.NOTICE_APPLICATION_STARTUP.Broadcast(); IsStarted = true; mAppStarted?.Invoke(); mAppStarted = null; }
public void Start(int ticks) { Application.targetFrameRate = ticks <= 0 ? 10 : ticks; if (IsStarted) { LogStartedError(); return; } else { } Tester = Tester.Instance; Tester.Init(new TesterBaseApp()); AssertFrameworkInit(int.MaxValue); AssertFrameworkInit(0); Notificater = NotificatonsInt.Instance.Notificater; //new Notifications<int>();//新建消息中心 ABs = new AssetBundles(); //新建资源包管理器 Servers = new Servers(); //新建服务容器管理器 DataWarehouse datas = new DataWarehouse(); //新建数据管理器 AssetsPooling = new AssetsPooling(); //新建场景资源对象池 ECSContext = new ShipDockComponentContext //新建 ECS 组件上下文 { FrameTimeInScene = (int)(Time.deltaTime * UpdatesCacher.UPDATE_CACHER_TIME_SCALE) }; StateMachines = new StateMachines//新建有限状态机管理器 { FSMFrameUpdater = OnFSMFrameUpdater, StateFrameUpdater = OnStateFrameUpdater }; Effects = new Effects(); //新建特效管理器 Locals = new Locals(); //新建本地化管理器 PerspectivesInputer = new PerspectiveInputer(); //新建透视物体交互器 AppModulars = new DecorativeModulars(); //新建装饰模块管理器 Configs = new ConfigHelper(); //新建配置管理器 #region 向定制框架中填充框架功能单元 Framework framework = Framework.Instance; FrameworkUnits = new IFrameworkUnit[] { framework.CreateUnitByBridge(Framework.UNIT_DATA, datas), framework.CreateUnitByBridge(Framework.UNIT_AB, ABs), framework.CreateUnitByBridge(Framework.UNIT_MODULARS, AppModulars), framework.CreateUnitByBridge(Framework.UNIT_ECS, ECSContext), framework.CreateUnitByBridge(Framework.UNIT_IOC, Servers), framework.CreateUnitByBridge(Framework.UNIT_CONFIG, Configs), framework.CreateUnitByBridge(Framework.UNIT_UI, UIs), framework.CreateUnitByBridge(Framework.UNIT_FSM, StateMachines), }; framework.LoadUnit(FrameworkUnits); #endregion mFSMUpdaters = new KeyValueList <IStateMachine, IUpdate>(); mStateUpdaters = new KeyValueList <IState, IUpdate>(); TicksUpdater = new TicksUpdater(Application.targetFrameRate);//新建客户端心跳帧更新器 AssertFrameworkInit(1); AssertFrameworkInit(2); IsStarted = true; mAppStarted?.Invoke(); mAppStarted = default; ShipDockConsts.NOTICE_SCENE_UPDATE_READY.Add(OnSceneUpdateReady); UpdatesComponent?.Init(); ShipDockConsts.NOTICE_APPLICATION_STARTUP.Broadcast();//框架启动完成 AssertFrameworkInit(3); }
private void ComponentUnitUpdate(Action <int> method) { TicksUpdater.CallLater(method); }