Misc constructor caching

Cache trait look-ups in constructor for various other traits and
activities.
This commit is contained in:
reaperrr
2015-03-14 04:00:39 +01:00
parent 1e9d1a6cb7
commit b52d055eec
11 changed files with 70 additions and 48 deletions

View File

@@ -29,8 +29,14 @@ namespace OpenRA.Mods.Common.Traits
{
readonly Actor self;
readonly RepairableNearInfo info;
readonly IMove movement;
public RepairableNear(Actor self, RepairableNearInfo info) { this.self = self; this.info = info; }
public RepairableNear(Actor self, RepairableNearInfo info)
{
this.self = self;
this.info = info;
movement = self.Trait<IMove>();
}
public IEnumerable<IOrderTargeter> Orders
{
@@ -63,7 +69,6 @@ namespace OpenRA.Mods.Common.Traits
{
if (order.OrderString == "RepairNear" && CanRepairAt(order.TargetActor) && ShouldRepair())
{
var movement = self.Trait<IMove>();
var target = Target.FromOrder(self.World, order);
self.CancelActivity();