Remove Replacable actors for LineBuild too.
This commit is contained in:
committed by
abcdefg30
parent
a7004b2db7
commit
2f1edd4516
@@ -99,6 +99,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (buildableInfo != null && buildableInfo.ForceFaction != null)
|
||||
faction = buildableInfo.ForceFaction;
|
||||
|
||||
var replaceableTypes = actorInfo.TraitInfos<ReplacementInfo>()
|
||||
.SelectMany(r => r.ReplaceableTypes)
|
||||
.ToHashSet();
|
||||
|
||||
if (replaceableTypes.Any())
|
||||
foreach (var t in buildingInfo.Tiles(targetLocation))
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(t))
|
||||
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableTypes)))
|
||||
self.World.Remove(a);
|
||||
|
||||
if (os == "LineBuild")
|
||||
{
|
||||
// Build the parent actor first
|
||||
@@ -123,7 +133,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (t.Cell == targetLocation)
|
||||
continue;
|
||||
|
||||
w.CreateActor(t.Cell == targetLocation ? actorInfo.Name : segmentType, new TypeDictionary
|
||||
var segment = self.World.Map.Rules.Actors[segmentType];
|
||||
var replaceableSegments = segment.TraitInfos<ReplacementInfo>()
|
||||
.SelectMany(r => r.ReplaceableTypes)
|
||||
.ToHashSet();
|
||||
|
||||
if (replaceableSegments.Any())
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(t.Cell))
|
||||
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableSegments)))
|
||||
self.World.Remove(a);
|
||||
|
||||
w.CreateActor(segmentType, new TypeDictionary
|
||||
{
|
||||
new LocationInit(t.Cell),
|
||||
new OwnerInit(order.Player),
|
||||
@@ -163,16 +183,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|| !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, actorInfo, targetLocation))
|
||||
return;
|
||||
|
||||
var replaceableTypes = actorInfo.TraitInfos<ReplacementInfo>()
|
||||
.SelectMany(r => r.ReplaceableTypes)
|
||||
.ToHashSet();
|
||||
|
||||
if (replaceableTypes.Any())
|
||||
foreach (var t in buildingInfo.Tiles(targetLocation))
|
||||
foreach (var a in self.World.ActorMap.GetActorsAt(t))
|
||||
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableTypes)))
|
||||
self.World.Remove(a);
|
||||
|
||||
var building = w.CreateActor(actorInfo.Name, new TypeDictionary
|
||||
{
|
||||
new LocationInit(targetLocation),
|
||||
|
||||
Reference in New Issue
Block a user