Skip to content

Commit 4eac0b0

Browse files
Minor improvements
1 parent 3e41815 commit 4eac0b0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Runtime/Controller.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,11 @@ public bool IsSystemEnabled<SystemType> () {
300300
public SystemType GetSystem<SystemType> () where SystemType : IEntitySystem, new() {
301301
var typeOf = typeof (SystemType);
302302
for (var systemIndex = 0; systemIndex < systems.Count; systemIndex++) {
303-
var system = systems[systemIndex].GetType ();
304-
if (system == typeOf) {
303+
var systemType = systems[systemIndex].GetType ();
304+
if (systemType == typeOf) {
305305
// If the system is present in the systems list, return it.
306-
return systems[systemIndex] as SystemType;
306+
var system = systems[systemIndex];
307+
return (SystemType)system;
307308
}
308309
}
309310
throw new System.Exception ($"Unable to get System of type {typeOf}, it was not registerd to the Controller");
@@ -346,16 +347,17 @@ public System.Object GetSystem (System.Type typeOf) {
346347
/// <summary>
347348
/// Gets a service from this controller.
348349
/// </summary>
349-
/// <typeparam name="SystemType">The type of the service to get.</typeparam>
350+
/// <typeparam name="ServiceType">The type of the service to get.</typeparam>
350351
/// <returns>The service of the given type.</returns>
351352
/// <exception cref="System.Exception">Thrown when the service is not registered to the controller.</exception>
352-
public SystemType GetService<SystemType> () where SystemType : IService, new() {
353-
var typeOf = typeof (SystemType);
353+
public ServiceType GetService<ServiceType> () where ServiceType : IService, new() {
354+
var typeOf = typeof (ServiceType);
354355
for (var serviceIndex = 0; serviceIndex < services.Count; serviceIndex++) {
355356
var serviceType = services[serviceIndex].GetType ();
356357
if (serviceType == typeOf) {
357358
// If the service is present in the services list, return it.
358-
return services[serviceIndex] as SystemType;
359+
var service = services[serviceIndex];
360+
return (ServiceType)service;
359361
}
360362
}
361363
throw new System.Exception ($"Unable to get Service of type {typeOf}, it was not registerd to the Controller");
@@ -381,10 +383,10 @@ public System.Object GetService (System.Type typeOf) {
381383
/// <summary>
382384
/// Check whether this controller has a service.
383385
/// </summary>
384-
/// <typeparam name="SystemType">The type of the service to check.</typeparam>
386+
/// <typeparam name="ServiceType">The type of the service to check.</typeparam>
385387
/// <returns>Whether this controller has a service of the given type.</returns>
386-
public bool HasService<SystemType> () where SystemType : IService, new() {
387-
var typeOf = typeof (SystemType);
388+
public bool HasService<ServiceType> () where ServiceType : IService, new() {
389+
var typeOf = typeof (ServiceType);
388390
for (var serviceIndex = 0; serviceIndex < services.Count; serviceIndex++) {
389391
var serviceType = services[serviceIndex].GetType ();
390392
if (serviceType == typeOf) {

0 commit comments

Comments
 (0)