private void Start() { module = FrameworkModule.CreatInstance <ECSModule>("", ""); module.SubscribeSystem(new PlayerSystem(module)); module.SubscribeSystem(new PCSystem(module)); var player = module.CreateEntity <SimpleEntity>(); player.AddComponent <PlayerComponent>(); var playerRO = player.AddComponent <RotaComponet>(); playerRO.go = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube); playerRO.go.name = "Player"; playerRO.go.transform.position = new UnityEngine.Vector3(0, -2, 0); var pc = module.CreateEntity <SimpleEntity>(); pc.AddComponent <SpeedComponent>(); pc.AddComponent <PCComponent>(); var pcRO = pc.AddComponent <RotaComponet>(); pcRO.go = UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube); pcRO.go.name = "Pc"; pcRO.go.transform.position = new UnityEngine.Vector3(0, 2, 0); }
/// <summary> /// 添加组 /// </summary> /// <param name="group"></param> public void AddGroup(MVPGroup group) { MVPGroup _group = FindGroup(name); if (_group != null) { throw new Exception("Have Add Group " + group.name); } else { group.module = this; _groupmap.Add(group.name, group); group.sensor.message = _message; group.policy.message = _message; group.executor.message = _message; group.view.message = _message; _ecs.SubscribeEnity(group.enity); _ecs.SubscribeSystem(group.sensor); _ecs.SubscribeSystem(group.policy); _ecs.SubscribeSystem(group.executor); _ecs.SubscribeSystem(group.view); } }