Introduce World.LocalShroud. Breaks targeting stealth tanks. Probably breaks FrozenUnderFog.

This commit is contained in:
Paul Chote
2010-11-26 16:56:33 +13:00
parent 41fd19c766
commit 7c5c989eb2
25 changed files with 88 additions and 161 deletions

View File

@@ -14,34 +14,15 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class FrozenUnderFogInfo : ITraitInfo
class FrozenUnderFogInfo : TraitInfo<FrozenUnderFog> {}
class FrozenUnderFog : IRenderModifier
{
public object Create(ActorInitializer init) { return new FrozenUnderFog(init.self); }
}
class FrozenUnderFog : IRenderModifier, IVisibilityModifier
{
Shroud shroud;
Renderable[] cache = { };
public FrozenUnderFog(Actor self)
{
shroud = self.World.WorldActor.Trait<Shroud>();
}
public bool IsVisible(Actor self, Player byPlayer)
{
return self.World.LocalPlayer == null
|| self.Owner == byPlayer
|| self.World.LocalPlayer.Shroud.Disabled
|| Shroud.GetVisOrigins(self).Any(o => self.World.Map.IsInMap(o) && shroud.visibleCells[o.X, o.Y] != 0);
}
Renderable[] cache = { };
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
if (IsVisible(self, self.World.LocalPlayer))
if (self.World.LocalShroud.IsVisible(self))
cache = r.ToArray();
return cache;
}
}