Skip to content

Commit dba0545

Browse files
authored
Merge pull request #841 from Courseplay/PrecisionFarmingSoilSampler
Changed soil sampler spec reference
2 parents ad19c63 + 22dea90 commit dba0545

6 files changed

Lines changed: 47 additions & 9 deletions

File tree

scripts/CpUtil.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,8 @@ function CpUtil.removeEventListenersBySpecialization(vehicle, specClass)
501501
end
502502
end
503503
end
504+
end
505+
506+
function CpUtil.getSoilSamplerSpecName()
507+
return "spec_FS25_precisionFarming.soilSampler"
504508
end

scripts/ai/controllers/SoilSamplerController.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ SoilSamplerController = CpObject(ImplementController)
44

55
function SoilSamplerController:init(vehicle, implement)
66
ImplementController.init(self, vehicle, implement)
7-
self.soilSamplerSpec = implement.spec_soilSampler
7+
local name = CpUtil.getSoilSamplerSpecName()
8+
if name ~= nil then
9+
self.soilSamplerSpec = implement[name]
10+
else
11+
CpUtil.errorImplement(implement, "Soil sampler is nil!")
12+
end
813
self.lastSampleTaken = nil
914
-- The sampling radius is a hexagon, so we shrink this to roughly math a square.
1015
self.distBetweenProbes = self.soilSamplerSpec.samplingRadius

scripts/ai/strategies/AIDriveStrategyFieldWorkCourse.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function AIDriveStrategyFieldWorkCourse:initializeImplementControllers(vehicle)
278278
self:addImplementController(vehicle, VineCutterController, VineCutter, defaultDisabledStates)
279279
self:addImplementController(vehicle, PalletFillerController, nil, defaultDisabledStates, "spec_pdlc_premiumExpansion.palletFiller")
280280

281-
self:addImplementController(vehicle, SoilSamplerController, nil, defaultDisabledStates, "spec_soilSampler")
281+
self:addImplementController(vehicle, SoilSamplerController, nil, defaultDisabledStates, CpUtil.getSoilSamplerSpecName())
282282
self:addImplementController(vehicle, StumpCutterController, StumpCutter, defaultDisabledStates)
283283
self:addImplementController(vehicle, TreePlanterController, TreePlanter, {})
284284

scripts/ai/util/WorkWidthUtil.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ function WorkWidthUtil.getAutomaticWorkWidthAndOffset(object, referenceNode, ign
8484
end
8585

8686
--- Work width for soil samplers.
87-
if not left and object.spec_soilSampler then
88-
if object.spec_soilSampler.samplingRadius then
89-
local width = 2 * object.spec_soilSampler.samplingRadius / math.sqrt(2)
87+
local soilSamplerSpecName = CpUtil.getSoilSamplerSpecName()
88+
if not left and object[soilSamplerSpecName] then
89+
if object[soilSamplerSpecName].samplingRadius then
90+
local width = 2 * object[soilSamplerSpecName].samplingRadius / math.sqrt(2)
9091
left, right = width / 2, -width / 2
9192
WorkWidthUtil.debug(object, 'using soil sampler width of %.1f (from sampling radius).', width)
9293
else

scripts/gui/CustomFieldHotspot.lua

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,35 @@ CustomFieldHotspot.CATEGORY = 200
55
CustomFieldHotspot.SLICE_ID = "gui.ingameMap_other"
66
CustomFieldHotspot.NAME = "CP_customFieldManager_hotspotName"
77
CustomFieldHotspot.COLOR = {0.61049, 0.56471, 0.00303, 1}
8-
local CustomFieldHotspot_mt = Class(CustomFieldHotspot, FarmlandHotspot)
8+
local CustomFieldHotspot_mt = Class(CustomFieldHotspot, MapHotspot)
99

1010
function CustomFieldHotspot.new(customMt)
11-
local self = FarmlandHotspot.new(customMt or CustomFieldHotspot_mt)
11+
local self = MapHotspot.new(customMt or CustomFieldHotspot_mt)
12+
self.width, self.height = getNormalizedScreenValues(60, 60)
13+
self.icon = g_overlayManager:createOverlay("mapHotspots.miniMapField", 0, 0, self.width, self.height)
14+
self.icon:setColor(unpack(HUD.COLOR.BACKGROUND_DARK))
15+
self.clickArea = MapHotspot.getClickCircle(0.667)
1216
self.lastName = ""
17+
local _
18+
_, self.textSize = getNormalizedScreenValues(0, 16)
19+
self.textColor = { 1, 1, 1 }
20+
self.textColorDisabled = {
21+
0.89627,
22+
0.92158,
23+
0.81485,
24+
0.5
25+
}
26+
_, self.textOffsetY = getNormalizedScreenValues(0, 2)
27+
self.disabled = false
28+
self.isFirstRendering = true
29+
self.name = ""
30+
31+
self.setFarmland = FarmlandHotspot.setFarmland
32+
self.getFarmland = FarmlandHotspot.getFarmland
33+
self.setOwnerFarmId = FarmlandHotspot.setOwnerFarmId
34+
self.setDisabled = FarmlandHotspot.setDisabled
35+
self.updateColors = FarmlandHotspot.updateColors
36+
1337
return self
1438
end
1539

@@ -22,7 +46,7 @@ function CustomFieldHotspot:render(x, y, rotation, small)
2246
self.icon:setDimension(width + self.width)
2347
end
2448
self.lastName = name
25-
CustomFieldHotspot:superClass().render(self, x, y, rotation, small)
49+
FarmlandHotspot.render(self, x, y, rotation, small)
2650
end
2751

2852
function CustomFieldHotspot:setScale(scale)
@@ -33,6 +57,10 @@ function CustomFieldHotspot:getCategory()
3357
return CustomFieldHotspot.CATEGORY
3458
end
3559

60+
function CustomFieldHotspot:getSortingValue()
61+
return math.huge
62+
end
63+
3664
---@param field CustomField
3765
function CustomFieldHotspot:setField(field)
3866
self.field = field

scripts/specializations/CpAIFieldWorker.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function CpAIFieldWorker:getCanStartCpFieldWork()
283283
-- Harvester with cutter on trailer attached.
284284
AIUtil.hasCutterOnTrailerAttached(self) or
285285
--- precision farming
286-
AIUtil.hasChildVehicleWithSpecialization(self, nil, "spec_soilSampler") or
286+
AIUtil.hasChildVehicleWithSpecialization(self, nil, CpUtil.getSoilSamplerSpecName()) or
287287
--- FS22_aPalletAutoLoader from Achimobil: https://bitbucket.org/Achimobil79/ls22_palletautoloader/src/master/
288288
AIUtil.hasChildVehicleWithSpecialization(self, nil, "spec_aPalletAutoLoader") or
289289
--- FS22_UniversalAutoload from Loki79uk: https://github.com/loki79uk/FS22_UniversalAutoload

0 commit comments

Comments
 (0)