@@ -45,24 +45,29 @@ It's recommended to build your entire project around these life cycle methods.
4545Basic example usage of some of the ECS features.
4646
4747``` cs
48- public class MainController : Controller {
49- public override void OnInitialize () {
50- this .Register (typeof (EnemySystem ));
48+ public class MainController : Controller {
49+ public override void OnInitialize () {
50+ this .Register (typeof (EnemySystem , typeof ( AiSystem ), typeof ( AudioService ));
5151 }
5252}
5353
54- public class EnemyComponent : EntityComponent <EnemyComponent , EnemySystem > {
54+ public class EnemyComponent : EntityComponent < EnemyComponent , EnemySystem > {
5555 [Referenced ] public BoxCollider collider ;
5656 [Protected ] public int level ;
5757
5858 public float speed ;
5959}
6060
61- public class EnemySystem : EntitySystem <EnemySystem , EnemyComponent > {
61+ public class EnemySystem : EntitySystem < EnemySystem , EnemyComponent > {
6262 [Injected ] public AiSystem aiSystem ;
6363 [Injected ] public AudioService AudioService ;
64+
65+ public override void OnEntityInitialized (EnemyComponent entity ) {
66+ if (entity .level > 5 )
67+ entity .speed *= 2 ;
68+ }
6469
65- public override void OnUpdate () {
70+ public override void OnUpdate () {
6671 var _delta = Time .deltaTime ;
6772 foreach (var _entity in this .entities )
6873 _entity .AddPosition (_delta * _entity .speed , 0 , 0 );
0 commit comments