Skip to content

Commit

Permalink
Add check if we successfully inserted the manual attach connection ho…
Browse files Browse the repository at this point in the history
…ses extension spec.
  • Loading branch information
stijnwop committed Mar 10, 2023
1 parent a35a045 commit abde44e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ManualAttach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,15 @@ function ManualAttach.installSpecializations(vehicleTypeManager, specializationM
if SpecializationUtil.hasSpecialization(ConnectionHoses, typeEntry.specializations)
and SpecializationUtil.hasSpecialization(Attachable, typeEntry.specializations) then

if SpecializationUtil.hasSpecialization(Enterable, typeEntry.specializations) and
(SpecializationUtil.hasSpecialization(LogGrab, typeEntry.specializations)
local hasEnterable = SpecializationUtil.hasSpecialization(Enterable, typeEntry.specializations)
local function isEnterableException()
return SpecializationUtil.hasSpecialization(LogGrab, typeEntry.specializations)
or SpecializationUtil.hasSpecialization(BaleLoader, typeEntry.specializations)
or SpecializationUtil.hasSpecialization(Roller, typeEntry.specializations)) then
vehicleTypeManager:addSpecialization(typeName, modName .. ".manualAttachConnectionHoses")
elseif not SpecializationUtil.hasSpecialization(Enterable, typeEntry.specializations) then
or SpecializationUtil.hasSpecialization(Roller, typeEntry.specializations)
or SpecializationUtil.hasSpecialization(UmbilicalPumpMotor, typeEntry.specializations)
end

if not hasEnterable or (hasEnterable and isEnterableException()) then
vehicleTypeManager:addSpecialization(typeName, modName .. ".manualAttachConnectionHoses")
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/utils/ManualAttachUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ end
---@param vehicle table
---@return boolean
function ManualAttachUtil.hasConnectionHoses(object, vehicle)
if not SpecializationUtil.hasSpecialization(ManualAttachConnectionHoses, object.specializations) then
return false
end

local attacherJointIndex = vehicle:getAttacherJointIndexFromObject(object)
local hasTarget = ManualAttachUtil.hasConnectionTarget(vehicle, attacherJointIndex)

Expand Down

0 comments on commit abde44e

Please sign in to comment.