Merge pull request #12307 from pchote/passive-visibility

Add plumbing for improved RA gap generator behaviour.
This commit is contained in:
reaperrr
2016-11-18 14:34:35 +01:00
committed by GitHub
3 changed files with 109 additions and 57 deletions

View File

@@ -33,10 +33,10 @@ namespace OpenRA.Mods.Common.Traits
if (!info.ValidStances.HasStance(p.Stances[self.Owner]))
return;
p.Shroud.AddProjectedShroudGeneration(this, uv);
p.Shroud.AddSource(this, Shroud.SourceType.Shroud, uv);
}
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveShroudGeneration(this); }
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveSource(this); }
protected override bool IsDisabled(Actor self) { return self.IsDisabled(); }
}

View File

@@ -18,24 +18,33 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Stance the watching player needs to see the shroud removed.")]
public readonly Stance ValidStances = Stance.Ally;
[Desc("Can this actor reveal shroud generated by the GeneratesShroud trait?")]
public readonly bool RevealGeneratedShroud = true;
public override object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); }
}
public class RevealsShroud : AffectsShroud
{
readonly RevealsShroudInfo info;
readonly Shroud.SourceType type;
public RevealsShroud(Actor self, RevealsShroudInfo info)
: base(self, info) { this.info = info; }
: base(self, info)
{
this.info = info;
type = info.RevealGeneratedShroud ? Shroud.SourceType.Visibility
: Shroud.SourceType.PassiveVisibility;
}
protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
{
if (!info.ValidStances.HasStance(p.Stances[self.Owner]))
return;
p.Shroud.AddProjectedVisibility(this, uv);
p.Shroud.AddSource(this, type, uv);
}
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveVisibility(this); }
protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveSource(this); }
}
}