78 lines
2.7 KiB
Text
78 lines
2.7 KiB
Text
--'******************************************************
|
|
--'* Áèíäåð îáúåêòà êîñòðà .
|
|
--'******************************************************
|
|
campfire_table_by_smart_names = {}
|
|
function bind(obj)
|
|
obj:bind_object(campfire_binder(obj))
|
|
end
|
|
|
|
class "campfire_binder" (object_binder)
|
|
function campfire_binder:__init(obj) super(obj)
|
|
self.campfire = obj:get_campfire()
|
|
end
|
|
function campfire_binder:net_spawn(server_object)
|
|
if not object_binder.net_spawn(self, server_object) then
|
|
return false
|
|
end
|
|
local smart_name = string.gsub(self.object:name(), "_campfire_%d*", "")
|
|
if sim_board.get_sim_board().smarts_by_names[smart_name] then
|
|
self.campfire:turn_off()
|
|
if campfire_table_by_smart_names[smart_name] == nil then
|
|
campfire_table_by_smart_names[smart_name] = {}
|
|
end
|
|
campfire_table_by_smart_names[smart_name][self.object:id()] = self.campfire
|
|
end
|
|
return true
|
|
end
|
|
function campfire_binder:update(delta)
|
|
object_binder.update(self, delta)
|
|
--[[ printf("campfire_update!!!")
|
|
local kamp = xr_kamp.kamps[string.gsub(self.object:name(), "_campfire", "")]
|
|
if kamp ~= nil and kamp.population > 0 then
|
|
if self.campfire:is_on() then
|
|
if (level.get_time_hours() >= 4 and level.get_time_hours() < 21) and level.get_time_minutes() >= campfire_timeout[self.object:name()] then
|
|
printf("turning off campfire %s %s %s",tostring(level.get_time_hours() >= 6 and level.get_time_hours() < 21),tostring(self.population),tostring(campfire:is_on()))
|
|
self.campfire:turn_off()
|
|
printf("turning off campfire %s %s %s",tostring(level.get_time_hours() >= 6 and level.get_time_hours() < 21),tostring(self.population),tostring(campfire:is_on()))
|
|
|
|
end
|
|
else
|
|
if (level.get_time_hours() < 4 or level.get_time_hours() >= 21) and level.get_time_minutes() >= campfire_timeout[self.object:name()] then
|
|
printf("turning on campfire %s %s %s",tostring(level.get_time_hours() >= 6 and level.get_time_hours() < 21),tostring(self.population),tostring(campfire:is_on()))
|
|
self.campfire:turn_on()
|
|
end
|
|
end
|
|
else
|
|
self.campfire:turn_off()
|
|
end ]]--
|
|
end
|
|
|
|
function turn_on_campfires_by_smart_name(smart_name)
|
|
local smart_campfires = campfire_table_by_smart_names[smart_name]
|
|
if smart_campfires ~= nil and not empty(smart_campfires) then
|
|
for k,v in pairs (smart_campfires) do
|
|
if not v:is_on() then
|
|
v:turn_on()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function turn_off_campfires_by_smart_name(smart_name)
|
|
local smart_campfires = campfire_table_by_smart_names[smart_name]
|
|
if smart_campfires ~= nil and not empty(smart_campfires) then
|
|
for k,v in pairs (smart_campfires) do
|
|
if v:is_on() then
|
|
v:turn_off()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|