fix #262 -- harv should move slower when full

This commit is contained in:
Chris Forbes
2010-08-12 17:40:39 +12:00
parent 2c1ab33893
commit 441bffecfc

View File

@@ -23,12 +23,15 @@ namespace OpenRA.Mods.RA
public readonly int Capacity = 28;
public readonly int PipCount = 7;
public readonly PipType PipColor = PipType.Yellow;
public readonly string[] Resources = { };
public readonly string[] Resources = { };
public readonly float FullyLoadedSpeed = .7f;
public object Create(ActorInitializer init) { return new Harvester(init.self, this); }
}
public class Harvester : IIssueOrder, IResolveOrder, INotifyDamage, IPips, IRenderModifier, IExplodeModifier, IOrderCursor, IOrderVoice
public class Harvester : IIssueOrder, IResolveOrder, INotifyDamage, IPips,
IRenderModifier, IExplodeModifier, IOrderCursor, IOrderVoice,
ISpeedModifier
{
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
@@ -202,5 +205,11 @@ namespace OpenRA.Mods.RA
}
public bool ShouldExplode(Actor self) { return !IsEmpty; }
public float GetSpeedModifier()
{
return float2.Lerp(1f, Info.FullyLoadedSpeed,
contents.Values.Sum() / (float)Info.Capacity);
}
}
}