This commit is contained in:
Matthias Mailänder
2014-04-17 21:24:04 +02:00
parent 657141bce0
commit bf4f58b5c7

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class PlaceBuildingInfo : TraitInfo<PlaceBuilding> {} class PlaceBuildingInfo : TraitInfo<PlaceBuilding> { }
class PlaceBuilding : IResolveOrder class PlaceBuilding : IResolveOrder
{ {
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.RA
{ {
var building = w.CreateActor(order.TargetString, new TypeDictionary var building = w.CreateActor(order.TargetString, new TypeDictionary
{ {
new LocationInit( t ), new LocationInit(t),
new OwnerInit( order.Player ), new OwnerInit(order.Player),
}); });
if (playSounds) if (playSounds)
@@ -70,14 +70,14 @@ namespace OpenRA.Mods.RA
var building = w.CreateActor(order.TargetString, new TypeDictionary var building = w.CreateActor(order.TargetString, new TypeDictionary
{ {
new LocationInit( order.TargetLocation ), new LocationInit(order.TargetLocation),
new OwnerInit( order.Player ), new OwnerInit(order.Player),
}); });
foreach (var s in buildingInfo.BuildSounds) foreach (var s in buildingInfo.BuildSounds)
Sound.PlayToPlayer(order.Player, s, building.CenterPosition); Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
} }
PlayBuildAnim( self, unit ); PlayBuildAnim(self, unit);
queue.FinishProduction(); queue.FinishProduction();
@@ -98,21 +98,21 @@ namespace OpenRA.Mods.RA
} }
// finds a construction yard (or equivalent) and runs its "build" animation. // finds a construction yard (or equivalent) and runs its "build" animation.
static void PlayBuildAnim( Actor self, ActorInfo unit ) static void PlayBuildAnim(Actor self, ActorInfo unit)
{ {
var bi = unit.Traits.GetOrDefault<BuildableInfo>(); var bi = unit.Traits.GetOrDefault<BuildableInfo>();
if (bi == null) if (bi == null)
return; return;
var producers = self.World.ActorsWithTrait<Production>() var producers = self.World.ActorsWithTrait<Production>()
.Where( x => x.Actor.Owner == self.Owner .Where(x => x.Actor.Owner == self.Owner
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) ) && x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(bi.Queue))
.ToList(); .ToList();
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers ) var producer = producers.Where(x => x.Actor.IsPrimaryBuilding()).Concat(producers)
.FirstOrDefault(); .FirstOrDefault();
if( producer.Actor != null ) if (producer.Actor == null)
producer.Actor.Trait<RenderSimple>().PlayCustomAnim( producer.Actor, "build" ); return;
} }
static int GetNumBuildables(Player p) static int GetNumBuildables(Player p)