Compare commits
No commits in common. "main" and "1.4.1" have entirely different histories.
@ -41,11 +41,17 @@ local function Retrieve(inventoryId)
|
|||||||
career_vehicleSaveSystem.CheckSavedAsync(function()
|
career_vehicleSaveSystem.CheckSavedAsync(function()
|
||||||
extensions.core_jobsystem.create(
|
extensions.core_jobsystem.create(
|
||||||
function(job)
|
function(job)
|
||||||
career_vehicleSaveSystem.SetFade(true)
|
|
||||||
job.sleep(1)
|
|
||||||
spawnVehicle(inventoryId, function()
|
spawnVehicle(inventoryId, function()
|
||||||
career_vehicleSaveSystem.TeleportVehicle(inventoryId, false)
|
local veh = be:getObjectByID(career_modules_inventory.getVehicleIdFromInventoryId(inventoryId))
|
||||||
career_vehicleSaveSystem.LoadVehicle(inventoryId, currentVehicleValue < vehicleValue)
|
local location = { pos = veh:getPosition(), rot = quat(0, 0, 1, 0) * quat(veh:getRefNodeRotation()) }
|
||||||
|
local garage = career_modules_inventory.getClosestGarage(location.pos)
|
||||||
|
job.sleep(1)
|
||||||
|
if currentVehicleValue < vehicleValue then
|
||||||
|
career_vehicleSaveSystem.LoadVehicle(inventoryId)
|
||||||
|
else
|
||||||
|
log('I', 'retrieval', 'retrieving vehicle ' .. inventoryId .. " in an undamaged state")
|
||||||
|
end
|
||||||
|
freeroam_facilities.teleportToGarage(garage.id, veh, false)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.dependencies = { 'freeroam_facilities', 'ui_fadeScreen', 'career_career', 'career_saveSystem',
|
M.dependencies = { 'career_career', 'career_saveSystem', 'career_modules_inventory' }
|
||||||
'career_modules_inventory' }
|
|
||||||
|
|
||||||
local extensionName = "career_vehicleSaveSystem"
|
local extensionName = "career_vehicleSaveSystem"
|
||||||
local vehicleSaves_temp = "/temp/career/vehicle_saves"
|
local vehicleSaves_temp = "/temp/career/vehicle_saves"
|
||||||
@ -76,42 +75,6 @@ local function DequeueVehicleToSave(inventoryId)
|
|||||||
M.queuedVehicleSaves[inventoryId] = nil
|
M.queuedVehicleSaves[inventoryId] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function TeleportVehicle(inventoryId, delayed, callback)
|
|
||||||
log("I", "loading", "teleporting vehicle " .. inventoryId)
|
|
||||||
|
|
||||||
local veh = be:getObjectByID(career_modules_inventory.getVehicleIdFromInventoryId(inventoryId))
|
|
||||||
local location = { pos = veh:getPosition(), rot = quat(0, 0, 1, 0) * quat(veh:getRefNodeRotation()) }
|
|
||||||
local garage = career_modules_inventory.getClosestGarage(location.pos)
|
|
||||||
|
|
||||||
extensions.core_jobsystem.create(function(job)
|
|
||||||
if delayed then
|
|
||||||
job.sleep(1)
|
|
||||||
end
|
|
||||||
freeroam_facilities.teleportToGarage(garage.id, veh, false)
|
|
||||||
|
|
||||||
if callback then
|
|
||||||
callback()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local fadeInProgress = false
|
|
||||||
local function SetFade(fade)
|
|
||||||
if fadeInProgress and fade then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if not fadeInProgress and not fade then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if fade then
|
|
||||||
ui_fadeScreen.start(0.5)
|
|
||||||
fadeInProgress = true
|
|
||||||
else
|
|
||||||
ui_fadeScreen.stop(0.5)
|
|
||||||
fadeInProgress = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function VehiclesSaved()
|
local function VehiclesSaved()
|
||||||
if next(M.queuedVehicleSaves) == nil then
|
if next(M.queuedVehicleSaves) == nil then
|
||||||
log('I', 'saving', 'all vehicles saved')
|
log('I', 'saving', 'all vehicles saved')
|
||||||
@ -154,43 +117,17 @@ local function SaveVehicle(inventoryId)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function FinishedLoading(inventoryId)
|
local function LoadVehicle(inventoryId)
|
||||||
M.SetFade(false)
|
|
||||||
local veh = be:getObjectByID(career_modules_inventory.getVehicleIdFromInventoryId(inventoryId))
|
|
||||||
local pos, _ = freeroam_facilities.getGaragePosRot(career_modules_inventory.getClosestGarage(), veh)
|
|
||||||
career_modules_playerDriving.showPosition(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function LoadVehicle(inventoryId, loadDamaged)
|
|
||||||
local saveFile = GetVehicleSaveFile(vehicleSaves_temp, inventoryId)
|
local saveFile = GetVehicleSaveFile(vehicleSaves_temp, inventoryId)
|
||||||
|
|
||||||
local vehicleId = career_modules_inventory.getVehicleIdFromInventoryId(inventoryId)
|
local vehicleId = career_modules_inventory.getVehicleIdFromInventoryId(inventoryId)
|
||||||
if vehicleId then
|
if vehicleId then
|
||||||
log("I", "loading", "loading vehicle from " .. saveFile)
|
log("I", "loading", "loading vehicle from " .. saveFile)
|
||||||
if loadDamaged then
|
local object = be:getObjectByID(vehicleId)
|
||||||
local object = be:getObjectByID(vehicleId)
|
object:queueLuaCommand("beamstate.load(\"" ..
|
||||||
object:queueLuaCommand(
|
saveFile .. "\");" ..
|
||||||
"beamstate.load(\"" .. saveFile .. "\"); " ..
|
"for key, value in pairs(v.data.controller) do if value['fileName'] == 'advancedCouplerControl' then local c = controller.getController(value['name']) if c['reset'] then c['reset']() end end end"
|
||||||
"for key, value in pairs(v.data.controller) do " ..
|
)
|
||||||
" if value['fileName'] == 'advancedCouplerControl' then " ..
|
|
||||||
" local c = controller.getController(value['name']) " ..
|
|
||||||
" if c['reset'] then " ..
|
|
||||||
" c['reset']() " ..
|
|
||||||
" end " ..
|
|
||||||
" end " ..
|
|
||||||
" end; " ..
|
|
||||||
" obj:queueGameEngineLua(' " ..
|
|
||||||
" career_vehicleSaveSystem.TeleportVehicle( " ..
|
|
||||||
" " .. inventoryId .. ", " ..
|
|
||||||
" true, " ..
|
|
||||||
" function() " ..
|
|
||||||
" career_vehicleSaveSystem.FinishedLoading(" .. inventoryId .. ")" ..
|
|
||||||
" end) " ..
|
|
||||||
" ');"
|
|
||||||
)
|
|
||||||
else
|
|
||||||
FinishedLoading(inventoryId)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -230,11 +167,6 @@ M.queuedVehicleSaves = {}
|
|||||||
|
|
||||||
M.SaveVehicle = SaveVehicle
|
M.SaveVehicle = SaveVehicle
|
||||||
M.LoadVehicle = LoadVehicle
|
M.LoadVehicle = LoadVehicle
|
||||||
M.FinishedLoading = FinishedLoading
|
|
||||||
|
|
||||||
M.TeleportVehicle = TeleportVehicle
|
|
||||||
|
|
||||||
M.SetFade = SetFade
|
|
||||||
|
|
||||||
M.CheckSavedAsync = CheckSavedAsync
|
M.CheckSavedAsync = CheckSavedAsync
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user