mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-05 22:53:39 +02:00
Improved performance_scale
It now keeps track of applied modifiers and doesn't override modifiers given from third parties. It now works with diggy
This commit is contained in:
parent
76871eefbf
commit
5c6d7b32f5
@ -1,10 +1,33 @@
|
||||
local Command = require 'utils.command'
|
||||
local Ranks = require 'resources.ranks'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local format = string.format
|
||||
|
||||
local Performance = {}
|
||||
|
||||
local mining_efficiency = {
|
||||
active_modifier = 0,
|
||||
}
|
||||
|
||||
local craft_bonus = {
|
||||
active_modifier = 0,
|
||||
}
|
||||
|
||||
local running_bonus = {
|
||||
active_modifier = 0,
|
||||
}
|
||||
|
||||
Global.register({
|
||||
mining_efficiency = mining_efficiency,
|
||||
craft_bonus = craft_bonus,
|
||||
running_bonus = running_bonus
|
||||
}, function(tbl)
|
||||
mining_efficiency = tbl.mining_efficiency
|
||||
craft_bonus = tbl.craft_bonus
|
||||
running_bonus = tbl.running_bonus
|
||||
end)
|
||||
|
||||
---Sets the scale of performance.
|
||||
---1 means the game runs at normal game speed with normal walking speed
|
||||
---0.5 means the game runs at half speed, running speed is doubled
|
||||
@ -18,9 +41,12 @@ function Performance.set_time_scale(scale)
|
||||
|
||||
local stat_mod = Performance.get_player_stat_modifier()
|
||||
for _, force in pairs(game.forces) do
|
||||
force.character_running_speed_modifier = stat_mod - 1
|
||||
force.manual_mining_speed_modifier = stat_mod - 1
|
||||
force.manual_crafting_speed_modifier = stat_mod - 1
|
||||
force.character_running_speed_modifier = force.character_running_speed_modifier - running_bonus.active_modifier + stat_mod - 1
|
||||
running_bonus.active_modifier = stat_mod - 1
|
||||
force.manual_mining_speed_modifier = force.manual_mining_speed_modifier - mining_efficiency.active_modifier + stat_mod - 1
|
||||
mining_efficiency.active_modifier = stat_mod - 1
|
||||
force.manual_crafting_speed_modifier = force.manual_crafting_speed_modifier - craft_bonus.active_modifier + stat_mod - 1
|
||||
craft_bonus.active_modifier = stat_mod - 1
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user