Fix frozen actors lacking tooltips if they have the cloak ability.

Since bbf5970bc1 we update frozen actors only when required.

In 8339c6843e a regression was fixed where actors created in line of sight would be invisible.

Here, we fix a related regression where cloaked units that are revealed, and then frozen when you move out of line of sight would lack tooltips.

The fix centers around the setting of the Hidden flag. In the old code this used CanBeViewedByPlayer which checks for visibility modifiers and then uses the default visibility. The bug with this code is that when a visibility modifier was not hiding the actor, then we would report the default visibility state instead. However the frozen visibility state applies here which means if the frozen actor is visible, then we consider the actor to be hidden and therefore tooltips will not appear. In the fixed version we only consider the modifiers. This means a visibility modifier such as Cloak can hide the frozen actor tooltips. But otherwise we do not consider the frozen actor to be hidden. This prevents a frozen actor from hiding its own tooltips in some unintended circular logic. Hidden now becomes just a flag to indicate if the visibility modifiers are overriding things, as intended.
This commit is contained in:
RoosterDragon
2022-08-19 21:46:23 +01:00
committed by Gustas
parent 16babc1975
commit 1fc1bdc849
3 changed files with 30 additions and 17 deletions

View File

@@ -81,13 +81,11 @@ namespace OpenRA.Mods.Common.Traits
for (var playerIndex = 0; playerIndex < frozenStates.Count; playerIndex++)
{
var state = frozenStates[playerIndex];
var frozen = state.FrozenActor;
if (startsRevealed || state.IsVisible)
{
UpdateFrozenActor(state.FrozenActor, playerIndex);
UpdateFrozenActor(frozen, playerIndex);
// Needed so tooltips appear.
state.FrozenActor.Hidden = false;
}
frozen.RefreshHidden();
}
});
@@ -113,6 +111,8 @@ namespace OpenRA.Mods.Common.Traits
if (isVisible)
UpdateFrozenActor(frozen, frozen.Viewer.World.Players.IndexOf(frozen.Viewer));
frozen.RefreshHidden();
}
bool IsVisibleInner(Player byPlayer)
@@ -176,7 +176,9 @@ namespace OpenRA.Mods.Common.Traits
{
// Force a state update for the old owner so the tooltip etc doesn't show them as the owner
var oldOwnerIndex = self.World.Players.IndexOf(oldOwner);
UpdateFrozenActor(frozenStates[oldOwnerIndex].FrozenActor, oldOwnerIndex);
var frozen = frozenStates[oldOwnerIndex].FrozenActor;
UpdateFrozenActor(frozen, oldOwnerIndex);
frozen.RefreshHidden();
}
void INotifyActorDisposing.Disposing(Actor self)