mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-14 10:13:13 +02:00
Reduced biter spawn cache footprint and digging increases evo (#241)
This commit is contained in:
parent
0b74795804
commit
a1f89dc6ea
@ -6,13 +6,20 @@
|
|||||||
-- dependencies
|
-- dependencies
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
local round = math.round
|
||||||
|
|
||||||
-- this
|
-- this
|
||||||
local AlienEvolutionProgress = {}
|
local AlienEvolutionProgress = {}
|
||||||
|
|
||||||
local alien_cache = {
|
local alien_cache = {
|
||||||
biters = {},
|
biters = {
|
||||||
spitters = {},
|
evolution = -1,
|
||||||
|
cache = {},
|
||||||
|
},
|
||||||
|
spitters = {
|
||||||
|
evolution = -1,
|
||||||
|
cache = {},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register({
|
Global.register({
|
||||||
@ -96,23 +103,25 @@ local function get_name_by_random(collection)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function AlienEvolutionProgress.getBiterValues(evolution)
|
function AlienEvolutionProgress.getBiterValues(evolution)
|
||||||
local evolution_cache_key = evolution * 100
|
local evolution_value = round(evolution * 100)
|
||||||
|
|
||||||
if (nil == alien_cache.biters[evolution_cache_key]) then
|
if (alien_cache.biters.evolution < evolution_value) then
|
||||||
alien_cache.biters[evolution_cache_key] = get_values(biters, evolution)
|
alien_cache.biters.evolution = evolution_value
|
||||||
|
alien_cache.biters.cache = get_values(biters, evolution)
|
||||||
end
|
end
|
||||||
|
|
||||||
return alien_cache.biters[evolution_cache_key]
|
return alien_cache.biters.cache
|
||||||
end
|
end
|
||||||
|
|
||||||
function AlienEvolutionProgress.getSpitterValues(evolution)
|
function AlienEvolutionProgress.getSpitterValues(evolution)
|
||||||
local evolution_cache_key = evolution * 100
|
local evolution_value = round(evolution * 100)
|
||||||
|
|
||||||
if (nil == alien_cache.spitters[evolution_cache_key]) then
|
if (alien_cache.spitters.evolution < evolution_value) then
|
||||||
alien_cache.spitters[evolution_cache_key] = get_values(spitters, evolution)
|
alien_cache.spitters.evolution = evolution_value
|
||||||
|
alien_cache.spitters.cache = get_values(spitters, evolution)
|
||||||
end
|
end
|
||||||
|
|
||||||
return alien_cache.spitters[evolution_cache_key]
|
return alien_cache.spitters.cache
|
||||||
end
|
end
|
||||||
|
|
||||||
function AlienEvolutionProgress.getBitersByEvolution(total_biters, evolution)
|
function AlienEvolutionProgress.getBitersByEvolution(total_biters, evolution)
|
||||||
|
@ -38,6 +38,8 @@ function AlienSpawner.register(config)
|
|||||||
local alien_minimum_distance_square = config.alien_minimum_distance ^ 2
|
local alien_minimum_distance_square = config.alien_minimum_distance ^ 2
|
||||||
|
|
||||||
Event.add(Template.events.on_void_removed, function(event)
|
Event.add(Template.events.on_void_removed, function(event)
|
||||||
|
game.forces.enemy.evolution_factor = game.forces.enemy.evolution_factor + 0.0000008
|
||||||
|
|
||||||
local x = event.old_tile.position.x
|
local x = event.old_tile.position.x
|
||||||
local y = event.old_tile.position.y
|
local y = event.old_tile.position.y
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user