// 自身のオブジェクト変更 void ChangeObject(int listnum) { ObjectList[mynum].SetActive(false); ObjectList[listnum].SetActive(true); mynum = listnum; // 自身のオブジェクト番号更新 S_aiOData = ObjectList[listnum].GetComponent <AIObjectData>(); SetOdata(OdataList[listnum]); }
// オブジェクトデータ変更 public void SetOdata(ObjectData data, AIObjectData data2) { this.Odata = data; this.aiOData = data2; }
private void CreateLocalEntityObject(AI_Entity_Details newAircraftData, uint objectID) { // SimConnect has notified the application that an entity exists and has provided its ObjectID // Create a local AIObjectData item to store this information and create a reocurring // SimConnect request for positional data each second // Finally, display the objects information in the listview control AIObjectData aidata = new AIObjectData(); aidata.dwIndex = 0; aidata.dwObjectID = objectID; aidata.itemText = aidata.dwObjectID.ToString(); aidata.ad = newAircraftData; ListViewItem lvi = null; if (aidata.ad.IsUserSim) { // Request positional data for the user object simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_USERAIRCRAFT_DATA, DEFINITIONS.PositionData_Definition, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SECOND, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0); // Distinguish this item from AI objects with specific naming lvi = new ListViewItem("User"); } else { // Request positional data for each object we encounter // Note that the request is for every second, but the interval is every 2nd one // so we will receive data every two seconds simconnect.RequestDataOnSimObject((DATA_REQUESTS)(objectID), DEFINITIONS.PositionData_Definition, objectID, SIMCONNECT_PERIOD.SECOND, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 2, 0); lvi = new ListViewItem(aidata.ad.Category); } // Add this object to our dictionary list to keep track of it if (!AIObjects.ContainsKey(aidata.itemText)) { AIObjects.Add(aidata.itemText, aidata); } else { // If the object has been added, update it AIObjects[aidata.itemText] = aidata; } // For this initial update, populate the items for this object with data which is available // The positional data will be updated as soon as the above 'RequestDataOnSimObject' // request is processed // The remainder of items will be populated in SimConnect_OnRecvSimobjectDataBytype lvi.Name = objectID.ToString(); lvi.SubItems.Add(aidata.ad.Title); lvi.SubItems.Add(aidata.ad.Model); lvi.SubItems.Add(aidata.ad.ID); lvi.SubItems.Add(aidata.ad.Airline); lvi.SubItems.Add(aidata.ad.FlightNumber); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.Tag = aidata; lvi.Checked = true; // If this is the User's object, insert it at the top of the list // Add all other AI object in the order they are received if (aidata.ad.IsUserSim) { AIObjectListView.Items.Insert(0, lvi); } else if (AIObjects.ContainsKey(aidata.itemText)) { AIObjectListView.Items.Add(lvi); } }