예제 #1
0
 public FlightLoopTestPlugin(IXPlaneApi api)
     : base(api)
 {
     m_flightLoopHook = Api.Processing.RegisterFlightLoopHook(
         FlightLoopTime.FromSeconds(1.0f), OnFlightLoopHook
         );
 }
예제 #2
0
        /// <summary>
        /// This is a hook that is called when the flight look starts to run,
        /// that is, when the simulator is fully loaded. Only then will <see cref="IXPlaneScenery.LookupObjects(string, float, float)"/>
        /// reasonable results, because the scenery indexes are loaded only after the
        /// plugins are started.  After the work is done the flight loop hook is
        /// disposed because we no longer need it.
        /// </summary>
        private FlightLoopTime SimLoaded(TimeSpan elapsedTimeSinceLastCall, TimeSpan elapsedTimeSinceLastFlightLoop, int counter)
        {
            m_api.Log.Log($"GraphicsTestPlugin: Entered SimLoaded flightloop (just called once)");

            m_api.Log.Log($"GraphicsTestPlugin: Loading objects with path {TUGPATH}");
            var tugs = m_api.Scenery.LookupObjects(TUGPATH, 0, 0);

            foreach (var p in tugs)
            {
                m_api.Log.Log($"GraphicsTestPlugin: Filename: {p}");
            }

            m_testTug          = m_api.Scenery.LoadObject(tugs.First());
            m_testTugInstances = Enumerable.Range(0, 10).Select(_ => m_api.Instance.Create(m_testTug, new string[]
            {
                "sim/graphics/animation/ground_traffic/tire_steer_deg"
            })).ToList();

            m_tireTurning = m_api.Processing.RegisterFlightLoopHook(FlightLoopTime.FromCycles(1), TurnTheWheel);

            m_api.Log.Log($"Loaded and still living, reference is {m_testTug}");
            m_firstFlightLoopHook.Dispose();
            m_firstFlightLoopHook = null;
            m_api.Log.Log($"GraphicsTestPlugin: Leaving SimLoaded flightloop");

            return(FlightLoopTime.Unscheduled);
        }
예제 #3
0
        public GraphicsTestPlugin(IXPlaneApi api)
        {
            m_api = api ?? throw new ArgumentNullException(nameof(api));

            m_api.Log.Log("GraphicsTestPlugin: Displaytest started");
            m_drawingLoopHook = m_api.Display.RegisterDrawHook(DrawingHook, XPLMDrawingPhase.xplm_Phase_Airplanes, 0);
            m_flightLoopHook  = m_api.Processing.RegisterFlightLoopHook(FlightLoopTime.FromCycles(1), SimLoaded);
            m_api.Log.Log("GraphicsTestPlugin: And now create a probe");
            m_probe = m_api.Scenery.CreateProbe();
            m_api.Log.Log("GraphicsTestPlugin: Probe created");
        }
예제 #4
0
        public GraphicsTestPlugin(IXPlaneApi api)
        {
            m_api = api ?? throw new ArgumentNullException(nameof(api));

            m_api.Log.Log("GraphicsTestPlugin: Displaytest started");
            m_drawingLoopHook     = m_api.Display.RegisterDrawHook(DrawingHook, XPDrawingPhase.Airplanes, 0);
            m_firstFlightLoopHook = m_api.Processing.RegisterFlightLoopHook(FlightLoopTime.FromCycles(1), SimLoaded);
            m_api.Data.RegisterDataAccessor("BSUB/CounterDataRef",
                                            getDataf: () => 3);
            m_api.Log.Log("GraphicsTestPlugin: And now create a probe");
            m_probe = m_api.Scenery.CreateProbe();
            m_api.Log.Log("GraphicsTestPlugin: Probe created");
        }
예제 #5
0
        public LoggerPlugin(IXPlaneApi api)
        {
            m_api = api ?? throw new ArgumentNullException(nameof(api));

            m_api.Log.Log("LoggerPlugin: Started");

            m_api.ConfigChanged += OnConfigurationChanged;

            m_flightLoopHook = m_api.Processing.RegisterFlightLoopHook(
                FlightLoopTime.FromSeconds(1.0f), OnFlightLoopHook
                );

            ReloadDataRefs();
        }
예제 #6
0
        public LoggerPlugin(IXPlaneApi api)
        {
            m_api = api ?? throw new ArgumentNullException("api");

            m_api.Log.Log("LoggerPlugin: Started");

            m_api.ConfigChanged += OnConfigurationChanged;

            m_api.Messages.MessageReceived += Messages_MessageReceived;
            m_api.Messages.PlaneCrashed    += Messages_PlaneCrashed;
            m_api.Messages.PlaneLoaded     += Messages_PlaneLoaded;

            m_flightLoopHook = m_api.Processing.RegisterFlightLoopHook(
                FlightLoopTime.FromSeconds(1.0f), OnFlightLoopHook
                );

            ReloadDataRefs();
        }
예제 #7
0
        /// <summary>
        /// This is a hook that is called when the flight look starts to run,
        /// that is, when the simulator is fully loaded. Only then will <see cref="IXPlaneScenery.LookupObjects(string, float, float)"/>
        /// reasonable results, because the scenery indexes are loaded only after the
        /// plugins are started.  After the work is done the flight loop hook is
        /// disposed because we no longer need it.
        /// </summary>
        private FlightLoopTime SimLoaded(TimeSpan elapsedTimeSinceLastCall, TimeSpan elapsedTimeSinceLastFlightLoop, int counter)
        {
            m_api.Log.Log($"GraphicsTestPlugin: Loading objects with path {TUGPATH}");

            var tugs = m_api.Scenery.LookupObjects(TUGPATH, 0, 0);

            foreach (var p in tugs)
            {
                m_api.Log.Log($"GraphicsTestPlugin: Filename: {p}");
            }

            testTug = m_api.Scenery.LoadObject(tugs.First());
            m_api.Log.Log($"GraphicsTestPlugin: Loaded and still living, reference is {testTug}");

            m_flightLoopHook.Dispose();
            m_flightLoopHook = null;

            return(FlightLoopTime.Unscheduled);
        }