Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
EntityExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Collections.Generic;
4 using System.Linq;
5 using SiliconStudio.Paradox.Engine;
6 using SiliconStudio.Paradox.EntityModel;
7 using SiliconStudio.Paradox.Games;
8 using SiliconStudio.Core;
9 
10 namespace SiliconStudio.Paradox.Extensions
11 {
12  public static class EntityExtensions
13  {
14  public static IEnumerable<T> Components<T>(this IEnumerable<Entity> entities, PropertyKey<T> key) where T : EntityComponent
15  {
16  return entities.Select(x => x.Get(key)).Where(x => x != null);
17  }
18 
19  public static IEnumerable<Entity> GetChildren(this Entity entity)
20  {
21  var transformationComponent = entity.Transformation;
22  if (transformationComponent != null)
23  {
24  foreach (var child in transformationComponent.Children)
25  {
26  yield return child.Entity;
27  }
28  }
29  }
30  }
31 }
Game entity. It usually aggregates multiple EntityComponent
Definition: Entity.cs:28
A class that represents a typed tag propety.
Definition: PropertyKey.cs:138
static IEnumerable< Entity > GetChildren(this Entity entity)