Improve Replaceable logic:

- Remove BuildingInfluence checks
- Support multiple Replaceable/Replacement traits on the same actors
- Fix description typos
This commit is contained in:
Paul Chote
2020-10-08 22:37:12 +01:00
committed by abcdefg30
parent 8aeec24c9b
commit daa8c74c37
4 changed files with 54 additions and 25 deletions

View File

@@ -163,16 +163,15 @@ namespace OpenRA.Mods.Common.Traits
|| !buildingInfo.IsCloseEnoughToBase(self.World, order.Player, actorInfo, targetLocation))
return;
var replacementInfo = actorInfo.TraitInfoOrDefault<ReplacementInfo>();
if (replacementInfo != null)
{
var buildingInfluence = self.World.WorldActor.Trait<BuildingInfluence>();
var replaceableTypes = actorInfo.TraitInfos<ReplacementInfo>()
.SelectMany(r => r.ReplaceableTypes)
.ToHashSet();
if (replaceableTypes.Any())
foreach (var t in buildingInfo.Tiles(targetLocation))
{
var host = buildingInfluence.GetBuildingAt(t);
host?.World.Remove(host);
}
}
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
{