From 66a1ab0e4e1167496206a4aaa8ea4fdcedf0b0f9 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:13:14 +1300 Subject: [PATCH] production/techtree starting to port --- OpenRa.Game/GameRules/Rules.cs | 8 +- OpenRa.Game/GameRules/TechTree.cs | 14 +- OpenRa.Game/Traits/Production.cs | 1 + OpenRa.Game/Traits/ProductionQueue.cs | 4 +- ra.yaml | 496 ++++++++++++++++++++++++++ regen-yaml.cmd | 2 +- 6 files changed, 512 insertions(+), 13 deletions(-) diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index d7200d93ec..87eb755a35 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -90,14 +90,14 @@ namespace OpenRa.Game SupportPowerInfo = new InfoLoader( Pair.New>("SupportPower", _ => new SupportPowerInfo())); + NewUnitInfo = new Dictionary(); + 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(); - 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) diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 57b707f670..6f70cf883a 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -7,15 +7,17 @@ namespace OpenRa.Game.GameRules { class TechTree { - readonly Cache> producesIndex = new Cache>( x => new List() ); + readonly Cache> producesIndex = new Cache>(x => new List()); public TechTree() { foreach( var b in Rules.Categories[ "Building" ] ) { - var info = (LegacyBuildingInfo)Rules.UnitInfo[ b ]; - foreach( var p in info.Produces ) - producesIndex[ p ].Add( info ); + var info = Rules.NewUnitInfo[ b ]; + var pi = info.Traits.WithInterface().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 UnitBuiltAt( LegacyUnitInfo info ) + public IEnumerable 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 ] ]; } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 5297112145..8ed3520461 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -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); } } diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index 06340287dd..b5945c76ff 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits // Prioritise primary structure in build order var primaryProducers = Game.world.Actors .Where(x => x.traits.Contains() - && producerTypes.Contains(x.LegacyInfo) + && producerTypes.Contains(x.Info) && x.Owner == self.Owner && x.traits.Get().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(); } diff --git a/ra.yaml b/ra.yaml index 32b914b875..36eb9d8fd8 100644 --- a/ra.yaml +++ b/ra.yaml @@ -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: diff --git a/regen-yaml.cmd b/regen-yaml.cmd index f5018afb67..296337b094 100644 --- a/regen-yaml.cmd +++ b/regen-yaml.cmd @@ -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 \ No newline at end of file