public EntityRemapEntry(EntityDesign entityDesign, EntityHierarchyData hierarchy) { Hierarchy = hierarchy; if (entityDesign == null) { throw new ArgumentNullException(nameof(entityDesign)); } EntityDesign = entityDesign; }
/// <inheritdoc /> public bool Equals(EntityDesign other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(Folder, other.Folder, StringComparison.OrdinalIgnoreCase) && Entity.Equals(other.Entity) && Equals(Base, other.Base)); }
public EntityEntry(EntityDesign entityDesign, AssetCompositeHierarchyData <EntityDesign, Entity> hierarchy, int order) { if (entityDesign == null) { throw new ArgumentNullException(nameof(entityDesign)); } Order = order; Hierarchy = hierarchy; EntityDesign = entityDesign; // Remove children from transform component in order to process them later PushChildren(); }
public IEnumerable <EntityDesign> EnumerateChildren(EntityDesign entityDesign, bool isRecursive) { var transformationComponent = entityDesign.Entity.Transform; if (transformationComponent == null) { yield break; } foreach (var child in transformationComponent.Children) { var childEntityDesign = Hierarchy.Entities[child.Entity.Id]; yield return(childEntityDesign); if (isRecursive) { foreach (var childChild in EnumerateChildren(childEntityDesign, true)) { var childChildEntityDesign = Hierarchy.Entities[childChild.Entity.Id]; yield return(childChildEntityDesign); } } } }
private void FixReferencesToEntities(EntityDesign newEntityDesign, Dictionary <GroupPartKey, Guid> mapBaseIdToNewId) { var newEntity = newEntityDesign.Entity; // We need to visit all references to entities/components in order to fix references // (e.g entities removed, entity added from base referencing an entity from base that we have to redirect to the new child entity...) // Suppose for example that: // // base newBase newAsset // EA EA EA' // EB EB EB' // EC EC EC' // ED (+link to EA via script or whather) ED' + link to EA' (we need to change from EA to EA') // // So in the example above, when merging ED into newAsset, all references to entities declared in newBase are not automatically // remapped to the new entities in newAsset. This is the purpose of this whole method var entityVisitor = new SingleLevelVisitor(typeof(Entity), true); var entityComponentVisitor = new SingleLevelVisitor(typeof(EntityComponent), true); DataVisitNodeBuilder.Run(TypeDescriptorFactory.Default, newEntity, new List <IDataCustomVisitor>() { entityVisitor, entityComponentVisitor }); // Fix Entity and EntityComponent references foreach (var idNodes in entityVisitor.References.Concat(entityComponentVisitor.References)) { var id = idNodes.Key; var nodes = idNodes.Value; // If entity id is not in the current list, it is more likely that it was a link to a base entity if (!newAsset.Hierarchy.Entities.ContainsKey(id)) { var groupKey = new GroupPartKey(newEntityDesign.Design.BasePartInstanceId, id); // We are trying to remap the base id to the new id from known entities from newAsset Guid newId; if (mapBaseIdToNewId.TryGetValue(groupKey, out newId)) { var linkedEntity = newAsset.Hierarchy.Entities[newId].Entity; foreach (var node in nodes) { var entityComponent = node.Instance as EntityComponent; if (entityComponent != null) { // TODO: In case of a DataVisitMember node, we need to set an OverrideType to New if we are actually removing a base value var newEntityComponent = (EntityComponent)linkedEntity.Components.Get(entityComponent.GetDefaultKey()); node.SetValue(newEntityComponent); } else { // TODO: In case of a DataVisitMember node, we need to set an OverrideType to New if we are actually removing a base value // Else the node applies to an entity node.SetValue(linkedEntity); } } } else { // TODO: In case of a DataVisitMember node, we need to set an OverrideType to New if we are actually removing a base value // If we are trying to link to an entity/component that was removed, we need to remove it foreach (var node in nodes) { node.RemoveValue(); } } } } }
public NewEntityEntry(EntityDesign entityDesign, AssetCompositeHierarchyData <EntityDesign, Entity> hierarchy, int order) : base(entityDesign, hierarchy, order) { }
public NewEntityEntry(EntityDesign entityDesign, EntityHierarchyData hierarchy, int order) : base(entityDesign, hierarchy, order) { }