コード例 #1
0
        /// <inheritdoc />
        protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, ScriptSourceFileAssetViewModel asset)
        {
            var scriptType = FindScriptType(asset.ServiceProvider, asset.AssetItem)?.FirstOrDefault();

            if (scriptType == null)
            {
                return(null);
            }

            try
            {
                return(Activator.CreateInstance(scriptType) as EntityComponent);
            }
            catch
            {
                // TODO: Display error message
                return(null);
            }
        }
コード例 #2
0
        /// <inheritdoc />
        protected override bool CanAddOrInsert(EntityHierarchyItemViewModel parent, PrefabViewModel asset, AddChildModifiers modifiers, int index, out string message, params object[] messageArgs)
        {
            var prefab = asset;

            if (prefab == parent.Asset || prefab.GatherAllBasePartAssets().Contains(parent.Asset))
            {
                message = "This prefab depends on this asset and can't be added.";
                return(false);
            }
            if (prefab.Asset.Hierarchy.Parts.Count == 0)
            {
                message = "This prefab is empty and can't be added.";
                return(false);
            }
            message = (modifiers & AddChildModifiers.Alt) != AddChildModifiers.Alt
                ? string.Format("Add the prefab to {0}\r\n(Hold Alt to add without a container entity)", messageArgs)
                : string.Format("Add the prefab to {0}\r\n(Release Alt to add with a container entity)", messageArgs);
            return(true);
        }
コード例 #3
0
        public static bool GenerateFolder([NotNull] EntityHierarchyItemViewModel parent, string path, [NotNull] IEnumerable <EntityDesign> entities)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (parent is EntityFolderViewModel)
            {
                return(false);
            }
            // Trim separator in malformed path
            path = path?.Trim(FolderSeparator);
            if (string.IsNullOrWhiteSpace(path))
            {
                return(false);
            }

            var folders          = path.Split(new[] { FolderSeparator }, StringSplitOptions.RemoveEmptyEntries);
            var folderCollection = parent.Folders;

            EntityFolderViewModel subFolder;

            foreach (var folder in folders.Take(folders.Length - 1))
            {
                subFolder = folderCollection.FirstOrDefault(x => string.Equals(x.Name, folder, FolderCase));
                if (subFolder == null)
                {
                    subFolder = new EntityFolderViewModel(parent.Editor, parent.Asset, folder, Enumerable.Empty <EntityDesign>());
                    parent.Folders.Add(subFolder);
                }
                folderCollection = subFolder.Folders;
                parent           = subFolder;
            }
            subFolder = new EntityFolderViewModel(parent.Editor, parent.Asset, folders[folders.Length - 1], entities);
            parent.Folders.Add(subFolder);
            return(true);
        }
コード例 #4
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 protected abstract AssetCompositeHierarchyData <EntityDesign, Entity> CreateEntitiesFromAsset([NotNull] EntityHierarchyItemViewModel parent, [NotNull] TAssetViewModel asset);
コード例 #5
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <inheritdoc />
 public AssetCompositeHierarchyData <EntityDesign, Entity> CreateEntitiesFromAsset(EntityHierarchyItemViewModel parent, AssetViewModel asset)
 {
     return(CreateEntitiesFromAsset(parent, (TAssetViewModel)asset));
 }
コード例 #6
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 protected abstract EntityComponent CreateComponentFromAsset([NotNull] EntityHierarchyItemViewModel parent, [NotNull] TAssetViewModel asset);
コード例 #7
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <inheritdoc />
 public EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, AssetViewModel asset)
 {
     return(CreateComponentFromAsset(parent, (TAssetViewModel)asset));
 }
コード例 #8
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <inheritdoc />
 protected override bool CanAddOrInsert(EntityHierarchyItemViewModel parent, TAssetViewModel asset, AddChildModifiers modifier, int index, out string message, params object[] messageArgs)
 {
     message = string.Format("Add the selection into {0}", messageArgs);
     return(true);
 }
コード例 #9
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <summary>
 /// Similar to <see cref="CanAddOrInsert(EntityHierarchyItemViewModel,AssetViewModel,AddChildModifiers,int,out string,object[])"/> but with the proper type for <paramref name="asset"/>.
 /// </summary>
 /// <param name="parent">The parent item where the asset will be added or inserted.</param>
 /// <param name="asset">The asset.</param>
 /// <param name="modifier">The modifier keys currently active.</param>
 /// <param name="index">The index at which the insertion occurs.</param>
 /// <param name="message">A message explaining the reason the operation is accepted or refused.</param>
 /// <param name="messageArgs">Optional arguments for the message.</param>
 /// <returns><c>true</c> if the provided <paramref name="asset"/> can be added or inserted; otherwise, <c>false</c>.</returns>
 /// <seealso cref="CanAddOrInsert(EntityHierarchyItemViewModel,AssetViewModel,AddChildModifiers,int,out string,object[])"/>
 protected abstract bool CanAddOrInsert([NotNull] EntityHierarchyItemViewModel parent, [NotNull] TAssetViewModel asset, AddChildModifiers modifier, int index, [NotNull] out string message, [NotNull] params object[] messageArgs);
コード例 #10
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <inheritdoc />
 public bool CanAddOrInsert(EntityHierarchyItemViewModel parent, AssetViewModel asset, AddChildModifiers modifier, int index, out string message, params object[] messageArgs)
 {
     return(CanAddOrInsert(parent, (TAssetViewModel)asset, modifier, index, out message, messageArgs));
 }
コード例 #11
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <summary>
 /// Similar to <see cref="ApplyPolicy(EntityHierarchyItemViewModel,IEnumerable{AssetViewModel},int,Vector3)"/> but with the proper type for <paramref name="assets"/>.
 /// </summary>
 /// <param name="parent">The parent item where the asset will be added or inserted.</param>
 /// <param name="assets">A collection of assets.</param>
 /// <param name="index">The index at which insertion should begin.</param>
 /// <param name="position"></param>
 /// <seealso cref="ApplyPolicy(EntityHierarchyItemViewModel,IEnumerable{AssetViewModel},int,Vector3)"/>
 protected abstract void ApplyPolicy([NotNull] EntityHierarchyItemViewModel parent, [ItemNotNull, NotNull] IReadOnlyCollection <TAssetViewModel> assets, int index, Vector3 position);
コード例 #12
0
ファイル: AddAssetPolicyBase.cs プロジェクト: Beefr/xenko-wd
 /// <inheritdoc />
 public void ApplyPolicy(EntityHierarchyItemViewModel parent, IEnumerable <AssetViewModel> assets, int index, Vector3 position)
 {
     ApplyPolicy(parent, assets.Cast <TAssetViewModel>().ToList(), index, position);
 }
コード例 #13
0
 protected override AssetCompositeHierarchyData <EntityDesign, Entity> CreateEntitiesFromAsset(EntityHierarchyItemViewModel parent, PrefabViewModel asset)
 {
     return(asset.Asset.CreatePrefabInstance(asset.Url));
 }