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
|
|
|
|
for k, 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
|
|
|
|
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 = {
|
|
|
|
['cargo-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
|
|
|
['artillery-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
|
|
|
['fluid-wagon'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}},
|
|
|
|
['locomotive'] = {left_top = {x = -30, y = 0}, right_bottom = {x = 30, y = 80}}
|
|
|
|
}
|
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
|
|
|
|
|
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
|