Entitas  0.35.0
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
BlueprintEntityExtension.cs
2 
3 namespace Entitas {
4 
5  public partial class Entity {
6 
7  /// Adds all components from the blueprint to the entity.
8  /// When 'replaceComponents' is set to true entity.ReplaceComponent()
9  /// will be used instead of entity.AddComponent().
10  public Entity ApplyBlueprint(Blueprint blueprint,
11  bool replaceComponents = false) {
12  var componentsLength = blueprint.components.Length;
13  for (int i = 0; i < componentsLength; i++) {
14  var componentBlueprint = blueprint.components[i];
15  if(replaceComponents) {
16  ReplaceComponent(componentBlueprint.index,
17  componentBlueprint.CreateComponent(this));
18  } else {
19  AddComponent(componentBlueprint.index,
20  componentBlueprint.CreateComponent(this));
21  }
22  }
23 
24  return this;
25  }
26  }
27 }
Entity ReplaceComponent(int index, IComponent component)
Definition: Entity.cs:178
Entity ApplyBlueprint(Blueprint blueprint, bool replaceComponents=false)
Entity AddComponent(int index, IComponent component)
Definition: Entity.cs:114