#115 New construction options
This commit is contained in:
@@ -114,7 +114,7 @@ namespace OpenRA
|
||||
u => u.Image,
|
||||
u => SpriteSheetBuilder.LoadAllSprites(u.Image)[0]);
|
||||
|
||||
var groups = Rules.Info.Values.Select( x => x.Category ).Distinct().Where( g => g != null ).ToList();
|
||||
var groups = Rules.Categories();
|
||||
|
||||
tabImageNames = groups.Select(
|
||||
(g, i) => Pair.New(g,
|
||||
|
||||
@@ -55,5 +55,10 @@ namespace OpenRA
|
||||
var y = files.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge);
|
||||
return y.ToDictionary(kv => kv.Key.ToLowerInvariant(), kv => f(kv, y));
|
||||
}
|
||||
|
||||
public static IEnumerable<string> Categories()
|
||||
{
|
||||
return Info.Values.Select( x => x.Category ).Distinct().Where( g => g != null ).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Traits
|
||||
public readonly string OnHoldAudio = "onhold1.aud";
|
||||
public readonly string CancelledAudio = "cancld1.aud";
|
||||
public readonly string ClickAudio = "ramenu1.aud";
|
||||
|
||||
public readonly string NewOptions = "newopt1.aud";
|
||||
|
||||
// For manual powerup/down in ra-ng
|
||||
public readonly string DisablePower = "bleep11.aud";
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -30,8 +31,10 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if( order.OrderString == "PlaceBuilding" || order.OrderString == "LineBuild" )
|
||||
{
|
||||
self.World.AddFrameEndTask( _ =>
|
||||
self.World.AddFrameEndTask( w =>
|
||||
{
|
||||
var prevItems = GetNumBuildables(self.Owner);
|
||||
|
||||
var queue = self.traits.Get<ProductionQueue>();
|
||||
var unit = Rules.Info[ order.TargetString ];
|
||||
var producing = queue.CurrentItem(unit.Category);
|
||||
@@ -43,9 +46,9 @@ namespace OpenRA.Traits
|
||||
{
|
||||
bool playSounds = true;
|
||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||
foreach( var t in LineBuildUtils.GetLineBuildCells( self.World, order.TargetLocation, order.TargetString, buildingInfo ) )
|
||||
foreach( var t in LineBuildUtils.GetLineBuildCells( w, order.TargetLocation, order.TargetString, buildingInfo ) )
|
||||
{
|
||||
var building = self.World.CreateActor( order.TargetString, t, order.Player );
|
||||
var building = w.CreateActor( order.TargetString, t, order.Player );
|
||||
if( playSounds )
|
||||
foreach( var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds )
|
||||
Sound.PlayToPlayer( order.Player, s );
|
||||
@@ -54,12 +57,12 @@ namespace OpenRA.Traits
|
||||
}
|
||||
else
|
||||
{
|
||||
var building = self.World.CreateActor( order.TargetString, order.TargetLocation, order.Player );
|
||||
var building = w.CreateActor( order.TargetString, order.TargetLocation, order.Player );
|
||||
foreach (var s in building.Info.Traits.Get<BuildingInfo>().BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s);
|
||||
}
|
||||
|
||||
var facts = self.World.Queries.OwnedBy[self.Owner]
|
||||
var facts = w.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<ConstructionYard>().Select(x => x.Actor);
|
||||
|
||||
var primaryFact = facts.Where(y => y.traits.Get<Production>().IsPrimary);
|
||||
@@ -69,8 +72,19 @@ namespace OpenRA.Traits
|
||||
fact.traits.Get<RenderBuilding>().PlayCustomAnim(fact, "build");
|
||||
|
||||
queue.FinishProduction(unit.Category);
|
||||
|
||||
if (GetNumBuildables(self.Owner) > prevItems)
|
||||
w.Add(new DelayedAction(10,
|
||||
() => Sound.PlayToPlayer(order.Player,
|
||||
w.WorldActor.Info.Traits.Get<EvaAlertsInfo>().NewOptions)));
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
static int GetNumBuildables(Player p)
|
||||
{
|
||||
if (p != p.World.LocalPlayer) return 0; // this only matters for local players.
|
||||
return Rules.TechTree.BuildableItems(p, Rules.Categories().ToArray()).Count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user