Exemplo n.º 1
0
        private void sc_OnRecvEventObjectAddremove(SimConnect sender, SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE data)
        {
            switch ((EventIDs)data.uEventID)
            {
            case EventIDs.AddObject:
                if (data.dwData != 0 && !Objects.Contains(data.dwData))
                {
                    VehiclePosition pos = new VehiclePosition(data.dwData);
                    Objects.Add(pos);
                    sender.RequestDataOnSimObject(
                        (RequestIDs)((int)RequestIDs.AIDataBase + (int)pos.ObjectID),
                        pos.ObjectID,
                        SIMCONNECT_PERIOD.VISUAL_FRAME,
                        SIMCONNECT_DATA_REQUEST_FLAG.CHANGED,
                        pos);
                }
                break;

            case EventIDs.RemoveObject:
                if (data.dwData != 0 && Objects.Contains(data.dwData))
                {
                    Objects.Remove(data.dwData);
                }
                break;
            }
        }
Exemplo n.º 2
0
 private void sc_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
 {
     if (!Objects.Contains(data.dwObjectID))
     {
         VehiclePosition pos = (VehiclePosition)data.dwData;
         pos.ObjectID = data.dwObjectID;
         Objects.Add(pos);
         sender.RequestDataOnSimObject(
             (RequestIDs)((int)RequestIDs.AIDataBase + (int)pos.ObjectID),
             pos.ObjectID,
             SIMCONNECT_PERIOD.VISUAL_FRAME,
             SIMCONNECT_DATA_REQUEST_FLAG.CHANGED,
             pos);
     }
 }