Rules.NewUnitInfo rename -> ActorInfo
This commit is contained in:
@@ -32,7 +32,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
{
|
{
|
||||||
Info = Rules.NewUnitInfo[name.ToLowerInvariant()];
|
Info = Rules.ActorInfo[name.ToLowerInvariant()];
|
||||||
Health = this.GetMaxHP();
|
Health = this.GetMaxHP();
|
||||||
|
|
||||||
foreach (var trait in Info.Traits.WithInterface<ITraitInfo>())
|
foreach (var trait in Info.Traits.WithInterface<ITraitInfo>())
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRa
|
|||||||
panelSprites = Graphics.Util.MakeArray(8,
|
panelSprites = Graphics.Util.MakeArray(8,
|
||||||
n => SequenceProvider.GetImageFromCollection(renderer, "panel", n.ToString()));
|
n => SequenceProvider.GetImageFromCollection(renderer, "panel", n.ToString()));
|
||||||
|
|
||||||
tabSprites = Rules.NewUnitInfo.Values
|
tabSprites = Rules.ActorInfo.Values
|
||||||
.Where(u => u.Traits.Contains<BuildableInfo>())
|
.Where(u => u.Traits.Contains<BuildableInfo>())
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u.Name,
|
u => u.Name,
|
||||||
@@ -122,7 +122,7 @@ namespace OpenRa
|
|||||||
u => u.Key,
|
u => u.Key,
|
||||||
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]);
|
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]);
|
||||||
|
|
||||||
var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().Where( g => g != null ).ToList();
|
var groups = Rules.ActorInfo.Values.Select( x => x.Category ).Distinct().Where( g => g != null ).ToList();
|
||||||
|
|
||||||
tabImageNames = groups.Select(
|
tabImageNames = groups.Select(
|
||||||
(g, i) => Pair.New(g,
|
(g, i) => Pair.New(g,
|
||||||
@@ -746,7 +746,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
void StartProduction( string item )
|
void StartProduction( string item )
|
||||||
{
|
{
|
||||||
var unit = Rules.NewUnitInfo[item];
|
var unit = Rules.ActorInfo[item];
|
||||||
Sound.Play(unit.Traits.Contains<BuildingInfo>() ? "abldgin1.aud" : "train1.aud");
|
Sound.Play(unit.Traits.Contains<BuildingInfo>() ? "abldgin1.aud" : "train1.aud");
|
||||||
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
||||||
}
|
}
|
||||||
@@ -754,7 +754,7 @@ namespace OpenRa
|
|||||||
void HandleBuildPalette(string item, bool isLmb)
|
void HandleBuildPalette(string item, bool isLmb)
|
||||||
{
|
{
|
||||||
var player = Game.LocalPlayer;
|
var player = Game.LocalPlayer;
|
||||||
var unit = Rules.NewUnitInfo[item];
|
var unit = Rules.ActorInfo[item];
|
||||||
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||||
var producing = queue.AllItems(unit.Category).FirstOrDefault( a => a.Item == item );
|
var producing = queue.AllItems(unit.Category).FirstOrDefault( a => a.Item == item );
|
||||||
|
|
||||||
@@ -839,7 +839,7 @@ namespace OpenRa
|
|||||||
rgbaRenderer.DrawSprite(tooltipSprite, p, PaletteType.Chrome);
|
rgbaRenderer.DrawSprite(tooltipSprite, p, PaletteType.Chrome);
|
||||||
rgbaRenderer.Flush();
|
rgbaRenderer.Flush();
|
||||||
|
|
||||||
var info = Rules.NewUnitInfo[unit];
|
var info = Rules.ActorInfo[unit];
|
||||||
var buildable = info.Traits.Get<BuildableInfo>();
|
var buildable = info.Traits.Get<BuildableInfo>();
|
||||||
|
|
||||||
renderer.DrawText2(buildable.Description, p.ToInt2() + new int2(5,5), Color.White);
|
renderer.DrawText2(buildable.Description, p.ToInt2() + new int2(5,5), Color.White);
|
||||||
@@ -876,7 +876,7 @@ namespace OpenRa
|
|||||||
if( a[ 0 ] == '@' )
|
if( a[ 0 ] == '@' )
|
||||||
return "any " + a.Substring( 1 );
|
return "any " + a.Substring( 1 );
|
||||||
else
|
else
|
||||||
return Rules.NewUnitInfo[ a.ToLowerInvariant() ].Traits.Get<BuildableInfo>().Description;
|
return Rules.ActorInfo[ a.ToLowerInvariant() ].Traits.Get<BuildableInfo>().Description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSupportPowers()
|
void DrawSupportPowers()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRa
|
|||||||
public static Map Map;
|
public static Map Map;
|
||||||
public static TileSet TileSet;
|
public static TileSet TileSet;
|
||||||
|
|
||||||
public static Dictionary<string, ActorInfo> NewUnitInfo;
|
public static Dictionary<string, ActorInfo> ActorInfo;
|
||||||
|
|
||||||
public static void LoadRules(string mapFileName, bool useAftermath)
|
public static void LoadRules(string mapFileName, bool useAftermath)
|
||||||
{
|
{
|
||||||
@@ -70,9 +70,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "[mod]Separate buildqueue for defense.yaml" ), yamlRules );
|
yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "[mod]Separate buildqueue for defense.yaml" ), yamlRules );
|
||||||
|
|
||||||
NewUnitInfo = new Dictionary<string, ActorInfo>();
|
ActorInfo = new Dictionary<string, ActorInfo>();
|
||||||
foreach( var kv in yamlRules )
|
foreach( var kv in yamlRules )
|
||||||
NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
ActorInfo.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
||||||
|
|
||||||
TechTree = new TechTree();
|
TechTree = new TechTree();
|
||||||
Map = new Map( AllRules );
|
Map = new Map( AllRules );
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace OpenRa.GameRules
|
|||||||
|
|
||||||
public TechTree()
|
public TechTree()
|
||||||
{
|
{
|
||||||
foreach( var info in Rules.NewUnitInfo.Values )
|
foreach( var info in Rules.ActorInfo.Values )
|
||||||
{
|
{
|
||||||
var pi = info.Traits.GetOrDefault<ProductionInfo>();
|
var pi = info.Traits.GetOrDefault<ProductionInfo>();
|
||||||
if (pi != null)
|
if (pi != null)
|
||||||
@@ -62,7 +62,7 @@ namespace OpenRa.GameRules
|
|||||||
|
|
||||||
public IEnumerable<ActorInfo> AllBuildables(Player player, params string[] categories)
|
public IEnumerable<ActorInfo> AllBuildables(Player player, params string[] categories)
|
||||||
{
|
{
|
||||||
return Rules.NewUnitInfo.Values
|
return Rules.ActorInfo.Values
|
||||||
.Where( x => x.Name[ 0 ] != '^' )
|
.Where( x => x.Name[ 0 ] != '^' )
|
||||||
.Where( x => categories.Contains( x.Category ) )
|
.Where( x => categories.Contains( x.Category ) )
|
||||||
.Where( x => x.Traits.Contains<BuildableInfo>() );
|
.Where( x => x.Traits.Contains<BuildableInfo>() );
|
||||||
@@ -72,7 +72,7 @@ namespace OpenRa.GameRules
|
|||||||
{
|
{
|
||||||
var builtAt = info.Traits.Get<BuildableInfo>().BuiltAt;
|
var builtAt = info.Traits.Get<BuildableInfo>().BuiltAt;
|
||||||
if( builtAt.Length != 0 )
|
if( builtAt.Length != 0 )
|
||||||
return builtAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] );
|
return builtAt.Select( x => Rules.ActorInfo[ x.ToLowerInvariant() ] );
|
||||||
else
|
else
|
||||||
return producesIndex[ info.Category ];
|
return producesIndex[ info.Category ];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace OpenRa.Orders
|
|||||||
{
|
{
|
||||||
readonly Actor Producer;
|
readonly Actor Producer;
|
||||||
readonly string Building;
|
readonly string Building;
|
||||||
BuildingInfo BuildingInfo { get { return Rules.NewUnitInfo[ Building ].Traits.Get<BuildingInfo>(); } }
|
BuildingInfo BuildingInfo { get { return Rules.ActorInfo[ Building ].Traits.Get<BuildingInfo>(); } }
|
||||||
|
|
||||||
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRa.Orders
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.NewUnitInfo[ Building ].Category );
|
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.ActorInfo[ Building ].Category );
|
||||||
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
||||||
Game.controller.CancelInputMode();
|
Game.controller.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace OpenRa.Orders
|
|||||||
else
|
else
|
||||||
return Cursor.MoveBlocked;
|
return Cursor.MoveBlocked;
|
||||||
case "DeployMcv":
|
case "DeployMcv":
|
||||||
var factBuildingInfo = Rules.NewUnitInfo["fact"].Traits.Get<BuildingInfo>();
|
var factBuildingInfo = Rules.ActorInfo["fact"].Traits.Get<BuildingInfo>();
|
||||||
if (Game.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a, false))
|
if (Game.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a, false))
|
||||||
return Cursor.Deploy;
|
return Cursor.Deploy;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRa.Orders
|
|||||||
Game.world.AddFrameEndTask( _ =>
|
Game.world.AddFrameEndTask( _ =>
|
||||||
{
|
{
|
||||||
var queue = order.Player.PlayerActor.traits.Get<ProductionQueue>();
|
var queue = order.Player.PlayerActor.traits.Get<ProductionQueue>();
|
||||||
var unit = Rules.NewUnitInfo[ order.TargetString ];
|
var unit = Rules.ActorInfo[ order.TargetString ];
|
||||||
var producing = queue.CurrentItem(unit.Category);
|
var producing = queue.CurrentItem(unit.Category);
|
||||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRa
|
|||||||
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
||||||
var effectivePrereq = Info.Prerequisite
|
var effectivePrereq = Info.Prerequisite
|
||||||
.Select( a => a.ToLowerInvariant() )
|
.Select( a => a.ToLowerInvariant() )
|
||||||
.Where( a => Rules.NewUnitInfo[a].Traits.Get<BuildableInfo>().Owner.Contains( Owner.Race ));
|
.Where( a => Rules.ActorInfo[a].Traits.Get<BuildableInfo>().Owner.Contains( Owner.Race ));
|
||||||
|
|
||||||
IsAvailable = Info.TechLevel > -1
|
IsAvailable = Info.TechLevel > -1
|
||||||
&& effectivePrereq.Any()
|
&& effectivePrereq.Any()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
if( order.OrderString == "DeployMcv" )
|
if( order.OrderString == "DeployMcv" )
|
||||||
{
|
{
|
||||||
var factBuildingInfo = Rules.NewUnitInfo[ "fact" ].Traits.Get<BuildingInfo>();
|
var factBuildingInfo = Rules.ActorInfo[ "fact" ].Traits.Get<BuildingInfo>();
|
||||||
if( Game.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) )
|
if( Game.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) )
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
case "StartProduction":
|
case "StartProduction":
|
||||||
{
|
{
|
||||||
var unit = Rules.NewUnitInfo[ order.TargetString ];
|
var unit = Rules.ActorInfo[ order.TargetString ];
|
||||||
var ui = unit.Traits.Get<BuildableInfo>();
|
var ui = unit.Traits.Get<BuildableInfo>();
|
||||||
var time = ui.Cost
|
var time = ui.Cost
|
||||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||||
@@ -65,7 +65,7 @@ namespace OpenRa.Traits
|
|||||||
}
|
}
|
||||||
case "PauseProduction":
|
case "PauseProduction":
|
||||||
{
|
{
|
||||||
var producing = CurrentItem( Rules.NewUnitInfo[ order.TargetString ].Category );
|
var producing = CurrentItem( Rules.ActorInfo[ order.TargetString ].Category );
|
||||||
if( producing != null && producing.Item == order.TargetString )
|
if( producing != null && producing.Item == order.TargetString )
|
||||||
producing.Paused = ( order.TargetLocation.X != 0 );
|
producing.Paused = ( order.TargetLocation.X != 0 );
|
||||||
break;
|
break;
|
||||||
@@ -95,7 +95,7 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public void CancelProduction( string itemName )
|
public void CancelProduction( string itemName )
|
||||||
{
|
{
|
||||||
var category = Rules.NewUnitInfo[itemName].Category;
|
var category = Rules.ActorInfo[itemName].Category;
|
||||||
var queue = production[ category ];
|
var queue = production[ category ];
|
||||||
if (queue.Count == 0) return;
|
if (queue.Count == 0) return;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public void BuildUnit( string name )
|
public void BuildUnit( string name )
|
||||||
{
|
{
|
||||||
var newUnitType = Rules.NewUnitInfo[ name ];
|
var newUnitType = Rules.ActorInfo[ name ];
|
||||||
var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType );
|
var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType );
|
||||||
Actor producer = null;
|
Actor producer = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user