-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraFlightManager.lua
More file actions
92 lines (66 loc) · 2.21 KB
/
CameraFlightManager.lua
File metadata and controls
92 lines (66 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
CameraFlightManager = {}
local CameraFlightManager_mt = Class(CameraFlightManager)
function CameraFlightManager.new()
local self = {}
setmetatable(self, CameraFlightManager_mt)
self.cameraFlightIsActive = false
self.abortCameraFlight = false
return self
end
function CameraFlightManager:load(xmlFile)
self.cameraFlights = {}
local i = 0
while true do
local key = string.format("map.cameraFlights.cameraFlight(%d)", i)
if not hasXMLProperty(xmlFile, key) then
break
end
local flightType = getXMLString(xmlFile, key .. "#type")
local speedScale = getXMLFloat(xmlFile, key .. "#speedScale")
local filename = getXMLString(xmlFile, key .. "#filename")
local i3dFilename = Utils.getFilename(filename, self.baseDirectory)
local camera = createCamera("cameraFlight_" .. flightType, math.rad(60), 1, 10000)
local cameraFlight = CameraPath.createFromI3D(i3dFilename, speedScale, camera)
if self.cameraFlights[flightType] == nil then
self.cameraFlights[flightType] = cameraFlight
end
i = i + 1
end
local function onMenuAbort()
self.abortCameraFlight = true
g_inputBinding:removeActionEventsByTarget(self)
end
g_inputBinding:registerActionEvent(InputAction.MENU, self, onMenuAbort, false, true, false, true)
end
function CameraFlightManager:delete()
for _, cameraPath in pairs(self.cameraFlights) do
cameraPath:delete()
end
end
function CameraFlightManager:update(dt)
if g_server ~= nil and g_client ~= nil and self.cameraFlights.careerStart ~= nil and not self.careerStartFlightPlayed then
local cameraPath = self.cameraFlights.careerStart
if g_currentMission.controlledVehicle ~= nil then
self.abortCameraFlight = true
end
if self.abortCameraFlight then
cameraPath:deactivate()
self.careerStartFlightPlayed = true
g_currentMission.player.walkingIsLocked = false
return
end
local continue = not g_gui:getIsGuiVisible()
if continue then
if cameraPath.time == 0 then
cameraPath:activate()
end
cameraPath:update(dt)
g_currentMission.player.walkingIsLocked = true
if cameraPath.maxTime <= cameraPath.time then
self.careerStartFlightPlayed = true
cameraPath:deactivate()
g_currentMission.player.walkingIsLocked = false
end
end
end
end