Fix building repair; Kill GlobalDefaults.

This commit is contained in:
Paul Chote
2010-07-30 00:34:33 +12:00
parent 6fba888d45
commit bce9791b56
16 changed files with 20 additions and 52 deletions

View File

@@ -29,14 +29,14 @@ namespace OpenRA.Mods.RA.Orders
if (mi.Button == MouseButton.Left)
{
var underCursor = world.FindUnitsAtMouse(mi.Location)
.Where(a => a.Owner == world.LocalPlayer
&& a.traits.Contains<Building>()
&& a.traits.Contains<Selectable>()).FirstOrDefault();
.Where(a => a.Owner == world.LocalPlayer && a.traits.Contains<RepairableBuilding>()).FirstOrDefault();
var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;
var health = underCursor != null ? underCursor.traits.GetOrDefault<Health>() : null;
if (underCursor == null)
yield break;
if (building != null && building.Repairable && health != null && health.HPFraction < 1f)
var health = underCursor.traits.GetOrDefault<Health>();
var repairable = health != null && underCursor.Info.Traits.Contains<RepairableBuildingInfo>();
if (repairable && health.HPFraction < 1f)
yield return new Order("Repair", underCursor);
}
}
@@ -48,10 +48,8 @@ namespace OpenRA.Mods.RA.Orders
}
public static bool PlayerIsAllowedToRepair( World world )
{
return Game.world.Queries.OwnedBy[ Game.world.LocalPlayer ]
.WithTrait<Production>().Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( "Building" ) )
.Any();
{
return Game.world.Queries.OwnedBy[ Game.world.LocalPlayer ].WithTrait<AllowsBuildingRepair>().Any();
}
public void RenderAfterWorld( World world ) {}