11namespace ElRaccoone . EntityComponentSystem {
22
33 /// Base class for every entity system.
4- public abstract class EntitySystem < EntitySystemType , EntityComponentType > : IEntitySystem
4+ public abstract class EntitySystem < EntitySystemType , EntityComponentType > : IEntitySystem , IEntitySystemInternals
55 where EntitySystemType : EntitySystem < EntitySystemType , EntityComponentType > , new ( )
66 where EntityComponentType : EntityComponent < EntityComponentType , EntitySystemType > , new ( ) {
77
@@ -132,25 +132,8 @@ public void StopCoroutine (UnityEngine.Coroutine routine) =>
132132 public void SetEnabled ( bool value ) =>
133133 Controller . Instance . SetSystemEnabled < EntitySystemType > ( value ) ;
134134
135- /// Internal method to set the instance reference. This method will
136- /// be called after the controller and system initialization.
137- public void Internal_OnInitialize ( ) =>
138- Instance = Controller . Instance . GetSystem < EntitySystemType > ( ) ;
139-
140- /// Internal method to update the children of the system.
141- public void Internal_OnUpdate ( ) {
142- if ( this . isInitialized == false ) {
143- this . OnInitialized ( ) ;
144- if ( Controller . Instance . IsSystemEnabled < EntitySystemType > ( ) == true )
145- this . OnEnabled ( ) ;
146- this . isInitialized = true ;
147- }
148- for ( var _entityIndex = 0 ; _entityIndex < this . entityCount ; _entityIndex ++ )
149- this . entities [ _entityIndex ] . Internal_OnUpdate ( ) ;
150- }
151-
152135 /// Internal method to add an entity's component to this system.
153- public void Internal_AddEntity ( EntityComponentType component ) {
136+ internal void AddEntity ( EntityComponentType component ) {
154137 if ( this . hasEntities == false )
155138 this . entity = component ;
156139 this . entityCount ++ ;
@@ -160,12 +143,29 @@ public void Internal_AddEntity (EntityComponentType component) {
160143 }
161144
162145 /// Internal method to remove an entity's component from this system.
163- public void Internal_RemoveEntry ( EntityComponentType component ) {
146+ internal void RemoveEntry ( EntityComponentType component ) {
164147 this . entityCount -- ;
165148 this . hasEntities = this . entityCount > 0 ;
166149 this . OnEntityWillDestroy ( component ) ;
167150 this . entities . Remove ( component ) ;
168151 this . entity = this . hasEntities == false ? null : this . entities [ 0 ] ;
169152 }
153+
154+ /// Internal method to set the instance reference. This method will
155+ /// be called after the controller and system initialization.
156+ void IEntitySystemInternals . OnInitializeInternal ( ) =>
157+ Instance = Controller . Instance . GetSystem < EntitySystemType > ( ) ;
158+
159+ /// Internal method to update the children of the system.
160+ void IEntitySystemInternals . OnUpdateInternal ( ) {
161+ if ( this . isInitialized == false ) {
162+ this . OnInitialized ( ) ;
163+ if ( Controller . Instance . IsSystemEnabled < EntitySystemType > ( ) == true )
164+ this . OnEnabled ( ) ;
165+ this . isInitialized = true ;
166+ }
167+ for ( var _entityIndex = 0 ; _entityIndex < this . entityCount ; _entityIndex ++ )
168+ ( this . entities [ _entityIndex ] as IEntityComponentInternals ) . OnUpdateInternal ( ) ;
169+ }
170170 }
171171}
0 commit comments