Skip to content

Commit 2285d45

Browse files
Added Controller Guard to stand-alone classes
1 parent 70fedf8 commit 2285d45

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Runtime/EntityComponent.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ElRaccoone.EntityComponentSystem {
66
/// </summary>
77
/// <typeparam name="EntityComponentType">The Entity Component type.</typeparam>
88
/// <typeparam name="EntitySystemType">The Entity System type.</typeparam>
9-
public abstract class EntityComponent<EntityComponentType, EntitySystemType> : UnityEngine.MonoBehaviour, IEntityComponent, IEntityComponentInternals
9+
public abstract class EntityComponent<EntityComponentType, EntitySystemType> : MonoBehaviour, IEntityComponent, IEntityComponentInternals
1010
where EntityComponentType : EntityComponent<EntityComponentType, EntitySystemType>, new()
1111
where EntitySystemType : EntitySystem<EntitySystemType, EntityComponentType>, new() {
1212
/// <summary>
@@ -78,6 +78,9 @@ public Vector3 localScale {
7878
/// <returns>The system.</returns>
7979
/// <exception cref="System.Exception"></exception>
8080
EntitySystemType GetSystem () {
81+
if (Controller.Instance == null) {
82+
throw new System.Exception ("Tried to access the Controller while non is instantiated");
83+
}
8184
if (system != null)
8285
return system;
8386
if (Controller.Instance.HasSystem<EntitySystemType> ()) {

0 commit comments

Comments
 (0)