Fix actors with no footprint not being copied and pasted

This commit is contained in:
abcdefg30
2019-08-08 11:42:45 +02:00
committed by RoosterDragon
parent eb39080248
commit 7f6149713e

View File

@@ -116,16 +116,11 @@ namespace OpenRA.Mods.Common.Traits
screenMap.Add(preview, preview.Bounds);
foreach (var kv in preview.Footprint)
{
List<EditorActorPreview> list;
if (!cellMap.TryGetValue(kv.Key, out list))
{
list = new List<EditorActorPreview>();
cellMap.Add(kv.Key, list);
}
AddPreviewLocation(preview, kv.Key);
list.Add(preview);
}
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
if (!preview.Footprint.Any())
AddPreviewLocation(preview, worldRenderer.World.Map.CellContaining(preview.CenterPosition));
if (!initialSetup)
{
@@ -207,6 +202,18 @@ namespace OpenRA.Mods.Common.Traits
p.ReplaceInit(new RuntimeNeighbourInit(NeighbouringPreviews(p.Footprint)));
}
void AddPreviewLocation(EditorActorPreview preview, CPos location)
{
List<EditorActorPreview> list;
if (!cellMap.TryGetValue(location, out list))
{
list = new List<EditorActorPreview>();
cellMap.Add(location, list);
}
list.Add(preview);
}
Dictionary<CPos, string[]> NeighbouringPreviews(IReadOnlyDictionary<CPos, SubCell> footprint)
{
var cells = Util.ExpandFootprint(footprint.Keys, true).Except(footprint.Keys);