Support non-int Enum types in the Lua API.

This commit is contained in:
Paul Chote
2018-11-04 10:55:28 +00:00
committed by reaperrr
parent d653614e75
commit 2064dc7c30
2 changed files with 14 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.Common.Scripting
var genericType = initType.GetInterfaces()
.First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IActorInit<>));
var innerType = genericType.GetGenericArguments().First();
var valueType = innerType.IsEnum ? typeof(int) : innerType;
var valueType = innerType.IsEnum ? Enum.GetUnderlyingType(innerType) : innerType;
// Try and coerce the table value to the required type
object value;