move LimitedAmmo to RA dll; reduce pips for YAK

This commit is contained in:
Chris Forbes
2010-07-19 19:43:37 +12:00
parent 92f4442941
commit fa0d6b3e72
4 changed files with 5 additions and 3 deletions

View File

@@ -171,7 +171,6 @@
<Compile Include="Traits\Buildable.cs" />
<Compile Include="Traits\Building.cs" />
<Compile Include="Traits\World\BuildingInfluence.cs" />
<Compile Include="Traits\LimitedAmmo.cs" />
<Compile Include="Traits\Player\PlaceBuilding.cs" />
<Compile Include="Traits\World\PlayerColorPalette.cs" />
<Compile Include="Traits\World\ResourceLayer.cs" />

View File

@@ -1,53 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Traits
{
class LimitedAmmoInfo : ITraitInfo
{
public readonly int Ammo = 0;
public readonly int PipCount = 0;
public object Create(ActorInitializer init) { return new LimitedAmmo(init.self); }
}
public class LimitedAmmo : INotifyAttack, IPips
{
[Sync]
int ammo;
Actor self;
public LimitedAmmo(Actor self)
{
ammo = self.Info.Traits.Get<LimitedAmmoInfo>().Ammo;
this.self = self;
}
public bool HasAmmo() { return ammo > 0; }
public bool GiveAmmo()
{
if (ammo >= self.Info.Traits.Get<LimitedAmmoInfo>().Ammo) return false;
++ammo;
return true;
}
public void Attacking(Actor self) { --ammo; }
public IEnumerable<PipType> GetPips(Actor self)
{
var info = self.Info.Traits.Get<LimitedAmmoInfo>();
var pips = info.PipCount != 0 ? info.PipCount : info.Ammo;
return Graphics.Util.MakeArray(pips,
i => (ammo * pips) / info.Ammo > i ? PipType.Green : PipType.Transparent);
}
}
}