Skip to content

Commit

Permalink
Modified GetBehaviours to return an empty array instead of null when …
Browse files Browse the repository at this point in the history
…nothing is found

Signed-off-by: Martin Evans <martindevans@gmail.com>
  • Loading branch information
martindevans committed Apr 29, 2014
1 parent c025528 commit b349f77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions Myre/Myre.Entities/Entity.cs
Expand Up @@ -364,7 +364,7 @@ public Behaviour[] GetBehaviours(Type type)
Behaviour[] array;
_behaviours.TryGetValue(type, out array);

return array;
return array ?? new Behaviour[0];
}

/// <summary>
Expand All @@ -385,12 +385,7 @@ public T GetBehaviour<T>(string name = null)
/// <returns></returns>
public T[] GetBehaviours<T>()
{
//return GetBehaviours(typeof(T)) as T[];
var v = GetBehaviours(typeof(T));
if (v != null)
return v.Cast<T>().ToArray();
else
return new T[0];
return GetBehaviours(typeof(T)) as T[];
}
}
}
2 changes: 1 addition & 1 deletion Myre/Myre.Entities/Properties/AssemblyInfo.cs
Expand Up @@ -30,4 +30,4 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.2.7")]
[assembly: AssemblyVersion("1.3.0")]

0 comments on commit b349f77

Please sign in to comment.