|  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Game | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public class EcsManager : ManagerBase<EcsManager> | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         private GameEntity _master; | 
					
						
							|  |  |  |         private GameEntity _masterSoul; | 
					
						
							|  |  |  |         private GameSystems _systems; | 
					
						
							|  |  |  |         private GameFixedSystems _fixedSystems; | 
					
						
							|  |  |  |         private GameLateSystems _lateSystems; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public override void OnCreate() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _systems = new GameSystems(); | 
					
						
							|  |  |  |             _systems.Initialize(); | 
					
						
							|  |  |  |             _fixedSystems = new GameFixedSystems(); | 
					
						
							|  |  |  |             _fixedSystems.Initialize(); | 
					
						
							|  |  |  |             _lateSystems = new GameLateSystems(); | 
					
						
							|  |  |  |             _lateSystems.Initialize(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public override void Update() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _systems.Execute(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public override void FixedUpdate() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _fixedSystems.Execute(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public override void LateUpdate() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _lateSystems.Execute(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public override void OnDestroy() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _systems.Cleanup(); | 
					
						
							|  |  |  |             _fixedSystems.Cleanup(); | 
					
						
							|  |  |  |             _lateSystems.Cleanup(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public void CreateMaster() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Util.CreateEntityImmediately(GameConst.MasterId, (entity) => { _master = entity; }); | 
					
						
							|  |  |  |             Util.CreateEntityImmediately(GameConst.MasterSoulId, (entity) => { _masterSoul = entity; }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public GameEntity GetMaster() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return _master; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public int GetMasterID() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return _master?.ID() ?? 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public GameEntity GetMasterSoul() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return _masterSoul; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public int GetMasterSoulID() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return _masterSoul?.ID() ?? 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         public void GetAllEnemies(List<int> allEnemies) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var entities = Util.GetGroup(GameMatcher.Hp); | 
					
						
							|  |  |  |             allEnemies.Clear(); | 
					
						
							|  |  |  |             foreach (var entity in entities) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if (entity.Team() == ETeam.Monster) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     allEnemies.Add(entity.ID()); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public sealed class GameSystems : Feature | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public GameSystems() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             //实体创建 | 
					
						
							|  |  |  |             Add(new EntityCreateSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //玩家操作 | 
					
						
							|  |  |  |             Add(new InputSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //非玩家操作 | 
					
						
							|  |  |  |             Add(new AIDirectorSystem()); | 
					
						
							|  |  |  |             Add(new AISystem()); | 
					
						
							|  |  |  |             Add(new MasterSoulSystem()); | 
					
						
							|  |  |  |             Add(new PointSystem()); | 
					
						
							|  |  |  |             Add(new BulletSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //技能 | 
					
						
							|  |  |  |             Add(new ComboLockSystem()); | 
					
						
							|  |  |  |             Add(new ComboSystem()); | 
					
						
							|  |  |  |             Add(new TimelineSystem()); | 
					
						
							|  |  |  |             Add(new InteractSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //通用 | 
					
						
							|  |  |  |             Add(new MoveSystem()); | 
					
						
							|  |  |  |             Add(new AnimationSystem()); | 
					
						
							|  |  |  |             Add(new BuffSystem()); | 
					
						
							|  |  |  |             Add(new RecoverSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //结算 | 
					
						
							|  |  |  |             Add(new SettleSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //表现 | 
					
						
							|  |  |  |             Add(new PauseSystem()); | 
					
						
							|  |  |  |             Add(new ShadowSystem()); | 
					
						
							|  |  |  |             Add(new ViewSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //死亡 | 
					
						
							|  |  |  |             Add(new DieSystem()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             //实体删除 | 
					
						
							|  |  |  |             Add(new EntityDestroySystem()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public sealed class GameFixedSystems : Feature | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public GameFixedSystems() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Add(new MoveSystemFixed()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public sealed class GameLateSystems : Feature | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public GameLateSystems() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Add(new ViewLateSystem()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |