GpsDotEffect, ShouldRender, optimization.
This commit is contained in:
committed by
Matthias Mailänder
parent
7e67889294
commit
7754e486ee
@@ -434,6 +434,11 @@ namespace OpenRA.Traits
|
|||||||
return explored.Contains(uv);
|
return explored.Contains(uv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CellVisibility GetVisibility(WPos pos)
|
||||||
|
{
|
||||||
|
return GetVisibility(map.ProjectedCellCovering(pos));
|
||||||
|
}
|
||||||
|
|
||||||
// PERF: Combine IsExplored and IsVisible.
|
// PERF: Combine IsExplored and IsVisible.
|
||||||
public CellVisibility GetVisibility(PPos puv)
|
public CellVisibility GetVisibility(PPos puv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,13 +32,16 @@ namespace OpenRA.Mods.Cnc.Effects
|
|||||||
class DotState
|
class DotState
|
||||||
{
|
{
|
||||||
public readonly GpsWatcher Watcher;
|
public readonly GpsWatcher Watcher;
|
||||||
public readonly FrozenActor FrozenActor;
|
public readonly bool FrozenActorWithRenderables;
|
||||||
public bool Visible;
|
public bool Visible;
|
||||||
public DotState(Actor a, GpsWatcher watcher, FrozenActorLayer frozenLayer)
|
public DotState(Actor a, GpsWatcher watcher, FrozenActorLayer frozenLayer)
|
||||||
{
|
{
|
||||||
Watcher = watcher;
|
Watcher = watcher;
|
||||||
if (frozenLayer != null)
|
if (frozenLayer != null)
|
||||||
FrozenActor = frozenLayer.FromID(a.ActorID);
|
{
|
||||||
|
var frozenActor = frozenLayer.FromID(a.ActorID);
|
||||||
|
FrozenActorWithRenderables = frozenActor != null ? frozenActor.HasRenderables : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,17 +61,26 @@ namespace OpenRA.Mods.Cnc.Effects
|
|||||||
|
|
||||||
bool ShouldRender(DotState state, Player toPlayer)
|
bool ShouldRender(DotState state, Player toPlayer)
|
||||||
{
|
{
|
||||||
|
// Hide the indicator if a frozen actor portrait is visible
|
||||||
|
if (state.FrozenActorWithRenderables)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Hide the indicator if no watchers are available
|
// Hide the indicator if no watchers are available
|
||||||
if (!state.Watcher.Granted && !state.Watcher.GrantedAllies)
|
if (!state.Watcher.Granted && !state.Watcher.GrantedAllies)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Hide the indicator if a frozen actor portrait is visible
|
// Hide the indicator if the unit appears to be owned by an allied player
|
||||||
if (state.FrozenActor != null && state.FrozenActor.HasRenderables)
|
var owner = actor.EffectiveOwner?.Owner;
|
||||||
|
if (owner != null && toPlayer.IsAlliedWith(owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Hide the indicator if the unit appears to be owned by an allied player
|
// Hide the indicator behind shroud
|
||||||
if (actor.EffectiveOwner != null && actor.EffectiveOwner.Owner != null &&
|
var visibility = toPlayer.Shroud.GetVisibility(actor.CenterPosition);
|
||||||
toPlayer.IsAlliedWith(actor.EffectiveOwner.Owner))
|
if (!visibility.HasFlag(Shroud.CellVisibility.Explored))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Hide for visible
|
||||||
|
if (visibility.HasFlag(Shroud.CellVisibility.Visible))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Hide indicator if the actor wouldn't otherwise be visible if there wasn't fog
|
// Hide indicator if the actor wouldn't otherwise be visible if there wasn't fog
|
||||||
@@ -76,11 +88,7 @@ namespace OpenRA.Mods.Cnc.Effects
|
|||||||
if (!visibilityModifier.IsVisible(actor, toPlayer))
|
if (!visibilityModifier.IsVisible(actor, toPlayer))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Hide the indicator behind shroud
|
return true;
|
||||||
if (!toPlayer.Shroud.IsExplored(actor.CenterPosition))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return !visibility.IsVisible(actor, toPlayer) && toPlayer.Shroud.IsExplored(actor.CenterPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IEffect.Tick(World world)
|
void IEffect.Tick(World world)
|
||||||
|
|||||||
@@ -85,8 +85,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
Granted = actors.Count > 0 && Launched;
|
Granted = actors.Count > 0 && Launched;
|
||||||
GrantedAllies = allyWatchers.Any(w => w.Trait.Granted);
|
GrantedAllies = allyWatchers.Any(w => w.Trait.Granted);
|
||||||
|
|
||||||
var allyLaunched = allyWatchers.Any(w => w.Trait.Launched);
|
if (!explored && (Launched || allyWatchers.Any(w => w.Trait.Launched)))
|
||||||
if ((Launched || allyLaunched) && !explored)
|
|
||||||
{
|
{
|
||||||
explored = true;
|
explored = true;
|
||||||
owner.Shroud.ExploreAll();
|
owner.Shroud.ExploreAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user