2013-04-21 06:21:53 -06:00
|
|
|
class AutoUnsuspend
|
2014-02-27 09:38:34 -07:00
|
|
|
attr_accessor :running
|
2013-04-21 06:21:53 -06:00
|
|
|
|
2014-02-27 09:38:34 -07:00
|
|
|
def process
|
|
|
|
count = 0
|
|
|
|
df.world.job_list.each { |job|
|
|
|
|
if job.job_type == :ConstructBuilding and job.flags.suspend and df.map_tile_at(job).designation.flow_size <= 1
|
|
|
|
job.flags.suspend = false
|
|
|
|
count += 1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
if count > 0
|
|
|
|
puts "Unsuspended #{count} job(s)."
|
|
|
|
df.process_jobs = true
|
|
|
|
end
|
|
|
|
end
|
2013-04-21 06:21:53 -06:00
|
|
|
|
2014-02-27 09:38:34 -07:00
|
|
|
def start
|
|
|
|
@running = true
|
|
|
|
@onupdate = df.onupdate_register('autounsuspend', 5) { process if @running }
|
|
|
|
end
|
2013-04-21 06:21:53 -06:00
|
|
|
|
2014-02-27 09:38:34 -07:00
|
|
|
def stop
|
|
|
|
@running = false
|
|
|
|
df.onupdate_unregister(@onupdate)
|
|
|
|
end
|
|
|
|
end
|
2013-04-21 06:21:53 -06:00
|
|
|
|
|
|
|
case $script_args[0]
|
|
|
|
when 'start'
|
2014-02-27 09:38:34 -07:00
|
|
|
$AutoUnsuspend ||= AutoUnsuspend.new
|
2013-04-21 06:21:53 -06:00
|
|
|
$AutoUnsuspend.start
|
|
|
|
|
|
|
|
when 'end', 'stop'
|
|
|
|
$AutoUnsuspend.stop
|
2014-02-27 09:38:34 -07:00
|
|
|
|
2013-04-21 06:21:53 -06:00
|
|
|
else
|
2014-02-27 09:38:34 -07:00
|
|
|
puts $AutoUnsuspend && $AutoUnsuspend.running ? 'Running.' : 'Stopped.'
|
2013-04-21 06:21:53 -06:00
|
|
|
end
|