local state_nowhere = 0
local state_inside = 1
local state_outside = 2
------------------------------
class "nowy_restryktor"
------------------------------
function nowy_restryktor:__init(obj, storage )
self.object = obj
self.st = storage
end
function nowy_restryktor:reset_scheme()
self.state = state_nowhere
end
function nowy_restryktor:update(delta)
local actor = db.actor
if xr_logic.try_switch_to_another_section(self.object, self.st, actor) then
return false
end
-- Różnicowanie stanu w zależności od tego czy aktor jest wewnątrz restryktora czy przed chwilą go opuścił
local state = self.state
-- Jeśli aktor wkracza w restryktor
if state == state_outside or state == state_nowhere then
if self.object:inside(actor:center()) then
self:zone_enter()
end
end
-- Jeśli aktor opuszcza restryktor
if state == state_inside or state == state_nowhere then
if not self.object:inside(actor:center()) then
self:zone_leave()
end
end
end
-- Funkcja wywoływana po wejściu w restryktor
function nowy_restryktor:zone_enter()
self.state = state_inside
end
-- Funkcja wywoływana po opuszczeniu restryktora
function nowy_restryktor:zone_leave()
self.state = state_outside
end
function add_to_binder(npc, ini, scheme, section, storage)
local new_action = nowy_restryktor(npc, storage)
end
-- Funkcja dodająca schemat
function set_scheme(npc, ini, scheme, section, gulag_name)
local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section)
st.logic = xr_logic.cfg_get_switch_conditions(ini, section, npc)
end