extend RevealMapCrateAction to optionally reveal for allies

This commit is contained in:
Chris Forbes
2010-11-06 20:18:18 +13:00
parent 3645b3ee13
commit aae7f56e7d

View File

@@ -6,26 +6,38 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
#endregion
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class RevealMapCrateActionInfo : CrateActionInfo
{
{
public readonly bool IncludeAllies = false;
public override object Create(ActorInitializer init) { return new RevealMapCrateAction(init.self, this); }
}
class RevealMapCrateAction : CrateAction
{
public RevealMapCrateAction(Actor self, RevealMapCrateActionInfo info)
: base(self, info) {}
: base(self, info) {}
bool ShouldReveal(Player collectingPlayer)
{
if ((info as RevealMapCrateActionInfo).IncludeAllies)
return collectingPlayer.World.LocalPlayer != null &&
collectingPlayer.Stances[collectingPlayer.World.LocalPlayer] == Stance.Ally;
return collectingPlayer == collectingPlayer.World.LocalPlayer;
}
public override void Activate(Actor collector)
{
base.Activate(collector);
if (collector.Owner == collector.World.LocalPlayer)
base.Activate(collector);
if (ShouldReveal( collector.Owner ))
collector.World.WorldActor.Trait<Shroud>().ExploreAll(collector.World);
}
}