fixes #3181 GPS dots not visble in spectator mode

This commit is contained in:
Matthias Mailänder
2013-05-11 13:15:03 +02:00
parent 95ec993134
commit 2c250ed700
2 changed files with 9 additions and 9 deletions

View File

@@ -45,8 +45,6 @@ namespace OpenRA.Mods.RA.Effects
anim.PlayRepeating(info.String);
self.World.AddFrameEndTask(w => w.Add(this));
if (self.World.LocalPlayer != null)
watcher = self.World.LocalPlayer.PlayerActor.Trait<GpsWatcher>();
}
bool firstTick = true;
@@ -55,7 +53,7 @@ namespace OpenRA.Mods.RA.Effects
if (self.Destroyed)
world.AddFrameEndTask(w => w.Remove(this));
if (world.LocalPlayer == null || !self.IsInWorld || self.Destroyed)
if (!self.IsInWorld || self.Destroyed)
return;
// Can be granted at runtime via a crate, so can't cache
@@ -68,6 +66,10 @@ namespace OpenRA.Mods.RA.Effects
firstTick = false;
}
// Can change with the Shroud selector for observers so don't cache.
if (self.World.RenderPlayer != null)
watcher = self.World.RenderPlayer.PlayerActor.Trait<GpsWatcher>();
var hasGps = (watcher != null && (watcher.Granted || watcher.GrantedAllies));
var hasDot = (huf != null && !huf.IsVisible(self, self.World.RenderPlayer));
var dotHidden = (cloak != null && cloak.Cloaked) || (spy != null && spy.Disguised);
@@ -84,7 +86,6 @@ namespace OpenRA.Mods.RA.Effects
var palette = wr.Palette(info.IndicatorPalettePrefix+self.Owner.InternalName);
yield return new Renderable(anim.Image, p.ToFloat2() - 0.5f * anim.Image.size, palette, p.Y)
.WithScale(1.5f);
}
}
}

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
List<Actor> actors = new List<Actor> { };
public GpsWatcher( Player owner ) { this.owner = owner; }
public GpsWatcher(Player owner) { this.owner = owner; }
public void GpsRem(Actor atek)
{
@@ -62,16 +62,15 @@ namespace OpenRA.Mods.RA
foreach (TraitPair<GpsWatcher> i in atek.World.ActorsWithTrait<GpsWatcher>())
i.Trait.RefreshGranted();
if ((Granted || GrantedAllies) && atek.World.LocalPlayer != null && (atek.World.LocalPlayer.Stances[atek.Owner] == Stance.Ally))
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(atek.World.RenderPlayer))
atek.Owner.Shroud.ExploreAll(atek.World);
}
void RefreshGranted()
{
Granted = (actors.Count > 0 && Launched);
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p =>
p.Actor.Owner.Stances[owner] == Stance.Ally && p.Trait.Granted);
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p => p.Actor.Owner.IsAlliedWith(owner) && p.Trait.Granted);
if (Granted || GrantedAllies)
owner.Shroud.ExploreAll(owner.World);
}