ScenarioController(SimulatorAPI sim, ClockController c, Scenario s, ImmutableMap<Class<? extends TimedEvent>, TimedEventHandler<?>> m, int t) { simulator = sim; clock = c; ticks = t; scenario = s; scenarioQueue = scenario.asQueue(); handlers = m; disp = new EventDispatcher(EventType.values()); final ScenarioController sc = this; clock.getEventAPI().addListener(new Listener() { @Override public void handleEvent(Event e) { if (clock.getCurrentTime() == 0) { dispatchSetupEvents(); } if (sc.endOfScenario) { clock.stop(); } } }, Clock.ClockEventType.STARTED); }
ScenarioController(SimulatorAPI sim, ClockController c, Scenario s, ImmutableMap<Class<? extends TimedEvent>, TimedEventHandler<?>> m, int t) { simulator = sim; clock = c; ticks = t; scenario = s; scenarioQueue = scenario.asQueue(); handlers = m; disp = new EventDispatcher(EventType.values()); final ScenarioController sc = this; clock.getEventAPI().addListener(new Listener() { @Override public void handleEvent(Event e) { if (clock.getCurrentTime() == 0) { dispatchSetupEvents(); } if (sc.endOfScenario) { clock.stop(); } } }, Clock.ClockEventType.STARTED); }
.build(); assertThat(scenario.asQueue()).isEqualTo(scenario.getEvents());