Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCraymer committed Jan 9, 2022
0 parents commit 4149080
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
39 changes: 39 additions & 0 deletions HeadtrackingCameraSuspension.lua
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions HeadtrackingCameraSuspensionRegister.lua
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Binary file added icon.dds
Binary file not shown.
Binary file added misc/FS22_HeadtrackingCameraSuspension.afdesign
Binary file not shown.
Binary file added misc/FS22_HeadtrackingCameraSuspension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions modDesc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="61">
<author>CptCray</author>
<version>1.0.0.0</version>
<title>
<en>Headtracking Camera Suspension</en>
</title>
<description>
<en><![CDATA[Headtracking Camera Suspension]]></en>
</description>
<iconFilename>icon.dds</iconFilename>
<multiplayer supported="true"/>

<extraSourceFiles>
<sourceFile filename="HeadtrackingCameraSuspensionRegister.lua"/>
</extraSourceFiles>
</modDesc>

0 comments on commit 4149080

Please sign in to comment.