Added repair bonus for multiple players
More than one player can now contribute to repairing a building. Base repair amount is multiplied by value of array Players who can't afford to contribute are ignored Repair indicator cycles between each player's color.
This commit is contained in:
committed by
Paul Chote
parent
9e11e38005
commit
16df8322c6
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
@@ -18,27 +19,27 @@ namespace OpenRA.Mods.RA.Effects
|
||||
class RepairIndicator : IEffect
|
||||
{
|
||||
readonly Actor building;
|
||||
readonly Player player;
|
||||
readonly string palettePrefix;
|
||||
readonly Animation anim;
|
||||
readonly RepairableBuilding rb;
|
||||
int shownPlayer = 0;
|
||||
|
||||
public RepairIndicator(Actor building, string palettePrefix, Player player)
|
||||
public RepairIndicator(Actor building, string palettePrefix)
|
||||
{
|
||||
this.building = building;
|
||||
this.player = player;
|
||||
this.palettePrefix = palettePrefix;
|
||||
|
||||
rb = building.TraitOrDefault<RepairableBuilding>();
|
||||
anim = new Animation(building.World, "allyrepair");
|
||||
anim.Paused = () => !rb.RepairActive;
|
||||
anim.PlayRepeating("repair");
|
||||
|
||||
CycleRepairer();
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!building.IsInWorld || building.IsDead() ||
|
||||
rb == null || rb.Repairer == null || rb.Repairer != player)
|
||||
if (!building.IsInWorld || building.IsDead() ||
|
||||
rb == null || !rb.Repairers.Any())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
anim.Tick();
|
||||
@@ -49,8 +50,16 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (building.Destroyed || wr.world.FogObscures(building))
|
||||
return SpriteRenderable.None;
|
||||
|
||||
return anim.Render(building.CenterPosition,
|
||||
wr.Palette(palettePrefix+player.InternalName));
|
||||
return anim.Render(building.CenterPosition,
|
||||
wr.Palette(palettePrefix + rb.Repairers[shownPlayer % rb.Repairers.Count].InternalName));
|
||||
}
|
||||
|
||||
void CycleRepairer()
|
||||
{
|
||||
anim.PlayThen("repair", CycleRepairer);
|
||||
|
||||
if (++shownPlayer == rb.Repairers.Count)
|
||||
shownPlayer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user