diff --git a/HeadtrackingCameraSuspension.lua b/HeadtrackingCameraSuspension.lua new file mode 100644 index 0000000..096c67f --- /dev/null +++ b/HeadtrackingCameraSuspension.lua @@ -0,0 +1,39 @@ +HeadtrackingCameraSuspension = {} + +function HeadtrackingCameraSuspension.prerequisitesPresent(specializations) + return true +end + +function HeadtrackingCameraSuspension.registerEventListeners(vehicleType) + -- print("HeadtrackingCameraSuspension.registerEventListeners"); + SpecializationUtil.registerEventListener(vehicleType, "onLoad", HeadtrackingCameraSuspension); +end + + +function HeadtrackingCameraSuspension:onLoad(savegame) + -- print("HeadtrackingCameraSuspension:onLoad") + VehicleCamera.onActiveCameraSuspensionSettingChanged = Utils.overwrittenFunction(VehicleCamera.onActiveCameraSuspensionSettingChanged, HeadtrackingCameraSuspension.onActiveCameraSuspensionSettingChanged) +end + +---Called when camera suspension setting has changed +-- @param bool newState new setting state +function HeadtrackingCameraSuspension:onActiveCameraSuspensionSettingChanged(superFunc, newState) + -- print("VehicleCamera:onActiveCameraSuspensionSettingChanged") + + if self.suspensionNode ~= nil then + if self.lastActiveCameraSuspensionSetting ~= newState then + if newState then + link(self.cameraSuspensionParentNode, self.cameraPositionNode) + else + link(self.cameraBaseParentNode, self.cameraPositionNode) + end + + -- Update headTrackingNode + if self.headTrackingNode ~= nil then + link(getParent(self.cameraPositionNode), self.headTrackingNode) + end + + self.lastActiveCameraSuspensionSetting = newState + end + end +end diff --git a/HeadtrackingCameraSuspensionRegister.lua b/HeadtrackingCameraSuspensionRegister.lua new file mode 100644 index 0000000..62ccaa0 --- /dev/null +++ b/HeadtrackingCameraSuspensionRegister.lua @@ -0,0 +1,20 @@ +if g_specializationManager:getSpecializationByName("headtrackingCameraSuspension") == nil then + g_specializationManager:addSpecialization( + "headtrackingCameraSuspension", + "HeadtrackingCameraSuspension", + Utils.getFilename("HeadtrackingCameraSuspension.lua", + g_currentModDirectory), + true + ) +end + +for typeName, typeEntry in pairs(g_vehicleTypeManager.types) do + if + + SpecializationUtil.hasSpecialization(Enterable, typeEntry.specializations) + + + then + g_vehicleTypeManager:addSpecialization(typeName, "headtrackingCameraSuspension") + end +end \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..49f31c7 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Headtracking Camera Suspension + +This is a mod for Farming Simulator 22. + +If you are playing with headtracking in the current version of the game you will have no dynamic camera suspension, even if enabled in the settings. This mod fixes this problem. + +--- + +Dies ist ein Mod für den Farming Simulator 22 + +Wenn du mit Headtracking spielst, funktioniert in der aktuellen Spielversion die dynamische Kamera (federnde Sitzkamera) nicht, selbst wenn man dies in den Einstellungen aktiviert. Dieser Mod behebt dieses Problem. \ No newline at end of file diff --git a/icon.dds b/icon.dds new file mode 100644 index 0000000..477741b Binary files /dev/null and b/icon.dds differ diff --git a/misc/FS22_HeadtrackingCameraSuspension.afdesign b/misc/FS22_HeadtrackingCameraSuspension.afdesign new file mode 100644 index 0000000..f28bbbd Binary files /dev/null and b/misc/FS22_HeadtrackingCameraSuspension.afdesign differ diff --git a/misc/FS22_HeadtrackingCameraSuspension.png b/misc/FS22_HeadtrackingCameraSuspension.png new file mode 100644 index 0000000..53ac614 Binary files /dev/null and b/misc/FS22_HeadtrackingCameraSuspension.png differ diff --git a/modDesc.xml b/modDesc.xml new file mode 100644 index 0000000..7ed4a21 --- /dev/null +++ b/modDesc.xml @@ -0,0 +1,17 @@ + + + CptCray + 1.0.0.0 + + <en>Headtracking Camera Suspension</en> + + + + + icon.dds + + + + + +