Load unit data from ra.yaml

This commit is contained in:
Bob
2010-01-09 22:50:56 +13:00
parent 454e3a9ca9
commit 0b6a05fcee
13 changed files with 1707 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using OpenRa.FileFormats;
using System.Collections.Generic;
namespace OpenRa.Game.GameRules
{
@@ -15,6 +16,39 @@ namespace OpenRa.Game.GameRules
}
}
public static void CheckYaml( object self, Dictionary<string, MiniYaml> d )
{
//foreach( var x in d )
//{
// if( x.Key == "Tab" ) continue;
// if( x.Key == "Description" ) continue;
// if( x.Key == "LongDesc" ) continue;
// var key = x.Key;
// if( key == "Prerequisites" ) key = "Prerequisite";
// if( key == "HP" ) key = "Strength";
// if( key == "Priority" ) key = "SelectionPriority";
// if( key == "Bounds" ) key = "SelectionSize";
// var field = self.GetType().GetField( key );
// var old = field.GetValue( self );
// var neww = GetValue( field.FieldType, x.Value.Value.Trim() );
// if( old.ToString() != neww.ToString() )
// throw new NotImplementedException();
//}
foreach( var x in d )
{
var key = x.Key;
if( key == "Tab" )
continue;
if( key == "Prerequisites" ) key = "Prerequisite";
if( key == "HP" ) key = "Strength";
if( key == "Priority" ) key = "SelectionPriority";
if( key == "Bounds" ) key = "SelectionSize";
var field = self.GetType().GetField( key.Trim() );
field.SetValue( self, GetValue( field.FieldType, x.Value.Value.Trim() ) );
}
}
static object GetValue( Type fieldType, string x )
{
if( fieldType == typeof( int ) )