Actor.traits is implementation detail

This commit is contained in:
Bob
2010-08-14 15:19:30 +12:00
committed by alzeih
parent f6c6255f64
commit ae703d50b2
165 changed files with 586 additions and 561 deletions

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
if (isCanceled) return NextActivity;
if (remainingTicks == 0)
{
var health = self.traits.GetOrDefault<Health>();
var health = self.TraitOrDefault<Health>();
if (health == null) return NextActivity;
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities
var costPerHp = (repairsUnits.URepairPercent * unitCost) / health.MaxHP;
var hpToRepair = Math.Min(host.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, health.MaxHP - health.HP);
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
if (!self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeCash(cost))
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
{
remainingTicks = 1;
return this;
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
if (host != null)
host.traits.Get<RenderBuilding>()
host.Trait<RenderBuilding>()
.PlayCustomAnim(host, "active");
remainingTicks = (int)(repairsUnits.RepairRate * 60 * 25);