Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/CpUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,8 @@ function CpUtil.removeEventListenersBySpecialization(vehicle, specClass)
end
end
end
end

function CpUtil.getSoilSamplerSpecName()
return "spec_FS25_precisionFarming.soilSampler"
end
7 changes: 6 additions & 1 deletion scripts/ai/controllers/SoilSamplerController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ SoilSamplerController = CpObject(ImplementController)

function SoilSamplerController:init(vehicle, implement)
ImplementController.init(self, vehicle, implement)
self.soilSamplerSpec = implement.spec_soilSampler
local name = CpUtil.getSoilSamplerSpecName()
if name ~= nil then
self.soilSamplerSpec = implement[name]
else
CpUtil.errorImplement(implement, "Soil sampler is nil!")
end
self.lastSampleTaken = nil
-- The sampling radius is a hexagon, so we shrink this to roughly math a square.
self.distBetweenProbes = self.soilSamplerSpec.samplingRadius
Expand Down
2 changes: 1 addition & 1 deletion scripts/ai/strategies/AIDriveStrategyFieldWorkCourse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function AIDriveStrategyFieldWorkCourse:initializeImplementControllers(vehicle)
self:addImplementController(vehicle, VineCutterController, VineCutter, defaultDisabledStates)
self:addImplementController(vehicle, PalletFillerController, nil, defaultDisabledStates, "spec_pdlc_premiumExpansion.palletFiller")

self:addImplementController(vehicle, SoilSamplerController, nil, defaultDisabledStates, "spec_soilSampler")
self:addImplementController(vehicle, SoilSamplerController, nil, defaultDisabledStates, CpUtil.getSoilSamplerSpecName())
self:addImplementController(vehicle, StumpCutterController, StumpCutter, defaultDisabledStates)
self:addImplementController(vehicle, TreePlanterController, TreePlanter, {})

Expand Down
7 changes: 4 additions & 3 deletions scripts/ai/util/WorkWidthUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ function WorkWidthUtil.getAutomaticWorkWidthAndOffset(object, referenceNode, ign
end

--- Work width for soil samplers.
if not left and object.spec_soilSampler then
if object.spec_soilSampler.samplingRadius then
local width = 2 * object.spec_soilSampler.samplingRadius / math.sqrt(2)
local soilSamplerSpecName = CpUtil.getSoilSamplerSpecName()
if not left and object[soilSamplerSpecName] then
if object[soilSamplerSpecName].samplingRadius then
local width = 2 * object[soilSamplerSpecName].samplingRadius / math.sqrt(2)
left, right = width / 2, -width / 2
WorkWidthUtil.debug(object, 'using soil sampler width of %.1f (from sampling radius).', width)
else
Expand Down
34 changes: 31 additions & 3 deletions scripts/gui/CustomFieldHotspot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,35 @@ CustomFieldHotspot.CATEGORY = 200
CustomFieldHotspot.SLICE_ID = "gui.ingameMap_other"
CustomFieldHotspot.NAME = "CP_customFieldManager_hotspotName"
CustomFieldHotspot.COLOR = {0.61049, 0.56471, 0.00303, 1}
local CustomFieldHotspot_mt = Class(CustomFieldHotspot, FarmlandHotspot)
local CustomFieldHotspot_mt = Class(CustomFieldHotspot, MapHotspot)

function CustomFieldHotspot.new(customMt)
local self = FarmlandHotspot.new(customMt or CustomFieldHotspot_mt)
local self = MapHotspot.new(customMt or CustomFieldHotspot_mt)
self.width, self.height = getNormalizedScreenValues(60, 60)
self.icon = g_overlayManager:createOverlay("mapHotspots.miniMapField", 0, 0, self.width, self.height)
self.icon:setColor(unpack(HUD.COLOR.BACKGROUND_DARK))
self.clickArea = MapHotspot.getClickCircle(0.667)
self.lastName = ""
local _
_, self.textSize = getNormalizedScreenValues(0, 16)
self.textColor = { 1, 1, 1 }
self.textColorDisabled = {
0.89627,
0.92158,
0.81485,
0.5
}
_, self.textOffsetY = getNormalizedScreenValues(0, 2)
self.disabled = false
self.isFirstRendering = true
self.name = ""

self.setFarmland = FarmlandHotspot.setFarmland
self.getFarmland = FarmlandHotspot.getFarmland
self.setOwnerFarmId = FarmlandHotspot.setOwnerFarmId
self.setDisabled = FarmlandHotspot.setDisabled
self.updateColors = FarmlandHotspot.updateColors

return self
end

Expand All @@ -22,7 +46,7 @@ function CustomFieldHotspot:render(x, y, rotation, small)
self.icon:setDimension(width + self.width)
end
self.lastName = name
CustomFieldHotspot:superClass().render(self, x, y, rotation, small)
FarmlandHotspot.render(self, x, y, rotation, small)
end

function CustomFieldHotspot:setScale(scale)
Expand All @@ -33,6 +57,10 @@ function CustomFieldHotspot:getCategory()
return CustomFieldHotspot.CATEGORY
end

function CustomFieldHotspot:getSortingValue()
return math.huge
end

---@param field CustomField
function CustomFieldHotspot:setField(field)
self.field = field
Expand Down
2 changes: 1 addition & 1 deletion scripts/specializations/CpAIFieldWorker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function CpAIFieldWorker:getCanStartCpFieldWork()
-- Harvester with cutter on trailer attached.
AIUtil.hasCutterOnTrailerAttached(self) or
--- precision farming
AIUtil.hasChildVehicleWithSpecialization(self, nil, "spec_soilSampler") or
AIUtil.hasChildVehicleWithSpecialization(self, nil, CpUtil.getSoilSamplerSpecName()) or
--- FS22_aPalletAutoLoader from Achimobil: https://bitbucket.org/Achimobil79/ls22_palletautoloader/src/master/
AIUtil.hasChildVehicleWithSpecialization(self, nil, "spec_aPalletAutoLoader") or
--- FS22_UniversalAutoload from Loki79uk: https://github.com/loki79uk/FS22_UniversalAutoload
Expand Down
Loading