Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParameterKeyMetadata.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 SiliconStudio.Core;
4 
5 namespace SiliconStudio.Paradox.Effects
6 {
7  public abstract class ParameterKeyMetadata : PropertyKeyMetadata
8  {
9  public abstract object GetDefaultValue();
10 
11  public abstract void SetupDefaultValue(ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies);
12 
13  public abstract ParameterDynamicValue DefaultDynamicValue { get; }
14  }
15 
16  /// <summary>
17  /// Metadata used for <see cref="ParameterKey"/>
18  /// </summary>
20  {
21  /// <summary>
22  /// Initializes a new instance of the <see cref="ParameterKeyMetadata"/> class.
23  /// </summary>
25  {
26  }
27 
28  /// <summary>
29  /// Initializes a new instance of the <see cref="ParameterKeyMetadata"/> class.
30  /// </summary>
31  /// <param name="setupDelegate">The setup delegate.</param>
32  public ParameterKeyMetadata(T defaultValue)
33  {
34  DefaultValue = defaultValue;
35  }
36 
37  /// <summary>
38  /// Initializes a new instance of the <see cref="ParameterKeyMetadata&lt;T&gt;"/> class.
39  /// </summary>
40  /// <param name="defaultDynamicValue">The default dynamic value.</param>
41  public ParameterKeyMetadata(ParameterDynamicValue<T> defaultDynamicValue)
42  {
43  DefaultDynamicValueT = defaultDynamicValue;
44  }
45 
46  /// <summary>
47  /// Gets the default value.
48  /// </summary>
49  public readonly T DefaultValue;
50 
51  protected ParameterDynamicValue<T> DefaultDynamicValueT { get; set; }
52 
53  public override ParameterDynamicValue DefaultDynamicValue
54  {
55  get { return DefaultDynamicValueT; }
56  }
57 
58  public override object GetDefaultValue()
59  {
60  return DefaultValue;
61  }
62 
63  public override void SetupDefaultValue(ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies)
64  {
65  if (DefaultDynamicValueT != null)
66  {
67  if (addDependencies)
68  {
69  foreach (var dependencyKey in DefaultDynamicValueT.Dependencies)
70  parameterCollection.RegisterParameter(dependencyKey, addDependencies);
71  }
72  parameterCollection.AddDynamic((ParameterKey<T>)parameterKey, DefaultDynamicValueT);
73  }
74  else
75  {
76  parameterCollection.Set((ParameterKey<T>)parameterKey, DefaultValue);
77  }
78  }
79  }
80 }
81 
Key of an effect parameter.
Definition: ParameterKey.cs:15
Key of an gereric effect parameter.
ParameterKeyMetadata(T defaultValue)
Initializes a new instance of the ParameterKeyMetadata class.
ParameterKeyMetadata(ParameterDynamicValue< T > defaultDynamicValue)
Initializes a new instance of the ParameterKeyMetadata<T> class.
Base class for ParameterDynamicValue{T}.
override void SetupDefaultValue(ParameterCollection parameterCollection, ParameterKey parameterKey, bool addDependencies)
ParameterKeyMetadata()
Initializes a new instance of the ParameterKeyMetadata class.
Specifies metadata for an PropertyKey.
A container to handle a hierarchical collection of effect variables.