Пример #1
0
func (m *Machine) Event(time float64) (hps.IEvent, bool) {
	var event hps.IEvent = nil

	for _, mm := range m.machines {
		if e, ok := mm.Event(time); ok && (event == nil || event.Time() > e.Time()) {
			event = e
		}
	}

	return event, event != nil
}
Пример #2
0
// Gets the next event from the environment machines.
func (e *Environment) Event(time float64) (hps.IEvent, bool) {
	var event hps.IEvent
	hasEvent := false

	for _, m := range e.machines {
		me, mhe := m.Event(time)

		if mhe && (event == nil || me.Time() < event.Time()) {
			event = me
			hasEvent = true
		}
	}

	return event, hasEvent
}