Replace ResourceLayer references with IResourceLayer in traits/warheads.

This commit is contained in:
Paul Chote
2021-03-07 17:31:26 +00:00
committed by reaperrr
parent 5adcbe4c78
commit dcd8eccee4
14 changed files with 72 additions and 80 deletions

View File

@@ -46,12 +46,12 @@ namespace OpenRA.Mods.Cnc.Traits
public class TransformsNearResources : ITick
{
readonly TransformsNearResourcesInfo info;
readonly ResourceLayer resourceLayer;
readonly IResourceLayer resourceLayer;
int delay;
public TransformsNearResources(Actor self, TransformsNearResourcesInfo info)
{
resourceLayer = self.World.WorldActor.Trait<ResourceLayer>();
resourceLayer = self.World.WorldActor.Trait<IResourceLayer>();
delay = Common.Util.RandomDelay(self.World, info.Delay);
this.info = info;
}
@@ -66,12 +66,11 @@ namespace OpenRA.Mods.Cnc.Traits
{
var location = self.Location + direction;
var resource = resourceLayer.GetResourceType(location);
if (resource == null || resource.Info.Type != info.Type)
var resource = resourceLayer.GetResource(location);
if (resource.Type == null || resource.Type.Info.Type != info.Type)
continue;
var density = resourceLayer.GetResourceDensity(location);
if (density < info.Density)
if (resource.Density < info.Density)
continue;
if (++adjacent < info.Adjacency)