diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index dfd84c5f38..5c86323984 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -36,6 +36,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("When this actor is sold should all of its passengers be unloaded?")] public readonly bool EjectOnSell = true; + [Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")] + public readonly string[] UnloadTerrainTypes = { }; + [Desc("Which direction the passenger will face (relative to the transport) when unloading.")] public readonly int PassengerFacing = 128; @@ -55,6 +58,7 @@ namespace OpenRA.Mods.Common.Traits readonly Stack cargo = new Stack(); readonly HashSet reserves = new HashSet(); readonly Lazy facing; + readonly bool checkTerrainType; int totalWeight = 0; int reservedWeight = 0; @@ -71,6 +75,7 @@ namespace OpenRA.Mods.Common.Traits self = init.Self; Info = info; Unloading = false; + checkTerrainType = info.UnloadTerrainTypes.Length > 0; if (init.Contains()) { @@ -148,6 +153,14 @@ namespace OpenRA.Mods.Common.Traits bool CanUnload() { + if (checkTerrainType) + { + var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type; + + if (!Info.UnloadTerrainTypes.Contains(terrainType)) + return false; + } + return !IsEmpty(self) && (helicopter == null || helicopter.CanLand(self.Location)) && CurrentAdjacentCells != null && CurrentAdjacentCells.Any(c => Passengers.Any(p => p.Trait().CanEnterCell(c))); }