Skip to content

Commit

Permalink
Added Controller Guard to stand-alone classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylanters committed Mar 26, 2023
1 parent 70fedf8 commit 2285d45
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Runtime/EntityComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ElRaccoone.EntityComponentSystem {
/// </summary>
/// <typeparam name="EntityComponentType">The Entity Component type.</typeparam>
/// <typeparam name="EntitySystemType">The Entity System type.</typeparam>
public abstract class EntityComponent<EntityComponentType, EntitySystemType> : UnityEngine.MonoBehaviour, IEntityComponent, IEntityComponentInternals
public abstract class EntityComponent<EntityComponentType, EntitySystemType> : MonoBehaviour, IEntityComponent, IEntityComponentInternals
where EntityComponentType : EntityComponent<EntityComponentType, EntitySystemType>, new()
where EntitySystemType : EntitySystem<EntitySystemType, EntityComponentType>, new() {
/// <summary>
Expand Down Expand Up @@ -78,6 +78,9 @@ public Vector3 localScale {
/// <returns>The system.</returns>
/// <exception cref="System.Exception"></exception>
EntitySystemType GetSystem () {
if (Controller.Instance == null) {
throw new System.Exception ("Tried to access the Controller while non is instantiated");
}
if (system != null)
return system;
if (Controller.Instance.HasSystem<EntitySystemType> ()) {
Expand Down

0 comments on commit 2285d45

Please sign in to comment.