Deathweapon capability, refactoring, and Pip polishing on Silo, Proc, Harv. Lose ore on silo death.
This commit is contained in:
@@ -30,17 +30,20 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class TiberiumRefineryInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Pips = 0;
|
||||
public readonly int PipCount = 0;
|
||||
public readonly PipType PipColor = PipType.Red;
|
||||
public readonly int Capacity = 0;
|
||||
public readonly int ProcessTick = 25;
|
||||
public readonly int ProcessAmount = 50;
|
||||
public readonly string DeathWeapon = null;
|
||||
public object Create(Actor self) { return new TiberiumRefinery(self, this); }
|
||||
}
|
||||
|
||||
class TiberiumRefinery : ITick, IAcceptOre, IPips
|
||||
class TiberiumRefinery : ITick, IAcceptOre, INotifyDamage, IPips
|
||||
{
|
||||
Actor self;
|
||||
TiberiumRefineryInfo Info;
|
||||
readonly Actor self;
|
||||
readonly TiberiumRefineryInfo Info;
|
||||
readonly PlayerResources Player;
|
||||
|
||||
[Sync]
|
||||
int nextProcessTime = 0;
|
||||
@@ -51,6 +54,8 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
this.self = self;
|
||||
Info = info;
|
||||
Player = self.Owner.PlayerActor.traits.Get<PlayerResources>();
|
||||
|
||||
}
|
||||
|
||||
public void GiveOre(int amount)
|
||||
@@ -65,18 +70,30 @@ namespace OpenRA.Mods.Cnc
|
||||
if (--nextProcessTime <= 0)
|
||||
{
|
||||
// Convert resources to cash
|
||||
var pr = self.Owner.PlayerActor.traits.Get<PlayerResources>();
|
||||
int amount = Math.Min(Tiberium, Info.ProcessAmount);
|
||||
amount = Math.Min(amount, pr.OreCapacity - pr.Ore);
|
||||
amount = Math.Min(amount, Player.OreCapacity - Player.Ore);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
Tiberium -=amount;
|
||||
pr.GiveOre(amount);
|
||||
Player.GiveOre(amount);
|
||||
}
|
||||
nextProcessTime = Info.ProcessTick;
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead && Tiberium > 0)
|
||||
{
|
||||
if (Info.DeathWeapon != null)
|
||||
{
|
||||
Combat.DoExplosion(e.Attacker, Info.DeathWeapon,
|
||||
self.CenterLocation.ToInt2(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int2 DeliverOffset { get { return new int2(0, 2); } }
|
||||
public void OnDock(Actor harv, DeliverResources dockOrder)
|
||||
{
|
||||
@@ -93,9 +110,9 @@ namespace OpenRA.Mods.Cnc
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
return Graphics.Util.MakeArray( Info.Pips,
|
||||
i => (Tiberium * 1.0f / Info.Capacity > i * 1.0f / Info.Pips)
|
||||
? PipType.Green : PipType.Transparent );
|
||||
return Graphics.Util.MakeArray( Info.PipCount,
|
||||
i => (Tiberium * 1.0f / Info.Capacity > i * 1.0f / Info.PipCount)
|
||||
? Info.PipColor : PipType.Transparent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user