public void Seed(Actor self) { var cell = Util.RandomWalk(self.Location, self.World.SharedRandom) .Take(info.MaxRange) .SkipWhile(p => !self.World.Map.Contains(p) || (resLayer.GetResourceType(p) == resourceType && resLayer.IsFull(p))) .Cast <CPos?>().FirstOrDefault(); if (cell != null && resLayer.CanSpawnResourceAt(resourceType, cell.Value)) { resLayer.AddResource(resourceType, cell.Value, 1); } }
public bool CanHarvestCell(Actor self, CPos cell) { // Resources only exist in the ground layer if (cell.Layer != 0) { return(false); } var resType = resLayer.GetResourceType(cell); if (resType == null) { return(false); } // Can the harvester collect this kind of resource? return(Info.Resources.Contains(resType.Info.Type)); }