1
0
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:
~iltar 2018-10-17 10:20:43 +02:00 committed by Valansch
parent 0b74795804
commit a1f89dc6ea
2 changed files with 21 additions and 10 deletions

View File

@ -6,13 +6,20 @@
-- dependencies
local Global = require 'utils.global'
local random = math.random
local round = math.round
-- this
local AlienEvolutionProgress = {}
local alien_cache = {
biters = {},
spitters = {},
biters = {
evolution = -1,
cache = {},
},
spitters = {
evolution = -1,
cache = {},
},
}
Global.register({
@ -96,23 +103,25 @@ local function get_name_by_random(collection)
end
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
alien_cache.biters[evolution_cache_key] = get_values(biters, evolution)
if (alien_cache.biters.evolution < evolution_value) then
alien_cache.biters.evolution = evolution_value
alien_cache.biters.cache = get_values(biters, evolution)
end
return alien_cache.biters[evolution_cache_key]
return alien_cache.biters.cache
end
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
alien_cache.spitters[evolution_cache_key] = get_values(spitters, evolution)
if (alien_cache.spitters.evolution < evolution_value) then
alien_cache.spitters.evolution = evolution_value
alien_cache.spitters.cache = get_values(spitters, evolution)
end
return alien_cache.spitters[evolution_cache_key]
return alien_cache.spitters.cache
end
function AlienEvolutionProgress.getBitersByEvolution(total_biters, evolution)

View File

@ -38,6 +38,8 @@ function AlienSpawner.register(config)
local alien_minimum_distance_square = config.alien_minimum_distance ^ 2
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 y = event.old_tile.position.y