Make RevealsShroud and CreatesShroud use stances
Instead of hardcoded (!)IsAlliedWith checks.
This commit is contained in:
@@ -9,22 +9,31 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class CreatesShroudInfo : AffectsShroudInfo
|
||||
{
|
||||
[Desc("Stance the watching player needs to see the generated shroud.")]
|
||||
public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); }
|
||||
}
|
||||
|
||||
public class CreatesShroud : AffectsShroud
|
||||
{
|
||||
readonly CreatesShroudInfo info;
|
||||
|
||||
public CreatesShroud(Actor self, CreatesShroudInfo info)
|
||||
: base(self, info) { }
|
||||
: base(self, info) { this.info = info; }
|
||||
|
||||
protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
|
||||
{
|
||||
if (!self.Owner.IsAlliedWith(p))
|
||||
p.Shroud.AddProjectedShroudGeneration(this, uv);
|
||||
if (!info.ValidStances.HasStance(p.Stances[self.Owner]))
|
||||
return;
|
||||
|
||||
p.Shroud.AddProjectedShroudGeneration(this, uv);
|
||||
}
|
||||
|
||||
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveShroudGeneration(this); }
|
||||
|
||||
@@ -9,22 +9,31 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RevealsShroudInfo : AffectsShroudInfo
|
||||
{
|
||||
[Desc("Stance the watching player needs to see the shroud removed.")]
|
||||
public readonly Stance ValidStances = Stance.Ally;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); }
|
||||
}
|
||||
|
||||
public class RevealsShroud : AffectsShroud
|
||||
{
|
||||
readonly RevealsShroudInfo info;
|
||||
|
||||
public RevealsShroud(Actor self, RevealsShroudInfo info)
|
||||
: base(self, info) { }
|
||||
: base(self, info) { this.info = info; }
|
||||
|
||||
protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
|
||||
{
|
||||
if (self.Owner.IsAlliedWith(p))
|
||||
p.Shroud.AddProjectedVisibility(this, uv);
|
||||
if (!info.ValidStances.HasStance(p.Stances[self.Owner]))
|
||||
return;
|
||||
|
||||
p.Shroud.AddProjectedVisibility(this, uv);
|
||||
}
|
||||
|
||||
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveVisibility(this); }
|
||||
|
||||
Reference in New Issue
Block a user