示例#1
0
文件: Program.cs 项目: wegylexy/XPLM
    public XPlugin() : base()
    {
        // e.g. check for API support
        if (Utilities.Versions.XPLMVersion < 303)
        {
            throw new NotSupportedException("TCAS override not supported.");
        }

        // Example: finds datarefs
        _overrideTcas = DataRef.Find("sim/operation/override/override_TCAS") !;
        DataRef
            bearing  = DataRef.Find("sim/cockpit2/tcas/indicators/relative_bearing_degs") !,
            distance = DataRef.Find("sim/cockpit2/tcas/indicators/relative_distance_mtrs") !,
            altitude = DataRef.Find("sim/cockpit2/tcas/indicators/relative_altitude_mtrs") !;

        // Example: registers my flight loop
        _myLoop = new FlightLoop(FlightLoopPhase.AfterFlightModel, (elapsedSinceLastCall, elapsedTimeSinceLastFlightLoop, counter) =>
        {
            // TODO: set number of planes
            var count           = 2;
            Span <float> values = stackalloc float[count];
            // TODO: set bearings
            bearing.AsFloatVector(0).Write(values);
            // TODO: set distances
            distance.AsFloatVector(0).Write(values);
            // TODO: set altitudes
            altitude.AsFloatVector(0).Write(values);
            // Schedules for one second later
            return(1);
        });
    }