Add a given amount of time and return all the events that were active during the delay.

Note that events that expired during the delay are marked has_expired and are still returned.

Property definitions

event_queue $ EventQueue :: update
	# Add a given amount of time and return all the events that were active during the delay.
	#
	# Note that events that expired during the delay are marked `has_expired` and are still returned.
	fun update(dt: Float): SequenceRead[EventInfo[E]]
	do
		var time = self.time
		time += dt
		self.time = time

		# Switch things
		var tmp = old_actives
		old_actives = actives
		actives = tmp

		# Discard dead events
		actives.clear
		for ei in old_actives do
			if not ei.has_expired then actives.add ei
		end

		# Start new events
		if time >= next then loop
			if queue.is_empty then
				next = inf
				break
			end
			var ei = queue.peek
			if ei.start > time then
				next = ei.start
				break
			end
			ei = queue.take
			if not ei.has_expired then
				actives.add ei
				ei.occurrences = 0
			end
		end

		if actives.is_empty then return actives

		# Update event information
		for ei in actives do ei.update(time, dt)

		return actives
	end
lib/event_queue/event_queue.nit:210,2--254,4