production/techtree starting to port

This commit is contained in:
Chris Forbes
2010-01-11 19:13:14 +13:00
parent 5faa1ea724
commit 66a1ab0e4e
6 changed files with 512 additions and 13 deletions

View File

@@ -90,14 +90,14 @@ namespace OpenRa.Game
SupportPowerInfo = new InfoLoader<SupportPowerInfo>(
Pair.New<string, Func<string, SupportPowerInfo>>("SupportPower", _ => new SupportPowerInfo()));
NewUnitInfo = new Dictionary<string, NewUnitInfo>();
foreach (var kv in MiniYaml.FromFile("ra.yaml"))
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value));
TechTree = new TechTree();
Map = new Map( AllRules );
FileSystem.MountTemporary( new Package( Rules.Map.Theater + ".mix" ) );
TileSet = new TileSet( Map.TileSuffix );
NewUnitInfo = new Dictionary<string, NewUnitInfo>();
foreach( var kv in MiniYaml.FromFile( "ra.yaml" ) )
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value));
}
static void LoadCategories(params string[] types)

View File

@@ -7,14 +7,16 @@ namespace OpenRa.Game.GameRules
{
class TechTree
{
readonly Cache<string, List<LegacyUnitInfo>> producesIndex = new Cache<string, List<LegacyUnitInfo>>( x => new List<LegacyUnitInfo>() );
readonly Cache<string, List<NewUnitInfo>> producesIndex = new Cache<string, List<NewUnitInfo>>(x => new List<NewUnitInfo>());
public TechTree()
{
foreach( var b in Rules.Categories[ "Building" ] )
{
var info = (LegacyBuildingInfo)Rules.UnitInfo[ b ];
foreach( var p in info.Produces )
var info = Rules.NewUnitInfo[ b ];
var pi = info.Traits.WithInterface<ProductionInfo>().FirstOrDefault();
if (pi != null)
foreach( var p in pi.Produces )
producesIndex[ p ].Add( info );
}
}
@@ -60,10 +62,10 @@ namespace OpenRa.Game.GameRules
.Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */
}
public IEnumerable<LegacyUnitInfo> UnitBuiltAt( LegacyUnitInfo info )
public IEnumerable<NewUnitInfo> UnitBuiltAt( LegacyUnitInfo info )
{
if( info.BuiltAt.Length != 0 )
return info.BuiltAt.Select( x => Rules.UnitInfo[ x.ToLowerInvariant() ] );
return info.BuiltAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] );
else
return producesIndex[ Rules.UnitCategory[ info.Name ] ];
}

View File

@@ -7,6 +7,7 @@ namespace OpenRa.Game.Traits
class ProductionInfo : ITraitInfo
{
public readonly int[] SpawnOffset = null;
public readonly string[] Produces = { };
public object Create(Actor self) { return new Production(self); }
}

View File

@@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits
// Prioritise primary structure in build order
var primaryProducers = Game.world.Actors
.Where(x => x.traits.Contains<Production>()
&& producerTypes.Contains(x.LegacyInfo)
&& producerTypes.Contains(x.Info)
&& x.Owner == self.Owner
&& x.traits.Get<Production>().IsPrimary == true);
@@ -153,7 +153,7 @@ namespace OpenRa.Game.Traits
if (producer == null)
{
producer = Game.world.Actors
.Where( x => producerTypes.Contains( x.LegacyInfo ) && x.Owner == self.Owner )
.Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner )
.FirstOrDefault();
}

496
ra.yaml
View File

@@ -424,6 +424,18 @@ MNLY.AT:
Passenger:
IronCurtainable:
TRUK:
Inherits: DefaultVehicle
Selectable:
Unit:
HP: 110
Armor: light
Sight: 3
Mobile:
ROT: 5
Speed: 10
RenderUnit:
SS:
Inherits: DefaultShip
Buildable:
@@ -1720,6 +1732,490 @@ MINE:
RenderBuilding:
SeedsOre:
FCOM:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Power: -200
Footprint: xx xx
Dimensions: 2,2
Capturable: true
Bib: yes
HP: 400
Armor: wood
Crewed: yes
Sight: 10
RenderBuilding:
V01:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx xx
Dimensions: 2,2
Capturable: true
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V02:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx xx
Dimensions: 2,2
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V03:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx xx
Dimensions: 2,2
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V04:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx xx
Dimensions: 2,2
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V05:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx
Dimensions: 2,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V06:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx
Dimensions: 2,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V07:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: xx
Dimensions: 2,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V08:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V09:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V10:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V11:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V12:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V13:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V14:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V15:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V16:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V17:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V18:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V19:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
V20:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V21:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V22:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V23:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V24:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V25:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V26:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V27:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V28:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V29:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V30:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V31:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V32:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V33:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V34:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V35:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V36:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
V37:
Inherits: DefaultBuilding
Selectable:
Priority: 3
Building:
Repairable: false
HP: 400
Armor: wood
RenderBuilding:
Image: FCOM
BARL:
Inherits: DefaultBuilding
Selectable:
Priority: 0
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
BaseNormal: no
Adjacent: 0
HP: 10
RenderBuilding:
Explodes:
BRL3:
Inherits: DefaultBuilding
Selectable:
Priority: 0
Building:
Footprint: x
Dimensions: 1,1
Repairable: false
BaseNormal: no
Adjacent: 0
HP: 10
RenderBuilding:
Explodes:
MISS:
Inherits: DefaultBuilding
Selectable:
Priority: 0
Building:
Footprint: xxx xxx
Dimensions: 3,2
Capturable: true
Bib: yes
HP: 400
Armor: wood
RenderBuilding:
DOG:
Inherits: DefaultInfantry
Buildable:

View File

@@ -1,2 +1,2 @@
RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini trees.ini ra.yaml
RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini trees.ini campaignUnits.ini ra.yaml
RulesConverter\bin\debug\RulesConverter.exe aftermathUnits.ini aftrmath.ini aftermath.yaml