Merge pull request #11144 from pchote/fix-start-game-frozen-explored-map
Generate frozen actor renderables for all map-placed actors.
This commit is contained in:
@@ -20,8 +20,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("This actor will remain visible (but not updated visually) under fog, once discovered.")]
|
||||
public class FrozenUnderFogInfo : ITraitInfo, Requires<BuildingInfo>, IDefaultVisibilityInfo
|
||||
{
|
||||
public readonly bool StartsRevealed = false;
|
||||
|
||||
[Desc("Players with these stances can always see the actor.")]
|
||||
public readonly Stance AlwaysVisibleStances = Stance.Ally;
|
||||
|
||||
@@ -55,8 +53,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var map = init.World.Map;
|
||||
|
||||
// Spawned actors (e.g. building husks) shouldn't be revealed
|
||||
startsRevealed = info.StartsRevealed && !init.Contains<ParentActorInit>();
|
||||
// Explore map-placed actors if the "Explore Map" option is enabled
|
||||
var exploredMap = !init.World.LobbyInfo.GlobalSettings.Shroud;
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
|
||||
var footprintCells = FootprintUtils.Tiles(init.Self).ToList();
|
||||
footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
|
||||
}
|
||||
@@ -142,4 +141,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return IsVisible(self, self.World.RenderPlayer) || isRendering ? r : SpriteRenderable.None;
|
||||
}
|
||||
}
|
||||
|
||||
public class HiddenUnderFogInit : IActorInit { }
|
||||
}
|
||||
@@ -140,6 +140,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
|
||||
UpdateNeighbours(self);
|
||||
|
||||
// Set the initial animation frame before the render tick (for frozen actor previews)
|
||||
self.World.AddFrameEndTask(_ => DefaultAnimation.Tick());
|
||||
}
|
||||
|
||||
static void UpdateNeighbours(Actor self)
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var initDict = actorReference.InitDict;
|
||||
initDict.Add(new SkipMakeAnimsInit());
|
||||
initDict.Add(new SpawnedByMapInit(kv.Key));
|
||||
var actor = world.CreateActor(actorReference.Type, initDict);
|
||||
Actors[kv.Key] = actor;
|
||||
LastMapActorID = actor.ActorID;
|
||||
@@ -45,4 +46,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public class SkipMakeAnimsInit : IActorInit, ISuppressInitExport { }
|
||||
public class SpawnedByMapInit : IActorInit<string>, ISuppressInitExport
|
||||
{
|
||||
public readonly string Name;
|
||||
public SpawnedByMapInit(string name) { Name = name; }
|
||||
|
||||
public string Value(World world)
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user