Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateCustomSet< T >()

T[] Terraria.ID.SetFactory.CreateCustomSet< T > ( T defaultState,
params object[] inputs )
inline

Definition at line 170 of file SetFactory.cs.

171 {
172 if (inputs.Length % 2 != 0)
173 {
174 throw new Exception("You have a bad length for inputs on CreateCustomSet");
175 }
176 T[] array = new T[_size];
177 for (int i = 0; i < array.Length; i++)
178 {
180 }
181 if (inputs != null)
182 {
183 for (int j = 0; j < inputs.Length; j += 2)
184 {
185 T val = (typeof(T).IsPrimitive ? ((T)inputs[j + 1]) : ((typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Nullable<>)) ? ((T)inputs[j + 1]) : ((!typeof(T).IsClass) ? ((T)Convert.ChangeType(inputs[j + 1], typeof(T))) : ((T)inputs[j + 1]))));
186 if (inputs[j] is ushort)
187 {
188 array[(ushort)inputs[j]] = val;
189 }
190 else if (inputs[j] is int)
191 {
192 array[(int)inputs[j]] = val;
193 }
194 else
195 {
196 array[(short)inputs[j]] = val;
197 }
198 }
199 }
200 return array;
201 }

References Terraria.ID.SetFactory._size, System.array, System.Convert.ChangeType(), and System.T.