public void Update(UpdateType updateSource) { if (Active) { if (Context.Frame % 100 == 0 && Context.WCAPI == null) { Context.WCAPI = new WcPbApi(); if (!Context.WCAPI.Activate(Context.Program.Me)) { Context.WCAPI = null; } } while (GeneralListener.HasPendingMessage) { var msg = GeneralListener.AcceptMessage(); var data = msg.Data.ToString(); if (commandLine.TryParse(data)) { CommandV2(commandLine); } } if (OutputMode == OutputMode.Profile) { profiler.StartSectionWatch("Setup frequencies"); } if (OutputMode == OutputMode.Profile) { profiler.UpdateRuntime(); } Context.Frame++; UpdateFrequency updateFrequency = UpdateFrequency.None; if ((updateSource & UpdateType.Update1) != 0) { updateFrequency |= UpdateFrequency.Update1; } if ((updateSource & UpdateType.Update10) != 0) { updateFrequency |= UpdateFrequency.Update10; } if ((updateSource & UpdateType.Update100) != 0) { updateFrequency |= UpdateFrequency.Update100; } UpdateFrequency targetFrequency = UpdateFrequency.Update1; if (OutputMode == OutputMode.Profile) { profiler.StopSectionWatch("Setup frequencies"); } foreach (var subsystem in Subsystems) { if (OutputMode == OutputMode.Profile) { profiler.StartSectionWatch(subsystem.Key); } ISubsystem system = subsystem.Value; if ((system.UpdateFrequency & updateFrequency) != 0) { system.Update(Context.LocalTime, updateFrequency); } targetFrequency |= system.UpdateFrequency; if (OutputMode == OutputMode.Profile) { profiler.StopSectionWatch(subsystem.Key); } } Context.Program.Runtime.UpdateFrequency = targetFrequency; } else if (Activating) { Activating = false; Activate(); } }