4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Serialization;
6 using SiliconStudio.Core.Serialization.Converters;
7 using SiliconStudio.Paradox.Engine;
8 using SiliconStudio.Paradox.EntityModel;
9 using SiliconStudio.Paradox.EntityModel.Data;
11 namespace SiliconStudio.
Paradox.Data
13 internal class EntityComponentReferenceDataConverter<TSource> :
DataConverter<EntityComponentReference<TSource>, TSource>
16 public override bool CacheResult
21 public override void ConvertFromData(
ConverterContext converterContext, EntityComponentReference<TSource> componentReference, ref TSource component)
24 var entity = converterContext.ConvertFromData<
Entity>(componentReference.Entity);
27 component = entity.Get(componentReference.Component);
30 public override void ConvertToData(
ConverterContext converterContext, ref EntityComponentReference<TSource> componentReference, TSource component)
33 converterContext.ConvertToData(ref entityReference, component.Entity);
37 if (component.Entity == null)
38 throw new InvalidOperationException(
"Entity of a referenced component can't be null");
40 foreach (var entityComponent
in component.Entity.Tags)
43 && entityComponent.Value == component)
49 if (componentKey == null)
50 throw new InvalidOperationException(
"Could not find the component in its entity");
52 componentReference =
new EntityComponentReference<TSource>(entityReference, componentKey);
Game entity. It usually aggregates multiple EntityComponent
Base class for converters to/from a data type.
A class that represents a tag propety.