2019-10-28 18:38:36 +02:00
|
|
|
local Global = require 'utils.global'
|
|
|
|
local Event = require 'utils.event'
|
|
|
|
|
|
|
|
local wave_defense = {}
|
|
|
|
local Public = {}
|
|
|
|
|
|
|
|
Global.register(
|
|
|
|
wave_defense,
|
|
|
|
function(tbl)
|
|
|
|
wave_defense = tbl
|
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
function Public.reset_wave_defense()
|
2020-06-07 13:33:24 +02:00
|
|
|
wave_defense.boss_wave = false
|
|
|
|
wave_defense.boss_wave_warning = false
|
|
|
|
wave_defense.side_target_count = 0
|
2019-11-09 16:46:18 +02:00
|
|
|
wave_defense.active_biters = {}
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.active_biter_count = 0
|
|
|
|
wave_defense.active_biter_threat = 0
|
2019-11-09 16:46:18 +02:00
|
|
|
wave_defense.average_unit_group_size = 168
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.biter_raffle = {}
|
|
|
|
wave_defense.debug = false
|
|
|
|
wave_defense.game_lost = false
|
|
|
|
wave_defense.get_random_close_spawner_attempts = 5
|
|
|
|
wave_defense.group_size = 2
|
|
|
|
wave_defense.last_wave = game.tick
|
2019-10-29 12:26:59 +02:00
|
|
|
wave_defense.max_active_biters = 1280
|
|
|
|
wave_defense.max_active_unit_groups = 8
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.max_biter_age = 3600 * 60
|
2019-10-29 13:40:51 +02:00
|
|
|
wave_defense.nest_building_density = 48
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.next_wave = game.tick + 3600 * 15
|
|
|
|
wave_defense.side_targets = {}
|
2019-10-29 12:26:59 +02:00
|
|
|
wave_defense.simple_entity_shredding_cost_modifier = 0.005
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.spawn_position = {x = 0, y = 64}
|
|
|
|
wave_defense.spitter_raffle = {}
|
|
|
|
wave_defense.surface_index = 1
|
|
|
|
wave_defense.target = nil
|
|
|
|
wave_defense.threat = 0
|
2019-10-29 12:26:59 +02:00
|
|
|
wave_defense.threat_gain_multiplier = 2
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.threat_log = {}
|
|
|
|
wave_defense.threat_log_index = 0
|
2019-11-09 16:46:18 +02:00
|
|
|
wave_defense.unit_groups = {}
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.unit_group_command_delay = 3600 * 15
|
2020-04-08 20:28:02 +02:00
|
|
|
wave_defense.unit_group_command_step_length = 20
|
2019-10-28 18:38:36 +02:00
|
|
|
wave_defense.unit_group_last_command = {}
|
|
|
|
wave_defense.wave_interval = 3600
|
|
|
|
wave_defense.wave_number = 0
|
|
|
|
wave_defense.worm_building_chance = 3
|
|
|
|
wave_defense.worm_building_density = 16
|
|
|
|
wave_defense.worm_raffle = {}
|
2020-06-07 13:33:24 +02:00
|
|
|
wave_defense.clear_corpses = false
|
|
|
|
wave_defense.alert_boss_wave = false
|
2019-10-28 18:38:36 +02:00
|
|
|
end
|
|
|
|
|
2020-07-24 17:33:28 +02:00
|
|
|
function Public.get(key)
|
|
|
|
if key then
|
|
|
|
return wave_defense[key]
|
|
|
|
else
|
|
|
|
return wave_defense
|
|
|
|
end
|
2019-10-28 18:38:36 +02:00
|
|
|
end
|
|
|
|
|
2020-07-24 17:33:28 +02:00
|
|
|
function Public.set(key)
|
|
|
|
if key then
|
|
|
|
return wave_defense[key]
|
|
|
|
else
|
|
|
|
return wave_defense
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Public.get_table = Public.get
|
|
|
|
|
2020-06-07 13:33:24 +02:00
|
|
|
function Public.clear_corpses(value)
|
|
|
|
if value then
|
|
|
|
wave_defense.clear_corpses = value
|
|
|
|
end
|
2020-06-24 15:41:44 +02:00
|
|
|
return wave_defense.clear_corpses
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.get_wave()
|
|
|
|
return wave_defense.wave_number
|
2020-06-07 13:33:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Public.alert_boss_wave(value)
|
|
|
|
if value then
|
|
|
|
wave_defense.alert_boss_wave = value
|
|
|
|
end
|
2020-06-24 15:41:44 +02:00
|
|
|
return wave_defense.alert_boss_wave
|
2020-06-07 13:33:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local on_init = function()
|
2019-10-28 18:38:36 +02:00
|
|
|
Public.reset_wave_defense()
|
|
|
|
end
|
|
|
|
|
|
|
|
Event.on_init(on_init)
|
|
|
|
|
|
|
|
return Public
|