Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MaterialReferenceNode.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.Collections.Generic;
4 using SiliconStudio.Core;
5 using SiliconStudio.Core.Serialization.Contents;
6 
7 namespace SiliconStudio.Paradox.Assets.Materials.Nodes
8 {
9  [ContentSerializer(typeof(DataContentSerializer<MaterialReferenceNode>))]
10  [DataContract("MaterialReferenceNode")]
12  {
13  /// <summary>
14  /// Initializes a new instance of the <see cref="MaterialReferenceNode"/> class.
15  /// </summary>
17  {
18  }
19 
20  /// <summary>
21  /// Initializes a new instance of the <see cref="MaterialReferenceNode"/> class.
22  /// </summary>
23  /// <param name="name">The name.</param>
24  public MaterialReferenceNode(string name)
25  {
26  Name = name;
27  }
28 
29  /// <summary>
30  /// Gets or sets the name this instance is linked to.
31  /// </summary>
32  /// <value>The name.</value>
33  /// <userdoc>
34  /// The name of the referenced node.
35  /// </userdoc>
36  [DataMember(10)]
37  public string Name { get; set; }
38 
39  /// <inheritdoc/>
40  public override IEnumerable<MaterialNodeEntry> GetChildren(object context = null)
41  {
42  var materialContext = context as MaterialContext;
43  if (materialContext != null && Name != null)
44  {
45  IMaterialNode materialNode;
46  if (materialContext.Material.Nodes.TryGetValue(Name, out materialNode))
47  {
48  if (materialNode != null && materialNode != this)
49  yield return new MaterialNodeEntry(materialNode, node => { });
50  }
51  }
52  }
53 
54  /// <inheritdoc/>
55  public override string ToString()
56  {
57  return "Reference";
58  }
59  }
60 }
An entry to a nested IMaterialNode
MaterialReferenceNode(string name)
Initializes a new instance of the MaterialReferenceNode class.
override IEnumerable< MaterialNodeEntry > GetChildren(object context=null)
Gets the children. The context to get the children.The list of children.
MaterialReferenceNode()
Initializes a new instance of the MaterialReferenceNode class.
Base interface for all nodes in the material tree