More shroud refactoring.

This introduces a hash on Shroud which ShroudRenderer
can observe, removing the need to explicitly twiddle
a dirty flag between objects.

Shroud disabling is now done via RenderPlayer, so
enabling the cheat or winning/losing will now give
vis equivalent to an observer.
This commit is contained in:
Paul Chote
2013-04-10 20:27:33 +12:00
parent ca8dbce0ef
commit 248e815d99
9 changed files with 169 additions and 168 deletions

View File

@@ -32,29 +32,24 @@ namespace OpenRA.Traits
public void Tick(Actor self)
{
// TODO: don't tick all the time.
if(self.Owner == null) return;
if (self.Owner == null)
return;
if (previousLocation != self.Location && v != null) {
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
if (previousLocation != self.Location && v != null)
{
previousLocation = self.Location;
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
foreach (var shroud in shrouds) {
foreach (var shroud in shrouds)
shroud.UnhideActor(self, v, Info.Range);
}
}
if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) {
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
foreach (var shroud in shrouds) {
if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
foreach (var shroud in shrouds)
shroud.HideActor(self, Info.Range);
}
}
else {
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
foreach (var shroud in shrouds) {
else
foreach (var shroud in shrouds)
shroud.UnhideActor(self, v, Info.Range);
}
}
v = new Shroud.ActorVisibility {
vis = Shroud.GetVisOrigins(self).ToArray()