2020-06-03 20:09:00 +02:00
|
|
|
local Global = require 'utils.global'
|
|
|
|
|
2020-07-08 22:57:43 +02:00
|
|
|
local this = {}
|
2020-06-03 20:09:00 +02:00
|
|
|
Global.register(
|
2020-07-08 22:57:43 +02:00
|
|
|
this,
|
2020-06-03 20:09:00 +02:00
|
|
|
function(tbl)
|
2020-07-08 22:57:43 +02:00
|
|
|
this = tbl
|
2020-06-03 20:09:00 +02:00
|
|
|
end
|
|
|
|
)
|
|
|
|
|
|
|
|
local Public = {}
|
|
|
|
|
|
|
|
function Public.reset()
|
2020-07-08 22:57:43 +02:00
|
|
|
if this.surfaces then
|
2022-10-25 23:29:40 +02:00
|
|
|
for _, surface in pairs(this.surfaces) do
|
2020-06-03 20:09:00 +02:00
|
|
|
if surface and surface.valid then
|
|
|
|
game.delete_surface(surface)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-07-08 22:57:43 +02:00
|
|
|
for k, _ in pairs(this) do
|
|
|
|
this[k] = nil
|
2020-06-03 20:09:00 +02:00
|
|
|
end
|
2020-07-08 22:57:43 +02:00
|
|
|
this.doors = {}
|
|
|
|
this.wagons = {}
|
2021-05-04 18:55:32 +02:00
|
|
|
this.speed = 0.1
|
2023-08-12 00:29:17 +02:00
|
|
|
this.final_battle = false
|
2021-05-04 18:55:32 +02:00
|
|
|
this.hazardous_debris = true
|
2020-12-02 09:20:35 +01:00
|
|
|
this.current_wagon_index = nil
|
2020-07-08 22:57:43 +02:00
|
|
|
this.trains = {}
|
|
|
|
this.players = {}
|
|
|
|
this.surfaces = {}
|
|
|
|
this.multiple_chests = true
|
|
|
|
this.wagon_types = {
|
|
|
|
['cargo-wagon'] = true,
|
|
|
|
['artillery-wagon'] = true,
|
|
|
|
['fluid-wagon'] = true,
|
|
|
|
['locomotive'] = true
|
|
|
|
}
|
|
|
|
|
2021-05-15 16:01:07 +02:00
|
|
|
this.wagon_areas = {
|
2023-09-05 00:03:55 +02:00
|
|
|
['cargo-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
|
|
|
['artillery-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
|
|
|
['fluid-wagon'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}},
|
|
|
|
['locomotive'] = {left_top = {x = -40, y = 0}, right_bottom = {x = 40, y = 100}}
|
2021-05-15 16:01:07 +02:00
|
|
|
}
|
2020-06-03 20:09:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Public.get(key)
|
|
|
|
if key then
|
2020-07-08 22:57:43 +02:00
|
|
|
return this[key]
|
2020-06-03 20:09:00 +02:00
|
|
|
else
|
2020-07-08 22:57:43 +02:00
|
|
|
return this
|
2020-06-03 20:09:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-12 00:29:17 +02:00
|
|
|
function Public.set(key, value)
|
|
|
|
if key and (value or value == false) then
|
|
|
|
this[key] = value
|
|
|
|
return this[key]
|
|
|
|
elseif key then
|
|
|
|
return this[key]
|
|
|
|
else
|
|
|
|
return this
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-08 22:57:43 +02:00
|
|
|
function Public.set_wagon_area(tbl)
|
2020-07-11 09:32:36 +02:00
|
|
|
if not tbl then
|
2020-07-08 22:57:43 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2020-07-11 09:32:36 +02:00
|
|
|
this.wagon_areas = tbl
|
2020-07-08 22:57:43 +02:00
|
|
|
end
|
|
|
|
|
2020-06-03 20:09:00 +02:00
|
|
|
return Public
|