diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs index 5076ba7bce..dd83f71829 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorActorBrush.cs @@ -41,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets Actor = actor; this.owner = owner; + var ownerName = owner.Name; preview = editorWidget.Get("DRAG_ACTOR_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; @@ -50,10 +51,15 @@ namespace OpenRA.Mods.Common.Widgets if (buildingInfo != null) centerOffset = buildingInfo.CenterOffset(world); + // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners + var specificOwnerInfo = actor.TraitInfoOrDefault(); + if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName)) + ownerName = specificOwnerInfo.ValidOwnerNames.First(); + var td = new TypeDictionary(); td.Add(new FacingInit(facing)); td.Add(new TurretFacingInit(facing)); - td.Add(new OwnerInit(owner.Name)); + td.Add(new OwnerInit(ownerName)); td.Add(new FactionInit(owner.Faction)); preview.SetPreview(actor, td); @@ -94,8 +100,14 @@ namespace OpenRA.Mods.Common.Widgets if (!footprint.All(c => world.Map.Tiles.Contains(cell + c))) return true; + // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners + var ownerName = owner.Name; + var specificOwnerInfo = Actor.TraitInfoOrDefault(); + if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName)) + ownerName = specificOwnerInfo.ValidOwnerNames.First(); + var newActorReference = new ActorReference(Actor.Name); - newActorReference.Add(new OwnerInit(owner.Name)); + newActorReference.Add(new OwnerInit(ownerName)); newActorReference.Add(new LocationInit(cell));