Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
EntityComponentReference.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;
4 
5 using SiliconStudio.Core;
6 using SiliconStudio.Core.Serialization;
7 using SiliconStudio.Paradox.EntityModel;
8 using SiliconStudio.Paradox.EntityModel.Data;
9 
10 namespace SiliconStudio.Paradox.Data
11 {
12  public static class EntityComponentReference
13  {
14  public static EntityComponentReference<T> New<T>(Guid id, string location, PropertyKey<T> component) where T : EntityComponent
15  {
16  return new EntityComponentReference<T>(new ContentReference<EntityData>(id, location), component);
17  }
18  }
19 
20  [DataContract]
21  [DataStyle(DataStyle.Compact)]
23  {
24  // TODO: implement a serializer and pass these fields readonly (and their related properties)
25  private ContentReference<EntityData> entity;
26  private PropertyKey<T> component;
27 
29  {
30  this.entity = entity;
31  this.component = component;
32  }
33 
34  PropertyKey IEntityComponentReference.Component { get { return Component; } }
35 
36  [DataMemberIgnore]
37  public Type ComponentType { get { return typeof(T); } }
38 
39  [DataMember(10)]
40  public ContentReference<EntityData> Entity { get { return entity; } set { entity = value; } }
41 
42  [DataMember(20)]
43  public PropertyKey<T> Component { get { return component; } set { component = value; } }
44  }
45 }
Game entity. It usually aggregates multiple EntityComponent
Definition: Entity.cs:28
EntityComponentReference(ContentReference< EntityData > entity, PropertyKey< T > component)
A class that represents a typed tag propety.
Definition: PropertyKey.cs:138
A class that represents a tag propety.
Definition: PropertyKey.cs:17
DataStyle
Specifies the style used for textual serialization when an array/list or a dictionary/map must be ser...
Definition: DataStyle.cs:9