Esempio n. 1
0
 // TODO: turn this non-static and put it in the base - just keep the entity-specific part here. This need to rework a bit how we initialize folders
 private static IEnumerable <EntityDesign> GetOrCreateChildPartDesigns([NotNull] EntityHierarchyAssetBase asset, [NotNull] EntityDesign entityDesign)
 {
     foreach (var child in entityDesign.Entity.Transform.Children)
     {
         if (!asset.Hierarchy.Parts.TryGetValue(child.Entity.Id, out EntityDesign childDesign))
         {
             childDesign = new EntityDesign(child.Entity);
         }
         if (child.Entity != childDesign.Entity)
         {
             throw new InvalidOperationException();
         }
         yield return(childDesign);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a instance of this prefab that can be added to another <see cref="EntityHierarchyAssetBase"/>.
 /// </summary>
 /// <param name="targetContainer">The container in which the instance will be added.</param>
 /// <param name="targetLocation">The location of this asset.</param>
 /// <param name="instanceId">The identifier of the created instance.</param>
 /// <returns>An <see cref="AssetCompositeHierarchyData{EntityDesign, Entity}"/> containing the cloned entities of </returns>
 /// <remarks>This method will update the <see cref="Asset.BaseParts"/> property of the <see paramref="targetContainer"/>.</remarks>
 public AssetCompositeHierarchyData<EntityDesign, Entity> CreatePrefabInstance(EntityHierarchyAssetBase targetContainer, string targetLocation, out Guid instanceId)
 {
     var instance = (PrefabAsset)CreateDerivedAsset(targetLocation);
     instanceId = instance.Hierarchy.Parts.FirstOrDefault()?.Base.InstanceId ?? Guid.NewGuid();
     return instance.Hierarchy;
 }
Esempio n. 3
0
 /// <summary>
 /// Fixups the entity references, by clearing invalid <see cref="EntityReference.Id"/>, and updating <see cref="EntityReference.Value"/> (same for components).
 /// </summary>
 /// <param name="entityAssetBase">The entity asset.</param>
 public static void FixupEntityReferences(EntityHierarchyAssetBase entityAssetBase)
 {
     FixupEntityReferences(entityAssetBase, entityAssetBase.Hierarchy);
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a instance of this prefab that can be added to another <see cref="EntityHierarchyAssetBase"/>.
 /// </summary>
 /// <param name="targetContainer">The container in which the instance will be added.</param>
 /// <param name="targetLocation">The location of the <see paramref="targetContainer"/> asset.</param>
 /// <returns>An <see cref="AssetCompositeHierarchyData{EntityDesign, Entity}"/> containing the cloned entities of </returns>
 /// <remarks>This method will update the <see cref="Asset.BaseParts"/> property of the <see paramref="targetContainer"/>.</remarks>
 public AssetCompositeHierarchyData<EntityDesign, Entity> CreatePrefabInstance(EntityHierarchyAssetBase targetContainer, string targetLocation)
 {
     Guid unused;
     return CreatePrefabInstance(targetContainer, targetLocation, out unused);
 }