99
1010local SGSL = require (" includes.services.SGSL" )
1111local Warehouse = require (" includes.modules.businesses.Warehouse" )
12- local BikerBusiness = require (" includes.modules.businesses.BikerBusiness " )
12+ local Factory = require (" SSV2. includes.modules.businesses.Factory " )
1313local Nightclub = require (" includes.modules.businesses.Nightclub" )
1414local Clubhouse = require (" includes.modules.businesses.Clubhouse" )
1515local CashSafe = require (" includes.modules.businesses.CashSafe" )
@@ -59,8 +59,8 @@ Enums.eYRState = {
5959--- @field safes array<CashSafe>
6060--- @field clubhouse ? Clubhouse
6161--- @field hangar ? Warehouse
62- --- @field bunker ? BikerBusiness
63- --- @field acid_lab ? BikerBusiness
62+ --- @field bunker ? Factory
63+ --- @field acid_lab ? Factory
6464--- @field nightclub ? Nightclub
6565--- @field car_wash ? CarWash
6666--- @field salvage_yard ? SalvageYard
@@ -75,8 +75,9 @@ Enums.eYRState = {
7575--- @field private m_sell_script_disp_name string
7676--- @field private m_raw_data RawBusinessData
7777--- @field private m_businesses YRV3Businesses
78- --- @field private m_last_as_check_time milliseconds
78+ --- @field private m_last_autosell_check_time milliseconds
7979--- @field private m_last_income_check_time milliseconds
80+ --- @field private m_last_business_update_time milliseconds
8081--- @field private m_cooldown_state_dirty boolean
8182--- @field private m_initial_data_done boolean
8283--- @field private m_data_initialized boolean
@@ -92,20 +93,21 @@ function YRV3:init()
9293 return self
9394 end
9495
95- self .m_total_sum = 0
96- self .m_bhub_script_handle = 0
97- self .m_last_as_check_time = 0
98- self .m_last_income_check_time = 0
99- self .m_state = Enums .eYRState .OFFLINE
100- self .m_has_triggered_autosell = false
101- self .m_sell_script_running = false
102- self .m_initial_data_done = false
103- self .m_data_initialized = false
104- self .m_cooldown_state_dirty = true
105- self .m_sell_script_name = nil
106- self .m_sell_script_disp_name = " None"
107- self .m_last_error = " "
108- self .m_businesses = {
96+ self .m_total_sum = 0
97+ self .m_bhub_script_handle = 0
98+ self .m_last_autosell_check_time = 0
99+ self .m_last_income_check_time = 0
100+ self .m_last_business_update_time = 0
101+ self .m_state = Enums .eYRState .OFFLINE
102+ self .m_has_triggered_autosell = false
103+ self .m_sell_script_running = false
104+ self .m_initial_data_done = false
105+ self .m_data_initialized = false
106+ self .m_cooldown_state_dirty = true
107+ self .m_sell_script_name = nil
108+ self .m_sell_script_disp_name = " None"
109+ self .m_last_error = " "
110+ self .m_businesses = {
109111 warehouses = {},
110112 safes = {},
111113 }
@@ -131,18 +133,19 @@ function YRV3:init()
131133end
132134
133135function YRV3 :Reset ()
134- self .m_total_sum = 0
135- self .m_last_as_check_time = 0
136- self .m_last_income_check_time = 0
137- self .m_businesses = {
136+ self .m_total_sum = 0
137+ self .m_last_autosell_check_time = 0
138+ self .m_last_income_check_time = 0
139+ self .m_last_business_update_time = 0
140+ self .m_businesses = {
138141 warehouses = {},
139142 safes = {},
140143 }
141- self .m_has_triggered_autosell = false
142- self .m_sell_script_running = false
143- self .m_initial_data_done = false
144- self .m_data_initialized = false
145- self .m_cooldown_state_dirty = true
144+ self .m_has_triggered_autosell = false
145+ self .m_sell_script_running = false
146+ self .m_initial_data_done = false
147+ self .m_data_initialized = false
148+ self .m_cooldown_state_dirty = true
146149end
147150
148151function YRV3 :Reload ()
@@ -235,12 +238,12 @@ function YRV3:GetCarWash()
235238 return self .m_businesses .car_wash
236239end
237240
238- --- @return BikerBusiness ?
241+ --- @return Factory ?
239242function YRV3 :GetBunker ()
240243 return self .m_businesses .bunker
241244end
242245
243- --- @return BikerBusiness ?
246+ --- @return Factory ?
244247function YRV3 :GetAcidLab ()
245248 return self .m_businesses .acid_lab
246249end
@@ -343,7 +346,7 @@ function YRV3:PopulateBikerBusinesses()
343346 local eq_upg_mult = tunables .get_int (" GR_MANU_PRODUCT_VALUE_EQUIPMENT_UPGRADE" )
344347 local stf_upg_mult = tunables .get_int (" GR_MANU_PRODUCT_VALUE_STAFF_UPGRADE" )
345348
346- self .m_businesses .bunker = BikerBusiness .new ({
349+ self .m_businesses .bunker = Factory .new ({
347350 id = 5 ,
348351 name = Game .GetGXTLabel (_F (" MP_BUNKER_%d" , gxt_idx )),
349352 coords = ref and ref .coords or vec3 :zero (),
@@ -360,7 +363,7 @@ function YRV3:PopulateBikerBusinesses()
360363 and (stats .get_int (" MPX_XM22_LAB_EQUIP_UPGRADED" ) == 1 )
361364 local eq_upg_mult = tunables .get_int (" BIKER_ACID_PRODUCT_VALUE_EQUIPMENT_UPGRADE" )
362365
363- self .m_businesses .acid_lab = BikerBusiness .new ({
366+ self .m_businesses .acid_lab = Factory .new ({
364367 id = 6 ,
365368 name = Game .GetGXTLabel (" MP_BWH_ACID" ),
366369 vpu_mult_1 = has_eq_upgrade and eq_upg_mult or 0 ,
@@ -554,27 +557,6 @@ function YRV3:InitializeData()
554557 self :PopulateNightclub ()
555558end
556559
557- function YRV3 :WarehouseAutofill ()
558- if (not self :CanAccess ()) then
559- return
560- end
561-
562- for _ , wh in ipairs (self .m_businesses .warehouses ) do
563- wh :AutoFill ()
564- end
565- end
566-
567- function YRV3 :HangarAutofill ()
568- if (not self :CanAccess ()) then
569- return
570- end
571-
572- local hangar = self .m_businesses .hangar
573- if (hangar and hangar :IsValid ()) then
574- self .m_businesses .hangar :AutoFill ()
575- end
576- end
577-
578560function YRV3 :FinishSaleOnCommand ()
579561 if (not self :CanAccess ()) then
580562 return
809791local fadedOutTimer = Timer .new (1e4 )
810792fadedOutTimer :pause ()
811793function YRV3 :SetupAutosell ()
812- if (Time .millis () - self .m_last_as_check_time < 1200 ) then
794+ if (Time .millis () - self .m_last_autosell_check_time < 1200 ) then
813795 return
814796 end
815797
@@ -858,7 +840,7 @@ function YRV3:SetupAutosell()
858840 fadedOutTimer :pause ()
859841 end
860842
861- self .m_last_as_check_time = Time .millis ()
843+ self .m_last_autosell_check_time = Time .millis ()
862844end
863845
864846function YRV3 :AutoSellHandler ()
@@ -927,46 +909,33 @@ function YRV3:MCT()
927909 end )
928910end
929911
930- function YRV3 :AutoProduceHandler ()
931- for _ , bb in ipairs (self .m_businesses .clubhouse :GetSubBusinesses ()) do
932- if (bb .fast_prod_enabled and not bb .fast_prod_running ) then
933- bb :LoopProduction ()
934- end
935- end
936-
937- local bunker = self .m_businesses .bunker
938- if (bunker and bunker :IsValid ()) then
939- if (bunker .fast_prod_enabled and not bunker .fast_prod_running ) then
940- bunker :LoopProduction ()
941- end
942- end
943-
944- local acidlab = self .m_businesses .acid_lab
945- if (acidlab and acidlab :IsValid ()) then
946- if (acidlab .fast_prod_enabled and not acidlab .fast_prod_running ) then
947- acidlab :LoopProduction ()
948- end
949- end
950-
951- if (not self .m_businesses .nightclub ) then
912+ function YRV3 :UpdateBusinesses ()
913+ if (not self :CanAccess ()) then
952914 return
953915 end
954916
955- local hubs = self .m_businesses .nightclub :GetSubBusinesses ()
956- if (not hubs ) then
917+ if (Time .millis () - self .m_last_business_update_time < 500 ) then
957918 return
958919 end
959920
960- for _ , hub in ipairs ( hubs ) do
961- if (hub . fast_prod_enabled and not hub . fast_prod_running ) then
962- hub : LoopProduction ()
921+ for key , business in pairs ( self . m_businesses ) do
922+ if (key == " safes " or key == " salvage_yard " or key == " car_wash " ) then
923+ goto continue
963924 end
925+
926+ if (key == " warehouses" ) then
927+ for _ , wh in ipairs (business ) do
928+ if (type (wh .Update ) == " function" ) then
929+ wh :Update ()
930+ end
931+ end
932+ elseif (type (business .Update ) == " function" ) then
933+ business :Update ()
934+ end
935+ :: continue::
964936 end
965- end
966937
967- function YRV3 :AutoFillHandler ()
968- self :HangarAutofill ()
969- self :WarehouseAutofill ()
938+ self .m_last_business_update_time = Time .millis ()
970939end
971940
972941--- @param business BusinessBase | BasicBusiness
@@ -1046,11 +1015,11 @@ function YRV3:OnTick()
10461015 self .m_state = Enums .eYRState .RUNNING
10471016 self :SetLastError (" " )
10481017
1018+ self :UpdateBusinesses ()
1019+ self :CalculateEstimatedIncome ()
1020+
10491021 self :AutoSellHandler ()
1050- self :AutoFillHandler ()
1051- self :AutoProduceHandler ()
10521022 self :CooldownHandler ()
1053- self :CalculateEstimatedIncome ()
10541023end
10551024
10561025return YRV3
0 commit comments