Skip to content

Commit e8e9001

Browse files
Sync
1 parent 4524482 commit e8e9001

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,70 @@ It's recommended to build your entire project around these life cycle methods.
6060

6161
**Introduction:** The controller is the core of your application, it is of such importance that each application should only contain one of it. The controller is where your application will start from and all systems and services are registered. This can only be done during the OnInitialize method using the controller's Register method. To get started with your first controller you can use the generator, for the controller to work it should be assined to a game object in your scene.
6262

63+
```csharp
64+
public class MainController : Controller { }
65+
```
66+
67+
**Virtual OnInitialize:** The controller consists of an OnInitialize virtual method. This method can be overwritten and will be invoked during the very start of your application. During this cycle none [injectables](#Injectables) or [assets](#Assets) are being assigned, it is important to invoke the Register method during this cycle since this is the only time in your application you can register [systems](#Systems) and [services](#Services).
68+
6369
```csharp
6470
public class MainController : Controller {
6571
public override void OnInitialize () {
6672
this.Register (
67-
typeof (EnemyMovementSystem),
73+
typeof (MovementSystem),
6874
typeof (AudioService)
6975
);
7076
}
7177
}
7278
```
7379

74-
**Virtual OnInitialized:** The controller consists of a OnInitialized virtual method. This method can be overwritten and will be invoked during the very first start of your application. It is important to invoke the Register method during this cycle since this is the only time in your application you can register [systems](#Systems) and [services](#Services).
80+
**Virtual OnInitialized:** The controller consists of an OnInitialized virtual method. This method can be overwritten and will be invoked when all [systems](#Systems) and [services](#Services) did initialize and all [injectables](#Injectables) and [assets](#Assets) properties are assigned.
81+
82+
```csharp
83+
public class MainController : Controller {
84+
public override void OnInitialized () { }
85+
}
86+
```
87+
88+
**Virtual OnUpdate:** The controller consists of an OnUpdate virtual method. This method can be overwritten and will be invoked during the update cycle. This cycle will run once every frame, the controller's Update is invoked before the [system's](#Systems) and [service's](#Services) update cycles.
89+
90+
```csharp
91+
public class MainController : Controller {
92+
public override void OnUpdate () { }
93+
}
94+
```
95+
96+
**Enabling Systems:** To enable or disable [systems](#Systems), the controller contains of a method EnableSystem which allows [systems](#Systems) to stop their life cycle methods such as OnUpdate, OnPhysics, OnDrawGui and others.
97+
98+
```csharp
99+
public class MainController : Controller {
100+
public void DoSomething () {
101+
this.SetSystemEnabled<MovementSystem>(true);
102+
this.SetSystemEnabled<InteractableSystem>(false);
103+
}
104+
}
105+
```
106+
107+
**Is System Enabled:** To check wether [systems](#Systems) are enable or disabled, the controller contains of a method IsSystemEnabled. Invoking the method will return a booling informing if the [systems](#Systems) is enabled or not.
108+
109+
```csharp
110+
public class MainController : Controller {
111+
public void DoSomething () {
112+
if (this.IsSystemEnabled<MovementSystem>()) { }
113+
}
114+
}
115+
```
116+
117+
**Injection:** The controller can be be used as an [injected](#Injectables) property and allows insertion of other [injected](#Injectables) [systems](#Systems) and [services](#Services) properties. When being injected, all public methods and properties are accessibly.
75118

76119
```csharp
77120
public class MainController : Controller {
78-
public override void OnInitialize () { }
121+
[Injected] private MovementSystem movementSystem;
122+
[Injected] private AudioService audioService;
79123
}
80124
```
81125

82-
**Notes:** While it is recommended to move as much logic into [services](#Services) and [systems](#Systems), it is possible to let your controller house any functionality. If you use the controller for this purpose, try to keep it down to only application wide and core functionality. All public methods and properties are accessibly when having the controller [injected](#Injectables).
126+
**Notes:** While it is recommended to move as much logic into [services](#Services) and [systems](#Systems), it is possible to let your controller house any functionality. If you use the controller for this purpose, try to keep it down to only application wide and core functionality.
83127

84128
### Systems
85129

0 commit comments

Comments
 (0)