public SystemSlot(int order, ISystem system) { Order = order; System = system; UpdateSystem = system is IUpdateSystem ? (IUpdateSystem)system : null; DebugInfo = new SystemDebugInfo(system); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { wandererWorld = Matrix.Identity; wanderer = new WandererBody(this); heightMapTransformSystem_Wanderer = new HeightMapTransformSystem_Wanderer(); heightMapComponent = new HeightMapComponent(); heightMapCameraComponent = new HeightMapCameraComponent(); robotComponent = new RobotComponent(); heightMapSystem = new HeightmapSystem(); heightMapTranformSystem = new HeightMapTranformSystem(); heightMapRenderSystem = new HeightMapRenderSystem(graphics.GraphicsDevice); robotSystem = new RobotSystem(); robotTranformSystem = new RobotTranformSystem(); robotRenderSystem = new RobotRenderSystem(); collisionSystem = new CollisionSystem(); houseSystem = new HouseSystem(this); systemRenderer = new Renderer(); base.Initialize(); }
public AutoUpdateServiceManager() { InitializeComponent(); this.updateSystem = ServiceManager.ServiceManagerInstance.GetRemotingService <IUpdateSystem>("updateSystem"); this.serverConfig = this.updateSystem.GetVersionConfig(); }
protected void Add([NotNull] IUpdateSystem system) { if (system == null) { throw new ArgumentNullException(nameof(system)); } GetOrCreateListAndAdd(ref _updateSystems, system); }
/// <summary> /// Add update function from someone object what need to call /// </summary> /// <param name="update"></param> /// <exception cref="Exception"></exception> public void Add(IUpdateSystem update) { if (updates.Contains(update)) { throw new Exception($"Object is exist in updates: {nameof(update)}"); } updates.Add(update); }
public UpdateFileToServer(UpdateConfig config, List <UploadFileInfo> files) { InitializeComponent(); this.config = config; this.filesList = files; this.updateSystem = ServiceManager.ServiceManagerInstance.GetRemotingService <IUpdateSystem>("updateSystem"); }
/// <summary> /// remove update from a object when it does not use /// </summary> /// <param name="update"></param> /// <exception cref="Exception"></exception> public void Remove(IUpdateSystem update) { if (updates.Contains(update)) { updates.Remove(update); } else { throw new Exception($"Object is not exist in updates: {nameof(update)}"); } }
public DownloadUpdateFile() { InitializeComponent(); this.updateSystem = ServiceManager.ServiceManagerInstance.GetRemotingService <IUpdateSystem>("updateSystem"); this.serverConfig = this.updateSystem.GetVersionConfig(); this.clientConfig = new ClientUpdateConfig(); this.clientConfig.ClientUpdateInfo = new ClientUpdateInfo { PreviousVersion = this.clientConfig.ClientUpdateInfo == null ? this.serverConfig.ConfigInfo.CurrentVersion : this.clientConfig.ClientUpdateInfo.CurrentVersion, CurrentVersion = this.serverConfig.ConfigInfo.CurrentVersion, UpdateDate = DateTime.Now }; }
private void Start() { _context = new Context(); _context.systems.Add(new TimeSystem()); _context.systems.Add(new CameraSystem()); _context.systems.Add(new BoardSystem()); _context.systems.Add(new UISystem()); _context.systems.Add(new UnitAddSystem()); _context.systems.Add(new MoveSystem()); _context.systems.Add(new BounceSystem().SetOrder(int.MaxValue - 2)); _context.systems.Add(new EventSystem().SetOrder(int.MaxValue - 1)); _context.systems.Add(new PoolSystem().SetOrder(int.MaxValue)); _updateSystem = _context.systems; }
public void Update() { while (this.updates.Count > 0) { long instanceId = this.updates.Dequeue(); Entity component; if (!this.allEntities.TryGetValue(instanceId, out component)) { continue; } if (component.IsDisposed) { continue; } List <object> iUpdateSystems = this.typeSystems.GetSystems(component.GetType(), typeof(IUpdateSystem)); if (iUpdateSystems == null) { continue; } this.updates2.Enqueue(instanceId); for (int i = 0; i < iUpdateSystems.Count; ++i) { IUpdateSystem iUpdateSystem = iUpdateSystems[i] as IUpdateSystem; try { iUpdateSystem.Run(component); } catch (Exception e) { Log.Error(e); } } } ObjectHelper.Swap(ref this.updates, ref this.updates2); }
public void Add(DLLType dllType, Assembly assembly) { this.assemblies[dllType] = assembly; this.types.Clear(); foreach (Assembly value in this.assemblies.Values) { foreach (Type type in value.GetTypes()) { object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false); if (objects.Length == 0) { continue; } BaseAttribute baseAttribute = (BaseAttribute)objects[0]; this.types.Add(baseAttribute.AttributeType, type); } } this.awakeSystems.Clear(); this.lateUpdateSystems.Clear(); this.updateSystems.Clear(); this.startSystems.Clear(); this.loadSystems.Clear(); this.changeSystems.Clear(); foreach (Type type in types[typeof(ObjectSystemAttribute)]) { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeSystems.Add(objectSystem.Type(), objectSystem); } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateSystems.Add(updateSystem.Type(), updateSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startSystems.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.destroySystems.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadSystems.Add(loadSystem.Type(), loadSystem); } IChangeSystem changeSystem = obj as IChangeSystem; if (changeSystem != null) { this.changeSystems.Add(changeSystem.Type(), changeSystem); } } this.Load(); }
protected virtual void AddUpdateSystem(IUpdateSystem system) { _normalSystemMgr.AddUpdateSystem(system); }
public EventSystem() { Type[] types = ETModel.Game.Hotfix.GetHotfixTypes(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeEvents.Add(objectSystem.Type(), objectSystem); } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateEvents.Add(updateSystem.Type(), updateSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateEvents.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startEvents.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.desdroyEvents.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadEvents.Add(loadSystem.Type(), loadSystem); } } this.allEvents.Clear(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; object obj = Activator.CreateInstance(type); IEvent iEvent = obj as IEvent; if (iEvent == null) { Log.Error($"{obj.GetType().Name} 没有继承IEvent"); } this.RegisterEvent(aEventAttribute.Type, iEvent); // hotfix的事件也要注册到mono层,hotfix可以订阅mono层的事件 Action <List <object> > action = list => { Handle(aEventAttribute.Type, list); }; ETModel.Game.EventSystem.RegisterEvent(aEventAttribute.Type, new EventProxy(action)); } } this.Load(); }
private readonly Queue <long> starts = new Queue <long>(); //这个只需要一个 因为starts只会执行一次 /// <summary> /// 加载程序集 /// </summary> /// <param name="dllType"></param> /// <param name="assembly"></param> public void Add(DLLType dllType, Assembly assembly) { this.assemblies[dllType] = assembly; this.types.Clear(); //清空 foreach (Assembly value in this.assemblies.Values) { foreach (Type type in value.GetTypes()) { object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false); //有BaseAttribute特性的类 if (objects.Length == 0) { continue; } BaseAttribute baseAttribute = (BaseAttribute)objects[0]; this.types.Add(baseAttribute.AttributeType, type); //把类根据其特性的类型 加入到不同的字典中 } } this.awakeSystems.Clear(); this.lateUpdateSystems.Clear(); this.updateSystems.Clear(); this.startSystems.Clear(); this.loadSystems.Clear(); this.changeSystems.Clear(); foreach (Type type in types[typeof(ObjectSystemAttribute)]) //遍历有ObjectSystem特性的类 { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); //再次检查 if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); //实例化 //比如 public class TimerComponentUpdateSystem : UpdateSystem<TimerComponent> // 我们写的功能都在 TimerComponent 中 它里面有 start update 等方法 但是不用我们来调用 // TimerComponentUpdateSystem 类会自动帮我们调用 其中的 update 方法 // updateSystems 字典中会保存 TimerComponent类名 和 TimerComponentUpdateSystem 这个类 // 当 TimerComponent 这个类生成的时候 updateSystems 字典中检索到了 有这个类名 就会调用TimerComponentUpdateSystem // 而 TimerComponentUpdateSystem 的传参是 TimerComponent 他会自动调用 TimerComponent 中的方法 IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeSystems.Add(objectSystem.Type(), objectSystem); //!!!这里的objectSystem.Type()其实就是需要执行的类的类型 所以他能收集对应的类的方法 } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateSystems.Add(updateSystem.Type(), updateSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startSystems.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.destroySystems.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadSystems.Add(loadSystem.Type(), loadSystem); } IChangeSystem changeSystem = obj as IChangeSystem; if (changeSystem != null) { this.changeSystems.Add(changeSystem.Type(), changeSystem); } } ///////////////////////////////////////////////////////////////////////////////////////// this.allEvents.Clear(); //清除事件 //遍历所有的有事件特性的类 foreach (Type type in types[typeof(EventAttribute)]) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); //生成特性 foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; object obj = Activator.CreateInstance(type); //反射出类 IEvent iEvent = obj as IEvent; if (iEvent == null) //判断类是否继承IEvent接口 { Log.Error($"{obj.GetType().Name} 没有继承IEvent"); } this.RegisterEvent(aEventAttribute.Type, iEvent); //加入字典中 } } this.Load(); }
public void Add(DLLType dllType, Assembly assembly) { this.assemblies[dllType] = assembly; this.types.Clear(); foreach (Assembly value in this.assemblies.Values) { foreach (Type type in value.GetTypes()) { object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false); if (objects.Length == 0) { continue; } BaseAttribute baseAttribute = (BaseAttribute)objects[0]; this.types.Add(baseAttribute.AttributeType, type); } } this.awakeSystems.Clear(); this.lateUpdateSystems.Clear(); this.fixUpdateSystems.Clear(); this.updateSystems.Clear(); this.startSystems.Clear(); this.loadSystems.Clear(); this.changeSystems.Clear(); this.frameSystems.Clear(); foreach (Type type in types[typeof(ObjectSystemAttribute)]) { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeSystems.Add(objectSystem.Type(), objectSystem); } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateSystems.Add(updateSystem.Type(), updateSystem); } IFrameUpdateSystem frameSystem = obj as IFrameUpdateSystem; if (frameSystem != null) { this.frameSystems.Add(frameSystem.Type(), frameSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IFixUpdateSystem fixUpdateSystem = obj as IFixUpdateSystem; if (fixUpdateSystem != null) { this.fixUpdateSystems.Add(fixUpdateSystem.Type(), fixUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startSystems.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.destroySystems.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadSystems.Add(loadSystem.Type(), loadSystem); } IChangeSystem changeSystem = obj as IChangeSystem; if (changeSystem != null) { this.changeSystems.Add(changeSystem.Type(), changeSystem); } } this.allEvents.Clear(); foreach (Type type in types[typeof(ObjectSystemAttribute)]) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; object obj = Activator.CreateInstance(type); IEvent iEvent = obj as IEvent; if (iEvent == null) { Log.Error($"{obj.GetType().Name} 没有继承IEvent"); } this.RegisterEvent(aEventAttribute.Type, iEvent); } } this.Load(); }
public World Register(IUpdateSystem updateSystem) { _updateSystems.Add(updateSystem); return(this); }
public EventSystem() { this.types.Clear(); //获取所有热更新层类的Type List <Type> ts = GameEntry.ILRuntime.GetHotfixTypes(); foreach (Type type in ts) { // ILRuntime无法判断是否有Attribute //if (type.GetCustomAttributes(typeof (Attribute), false).Length == 0) //{ // continue; //} this.types.Add(type); } foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeSystems.Add(objectSystem.Type(), objectSystem); } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateSystems.Add(updateSystem.Type(), updateSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startSystems.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.destroySystems.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadSystems.Add(loadSystem.Type(), loadSystem); } IChangeSystem changeSystem = obj as IChangeSystem; if (changeSystem != null) { this.changeSystems.Add(changeSystem.Type(), changeSystem); } } this.Load(); }
public void Add(DLLType dllType, Assembly assembly) { this.assemblies[dllType] = assembly; this.awakeEvents.Clear(); this.lateUpdateEvents.Clear(); this.updateEvents.Clear(); this.startEvents.Clear(); this.loadEvents.Clear(); Type[] types = DllHelper.GetMonoTypes(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); IAwakeSystem objectSystem = obj as IAwakeSystem; if (objectSystem != null) { this.awakeEvents.Add(objectSystem.Type(), objectSystem); } IUpdateSystem updateSystem = obj as IUpdateSystem; if (updateSystem != null) { this.updateEvents.Add(updateSystem.Type(), updateSystem); } ILateUpdateSystem lateUpdateSystem = obj as ILateUpdateSystem; if (lateUpdateSystem != null) { this.lateUpdateEvents.Add(lateUpdateSystem.Type(), lateUpdateSystem); } IStartSystem startSystem = obj as IStartSystem; if (startSystem != null) { this.startEvents.Add(startSystem.Type(), startSystem); } IDestroySystem destroySystem = obj as IDestroySystem; if (destroySystem != null) { this.desdroyEvents.Add(destroySystem.Type(), destroySystem); } ILoadSystem loadSystem = obj as ILoadSystem; if (loadSystem != null) { this.loadEvents.Add(loadSystem.Type(), loadSystem); } } this.allEvents.Clear(); foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false); foreach (object attr in attrs) { EventAttribute aEventAttribute = (EventAttribute)attr; object obj = Activator.CreateInstance(type); IEvent iEvent = obj as IEvent; if (iEvent == null) { Log.Error($"{obj.GetType().Name} 没有继承IEvent"); } this.RegisterEvent(aEventAttribute.Type, iEvent); } } this.Load(); }
public void AddUpdateSystem(IUpdateSystem system) { _updateSystems.Add(system); }
/// <summary> /// The method register specialized system type which is IUpdateSystem. The systems of this type /// is executed every frame when the initialization's step is passed. Please DON'T use this method use Register /// method instead. /// </summary> /// <param name="system">A reference to ISystem implementation</param> /// <returns>An identifier of a system within the manager</returns> public SystemId RegisterSystem(IUpdateSystem system) { return(_registerSystem(system, mActiveUpdateSystems, (byte)E_SYSTEM_TYPE.ST_UPDATE)); }