"Alternate Names" aka pseudo-prerequisites. E7 and MSLO can be built again.

This commit is contained in:
Bob
2010-01-13 00:08:44 +13:00
parent b425f4c31f
commit f1bbbac39d
7 changed files with 26 additions and 8 deletions

View File

@@ -751,9 +751,7 @@ namespace OpenRa.Game
if (!Rules.TechTree.CanBuild(info, Game.LocalPlayer, buildings)) if (!Rules.TechTree.CanBuild(info, Game.LocalPlayer, buildings))
{ {
var prereqs = buildable.Prerequisites var prereqs = buildable.Prerequisites
.Select(a => Rules.NewUnitInfo[a.ToLowerInvariant()].Traits.Get<BuildableInfo>()) .Select( a => Description( a ) );
.Where( u => u.Owner.Any( o => o == Game.LocalPlayer.Race ) )
.Select( a => a.Description );
renderer.DrawText("Requires {0}".F( string.Join( ", ", prereqs.ToArray() ) ), p.ToInt2(), renderer.DrawText("Requires {0}".F( string.Join( ", ", prereqs.ToArray() ) ), p.ToInt2(),
Color.White); Color.White);
} }
@@ -765,6 +763,14 @@ namespace OpenRa.Game
} }
} }
private static string Description( string a )
{
if( a[ 0 ] == '@' )
return "any " + a.Substring( 1 );
else
return Rules.NewUnitInfo[ a.ToLowerInvariant() ].Traits.Get<BuildableInfo>().Description;
}
void DrawSupportPowers() void DrawSupportPowers()
{ {
var numPowers = Game.LocalPlayer.SupportPowers.Values var numPowers = Game.LocalPlayer.SupportPowers.Values

View File

@@ -25,7 +25,13 @@ namespace OpenRa.Game.GameRules
{ {
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() ); var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains<BuildingInfo>() ) ) foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains<BuildingInfo>() ) )
{
ret[ b.Info.Name ].Add( b ); ret[ b.Info.Name ].Add( b );
var buildable = b.Info.Traits.GetOrDefault<BuildableInfo>();
if( buildable != null )
foreach( var alt in buildable.AlternateName )
ret[ alt ].Add( b );
}
return ret; return ret;
} }

View File

@@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits
public readonly string Description = ""; public readonly string Description = "";
public readonly string LongDesc = ""; public readonly string LongDesc = "";
public readonly string Icon = null; public readonly string Icon = null;
public readonly string[] AlternateName = { };
} }
class Buildable { } class Buildable { }

View File

@@ -81,7 +81,8 @@ namespace RulesConverter
{ "Cost", "Cost" }, { "Cost", "Cost" },
{ "Icon", "Icon" }, { "Icon", "Icon" },
{ "Description", "Description" }, { "Description", "Description" },
{ "LongDesc", "LongDesc" } } { "LongDesc", "LongDesc" },
{ "AlternateName", "AlternateName" } }
}, },
{ "Cargo", new PL { { "Cargo", new PL {

View File

@@ -879,7 +879,7 @@ MSLO:
Buildable: Buildable:
TechLevel: 13 TechLevel: 13
Tab: Defense Tab: Defense
Prerequisites: stek,atek Prerequisites: @Tech Center
Owner: soviet,allies Owner: soviet,allies
Cost: 2500 Cost: 2500
Description: Missile Silo Description: Missile Silo
@@ -907,6 +907,7 @@ ATEK:
Cost: 1500 Cost: 1500
Description: Allied Tech Center Description: Allied Tech Center
LongDesc: Provides Allied advanced technologies.\n Special Ability: GPS Satellite LongDesc: Provides Allied advanced technologies.\n Special Ability: GPS Satellite
AlternateName: @Tech Center
Selectable: Selectable:
Priority: 3 Priority: 3
Building: Building:
@@ -1226,6 +1227,7 @@ STEK:
Cost: 1500 Cost: 1500
Description: Soviet Tech Center Description: Soviet Tech Center
LongDesc: Provides Soviet advanced technologies LongDesc: Provides Soviet advanced technologies
AlternateName: @Tech Center
Selectable: Selectable:
Priority: 3 Priority: 3
Building: Building:
@@ -2317,7 +2319,7 @@ E7:
Buildable: Buildable:
TechLevel: 11 TechLevel: 11
Tab: Infantry Tab: Infantry
Prerequisites: atek,stek Prerequisites: @Tech Center
Owner: allies,soviet Owner: allies,soviet
Cost: 1200 Cost: 1200
Description: Tanya Description: Tanya

View File

@@ -601,7 +601,7 @@ Infiltrate=yes
; Tanya ; Tanya
[E7] [E7]
Prerequisite=atek,stek Prerequisite=@Tech Center
Primary=Colt45 Primary=Colt45
Secondary=Colt45 Secondary=Colt45
Strength=100 Strength=100
@@ -1228,7 +1228,7 @@ ROT=30
; big missile silo ; big missile silo
[MSLO] [MSLO]
Prerequisite=stek,atek Prerequisite=@Tech Center
Primary=none Primary=none
Strength=400 Strength=400
Armor=heavy Armor=heavy

View File

@@ -353,6 +353,7 @@ Dimensions=2,2
Footprint=xx xx Footprint=xx xx
SelectionPriority=3 SelectionPriority=3
LongDesc=Provides Allied advanced technologies.\n Special Ability: GPS Satellite LongDesc=Provides Allied advanced technologies.\n Special Ability: GPS Satellite
AlternateName=@Tech Center
[WEAP] [WEAP]
Description=War Factory Description=War Factory
Traits=Building, RenderBuilding, RenderWarFactory, RallyPoint, Production, IronCurtainable Traits=Building, RenderBuilding, RenderWarFactory, RallyPoint, Production, IronCurtainable
@@ -448,6 +449,7 @@ Dimensions=3,2
Footprint=xxx xxx Footprint=xxx xxx
SelectionPriority=3 SelectionPriority=3
LongDesc=Provides Soviet advanced technologies LongDesc=Provides Soviet advanced technologies
AlternateName=@Tech Center
[BARR] [BARR]
Description=Soviet Barracks Description=Soviet Barracks
Traits=Building, RenderBuilding, RallyPoint, Production, IronCurtainable Traits=Building, RenderBuilding, RallyPoint, Production, IronCurtainable