GetEffectiveSpeed() factored out; Mobile hacked to only allow Move orders if the speed is nonzero

This commit is contained in:
Chris Forbes
2009-12-18 12:16:13 +13:00
parent 278eb7b4f7
commit f9b4782a99
5 changed files with 21 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using OpenRa.Game.Graphics;
using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
@@ -124,5 +125,17 @@ namespace OpenRa.Game.Traits
var loc = location - 0.5f * s.size;
return Tuple.New(s, loc.Round(), 8);
}
public static float GetEffectiveSpeed(Actor self)
{
var mi = self.Info as MobileInfo;
if (mi == null) return 0f;
var modifier = self.traits
.WithInterface<ISpeedModifier>()
.Select(t => t.GetSpeedModifier())
.Product();
return mi.Speed * modifier;
}
}
}