Game no longer crashes if no ResourceLayer is used.
This commit is contained in:
@@ -230,10 +230,10 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
foreach (var r in previewRenderables)
|
foreach (var r in previewRenderables)
|
||||||
yield return r;
|
yield return r;
|
||||||
|
|
||||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
var res = world.WorldActor.TraitOrDefault<ResourceLayer>();
|
||||||
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, building, topLeft);
|
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, building, topLeft);
|
||||||
foreach (var t in buildingInfo.Tiles(topLeft))
|
foreach (var t in buildingInfo.Tiles(topLeft))
|
||||||
cells.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, buildingInfo) && res.GetResource(t) == null));
|
cells.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, buildingInfo) && (res == null || res.GetResource(t) == null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var cellPalette = wr.Palette(placeBuildingInfo.Palette);
|
var cellPalette = wr.Palette(placeBuildingInfo.Palette);
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (building.AllowInvalidPlacement)
|
if (building.AllowInvalidPlacement)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
var res = world.WorldActor.TraitOrDefault<ResourceLayer>();
|
||||||
return building.Tiles(topLeft).All(
|
return building.Tiles(topLeft).All(
|
||||||
t => world.Map.Contains(t) && res.GetResource(t) == null &&
|
t => world.Map.Contains(t) && (res == null || res.GetResource(t) == null) &&
|
||||||
world.IsCellBuildable(t, building, toIgnore));
|
world.IsCellBuildable(t, building, toIgnore));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user