testing Inherits; seems to work. Also, the Converter knows a bit about Inherits now.
This commit is contained in:
@@ -20,19 +20,27 @@ namespace OpenRa.Game.GameRules
|
||||
Traits.Add( LoadTraitInfo( t.Key, t.Value ) );
|
||||
}
|
||||
|
||||
static MiniYaml MergeWithParent( MiniYaml node, Dictionary<string, MiniYaml> allUnits )
|
||||
static MiniYaml GetParent( MiniYaml node, Dictionary<string, MiniYaml> allUnits )
|
||||
{
|
||||
MiniYaml inherits;
|
||||
node.Nodes.TryGetValue( "Inherits", out inherits );
|
||||
if( inherits == null || string.IsNullOrEmpty( inherits.Value ) )
|
||||
return node;
|
||||
return null;
|
||||
|
||||
MiniYaml parent;
|
||||
allUnits.TryGetValue( inherits.Value, out parent );
|
||||
if( parent == null )
|
||||
return node;
|
||||
return null;
|
||||
|
||||
return MiniYaml.Merge( node, MergeWithParent( parent, allUnits ) );
|
||||
return parent;
|
||||
}
|
||||
|
||||
static MiniYaml MergeWithParent( MiniYaml node, Dictionary<string, MiniYaml> allUnits )
|
||||
{
|
||||
var parent = GetParent( node, allUnits );
|
||||
if( parent != null )
|
||||
return MiniYaml.Merge( node, MergeWithParent( parent, allUnits ) );
|
||||
return node;
|
||||
}
|
||||
|
||||
static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRa.Game
|
||||
SupportPowerInfo = new InfoLoader<SupportPowerInfo>(
|
||||
Pair.New<string, Func<string, SupportPowerInfo>>("SupportPower", _ => new SupportPowerInfo()));
|
||||
|
||||
var yamlRules = MiniYaml.FromFile("ra.yaml");
|
||||
var yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "ra.yaml" ), MiniYaml.FromFile( "defaults.yaml" ) );
|
||||
if( useAftermath )
|
||||
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules );
|
||||
|
||||
|
||||
@@ -62,10 +62,11 @@ namespace OpenRa.Game.GameRules
|
||||
.Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */
|
||||
}
|
||||
|
||||
public IEnumerable<NewUnitInfo> UnitBuiltAt( LegacyUnitInfo info )
|
||||
public IEnumerable<NewUnitInfo> UnitBuiltAt( NewUnitInfo info )
|
||||
{
|
||||
if( info.BuiltAt.Length != 0 )
|
||||
return info.BuiltAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] );
|
||||
var builtAt = info.Traits.Get<BuildableInfo>().BuiltAt;
|
||||
if( builtAt.Length != 0 )
|
||||
return builtAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] );
|
||||
else
|
||||
return producesIndex[ Rules.UnitCategory[ info.Name ] ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user