Sets the integer value of the specified parent node. Handles type casting and components assignment. The parent node. The node element archetype. The value to set.
(SurfaceNode parentNode, NodeElementArchetype arch, int toSet)
| 107 | /// <param name="arch">The node element archetype.</param> |
| 108 | /// <param name="toSet">The value to set.</param> |
| 109 | public static void Set(SurfaceNode parentNode, NodeElementArchetype arch, int toSet) |
| 110 | { |
| 111 | if (arch.ValueIndex < 0) |
| 112 | return; |
| 113 | |
| 114 | var value = parentNode.Values[arch.ValueIndex]; |
| 115 | float toSetF = (float)toSet; |
| 116 | |
| 117 | if (value is int) |
| 118 | value = toSet; |
| 119 | else if (value is uint) |
| 120 | value = (uint)toSet; |
| 121 | else if (value is long) |
| 122 | value = (long)toSet; |
| 123 | else if (value is ulong) |
| 124 | value = (ulong)toSet; |
| 125 | else if (value is float) |
| 126 | value = toSetF; |
| 127 | else if (value is Vector2 asVector2) |
| 128 | { |
| 129 | if (arch.BoxID == 0) |
| 130 | asVector2.X = toSetF; |
| 131 | else |
| 132 | asVector2.Y = toSetF; |
| 133 | value = asVector2; |
| 134 | } |
| 135 | else if (value is Vector3 asVector3) |
| 136 | { |
| 137 | if (arch.BoxID == 0) |
| 138 | asVector3.X = toSetF; |
| 139 | else if (arch.BoxID == 1) |
| 140 | asVector3.Y = toSetF; |
| 141 | else |
| 142 | asVector3.Z = toSetF; |
| 143 | value = asVector3; |
| 144 | } |
| 145 | else if (value is Vector4 asVector4) |
| 146 | { |
| 147 | if (arch.BoxID == 0) |
| 148 | asVector4.X = toSetF; |
| 149 | else if (arch.BoxID == 1) |
| 150 | asVector4.Y = toSetF; |
| 151 | else if (arch.BoxID == 2) |
| 152 | asVector4.Z = toSetF; |
| 153 | else |
| 154 | asVector4.W = toSetF; |
| 155 | value = asVector4; |
| 156 | } |
| 157 | else |
| 158 | value = 0; |
| 159 | |
| 160 | parentNode.SetValue(arch.ValueIndex, value); |
| 161 | } |
| 162 | } |
| 163 | } |