Esempio n. 1
0
 /// <summary>
 /// Gets the component of type <typeparamref  name="T"/> from current entity. If component does not exists, throws an exception
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T GetComponent <T>() where T : BaseComponent
 {
     return(SourceEntity.GetComponentOrDefault <T>() ?? throw new ArgumentException($"Component '{typeof(T).Name}' does not belong to current entity"));
 }
Esempio n. 2
0
 /// <summary>
 /// Gets the component of type <typeparamref  name="T"/> from current entity or default value (if component does not exist)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T GetComponentOrDefault <T>() where T : BaseComponent
 {
     return(SourceEntity.GetComponentOrDefault <T>());
 }