Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d245d00706 | |||
| 17d90c2699 | |||
| 5929cdff5f | |||
| 5eaf701f91 | |||
| 11cad0c721 | |||
| 014cc7dc20 |
@@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.dependencies = { 'career_modules_inventory', 'freeroam_facilities', "career_vehicleSaveSystem" }
|
M.dependencies = { 'career_modules_inventory', 'freeroam_facilities', "career_vehicleSaveSystem",
|
||||||
|
"career_modules_permissions", 'career_modules_valueCalculator' }
|
||||||
|
|
||||||
local career_modules_inventory_removeVehicleObject
|
local career_modules_inventory_removeVehicleObject
|
||||||
local vehicleObjectsToRemove = {}
|
local vehicleObjectsToRemove = {}
|
||||||
@@ -28,31 +29,54 @@ local function spawnVehicle(inventoryId, callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Retrieve()
|
local function Retrieve(inventoryId)
|
||||||
local fav_veh_id = career_modules_inventory.getFavoriteVehicle()
|
career_vehicleSaveSystem.EnqueueVehicleToSave(inventoryId)
|
||||||
|
if not career_vehicleSaveSystem.SaveVehicle(inventoryId) then
|
||||||
|
career_vehicleSaveSystem.DequeueVehicleToSave(inventoryId)
|
||||||
|
end
|
||||||
|
|
||||||
extensions.core_jobsystem.create(
|
local vehicleValue = career_modules_valueCalculator.getInventoryVehicleValue(inventoryId, true)
|
||||||
function(job)
|
local currentVehicleValue = career_modules_valueCalculator.getInventoryVehicleValue(inventoryId)
|
||||||
spawnVehicle(fav_veh_id, function()
|
|
||||||
local veh = be:getObjectByID(career_modules_inventory.getVehicleIdFromInventoryId(fav_veh_id))
|
career_vehicleSaveSystem.CheckSavedAsync(function()
|
||||||
local location = { pos = veh:getPosition(), rot = quat(0, 0, 1, 0) * quat(veh:getRefNodeRotation()) }
|
extensions.core_jobsystem.create(
|
||||||
local garage = career_modules_inventory.getClosestGarage(location.pos)
|
function(job)
|
||||||
job.sleep(1)
|
spawnVehicle(inventoryId, function()
|
||||||
career_vehicleSaveSystem.LoadVehicle(fav_veh_id)
|
local veh = be:getObjectByID(career_modules_inventory.getVehicleIdFromInventoryId(inventoryId))
|
||||||
freeroam_facilities.teleportToGarage(garage.id, veh, false)
|
local location = { pos = veh:getPosition(), rot = quat(0, 0, 1, 0) * quat(veh:getRefNodeRotation()) }
|
||||||
end)
|
local garage = career_modules_inventory.getClosestGarage(location.pos)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
local function onComputerAddFunctions(menuData, computerFunctions)
|
local function onComputerAddFunctions(menuData, computerFunctions)
|
||||||
if menuData.computerFacility.functions["vehicleInventory"] then
|
if menuData.computerFacility.functions["vehicleInventory"] then
|
||||||
|
local favouriteVehicleId = career_modules_inventory.getFavoriteVehicle()
|
||||||
|
|
||||||
local computerFunctionData = {
|
local computerFunctionData = {
|
||||||
id = "retrieve_damaged",
|
id = "retrieve_damaged",
|
||||||
label = "Retrieve Favourite Damaged",
|
label = "Retrieve Favourite Damaged",
|
||||||
callback = Retrieve,
|
callback = function() Retrieve(favouriteVehicleId) end,
|
||||||
order = 1
|
order = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local repairPermission = career_modules_permissions.getStatusForTag("vehicleRepair",
|
||||||
|
{ inventoryId = favouriteVehicleId })
|
||||||
|
|
||||||
|
if not repairPermission["allow"] then
|
||||||
|
computerFunctionData.disabled = true
|
||||||
|
computerFunctionData.reason = { type = "text", label = "Vehicle is being repaired." }
|
||||||
|
end
|
||||||
|
|
||||||
if menuData.tutorialPartShoppingActive or menuData.tutorialTuningActive then
|
if menuData.tutorialPartShoppingActive or menuData.tutorialTuningActive then
|
||||||
computerFunctionData.disabled = true
|
computerFunctionData.disabled = true
|
||||||
computerFunctionData.reason = career_modules_computer.reasons.tutorialActive
|
computerFunctionData.reason = career_modules_computer.reasons.tutorialActive
|
||||||
@@ -63,7 +87,7 @@ end
|
|||||||
|
|
||||||
local function RemoveVehicleObject(inventoryId)
|
local function RemoveVehicleObject(inventoryId)
|
||||||
table.insert(vehicleObjectsToRemove, inventoryId)
|
table.insert(vehicleObjectsToRemove, inventoryId)
|
||||||
career_vehicleSaveSystem.QueueVehicleToSave(inventoryId)
|
career_vehicleSaveSystem.EnqueueVehicleToSave(inventoryId)
|
||||||
career_vehicleSaveSystem.SaveVehicle(inventoryId)
|
career_vehicleSaveSystem.SaveVehicle(inventoryId)
|
||||||
career_vehicleSaveSystem.CheckSavedAsync(function()
|
career_vehicleSaveSystem.CheckSavedAsync(function()
|
||||||
career_modules_inventory_removeVehicleObject(inventoryId)
|
career_modules_inventory_removeVehicleObject(inventoryId)
|
||||||
|
|||||||
@@ -65,13 +65,14 @@ local function GetVehicleSaveFile(root, inventoryId)
|
|||||||
return path .. "/save.json"
|
return path .. "/save.json"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function QueueVehicleToSave(inventoryId)
|
local function EnqueueVehicleToSave(inventoryId)
|
||||||
|
log("I", "saving", "enqueued vehicle " .. inventoryId)
|
||||||
M.queuedVehicleSaves[inventoryId] = true
|
M.queuedVehicleSaves[inventoryId] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function QueuedVehicleSaved(inventoryId)
|
local function DequeueVehicleToSave(inventoryId)
|
||||||
log("I", "saving", "saved vehicle " .. inventoryId)
|
log("I", "saving", "dequeued vehicle " .. inventoryId)
|
||||||
table.remove(M.queuedVehicleSaves, inventoryId)
|
M.queuedVehicleSaves[inventoryId] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function VehiclesSaved()
|
local function VehiclesSaved()
|
||||||
@@ -108,9 +109,10 @@ local function SaveVehicle(inventoryId)
|
|||||||
local object = be:getObjectByID(vehicleId)
|
local object = be:getObjectByID(vehicleId)
|
||||||
object:queueLuaCommand("beamstate.save(\"" ..
|
object:queueLuaCommand("beamstate.save(\"" ..
|
||||||
saveFile ..
|
saveFile ..
|
||||||
"\"); obj:queueGameEngineLua('career_vehicleSaveSystem.QueuedVehicleSaved(\"" .. inventoryId .. "\")');")
|
"\"); obj:queueGameEngineLua('career_vehicleSaveSystem.DequeueVehicleToSave(" .. inventoryId .. ")');")
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
log('I', 'saving', 'vehicle ' .. inventoryId .. " not spawned")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -137,12 +139,12 @@ local function onSaveCurrentSaveSlot(currentSavePath, oldSaveDate, vehiclesThumb
|
|||||||
local vehicles = career_modules_inventory.getVehicles()
|
local vehicles = career_modules_inventory.getVehicles()
|
||||||
|
|
||||||
for id, _ in pairs(vehicles) do
|
for id, _ in pairs(vehicles) do
|
||||||
QueueVehicleToSave(id)
|
EnqueueVehicleToSave(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
for id, _ in pairs(M.queuedVehicleSaves) do
|
for id, _ in pairs(M.queuedVehicleSaves) do
|
||||||
if not SaveVehicle(id) then
|
if not SaveVehicle(id) then
|
||||||
QueuedVehicleSaved(id)
|
DequeueVehicleToSave(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
CheckSavedAsync(function()
|
CheckSavedAsync(function()
|
||||||
@@ -168,8 +170,8 @@ M.LoadVehicle = LoadVehicle
|
|||||||
|
|
||||||
M.CheckSavedAsync = CheckSavedAsync
|
M.CheckSavedAsync = CheckSavedAsync
|
||||||
|
|
||||||
M.QueueVehicleToSave = QueueVehicleToSave
|
M.EnqueueVehicleToSave = EnqueueVehicleToSave
|
||||||
M.QueuedVehicleSaved = QueuedVehicleSaved
|
M.DequeueVehicleToSave = DequeueVehicleToSave
|
||||||
|
|
||||||
M.onSaveCurrentSaveSlotAsyncStart = onSaveCurrentSaveSlotAsyncStart
|
M.onSaveCurrentSaveSlotAsyncStart = onSaveCurrentSaveSlotAsyncStart
|
||||||
M.onSaveCurrentSaveSlot = onSaveCurrentSaveSlot
|
M.onSaveCurrentSaveSlot = onSaveCurrentSaveSlot
|
||||||
|
|||||||
Reference in New Issue
Block a user