public List <PlaneInfo> PlaneInfoGetAll(DateTime newerthan) { List <PlaneInfo> l = new List <PlaneInfo>(); int i = SupportFunctions.DateTimeToUNIXTime(newerthan); // SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > 1500000 GROUP BY AircraftPositions.Hex DataTable Result = db.Select("SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > " + i.ToString() + " GROUP BY AircraftPositions.Hex"); if (!IsValid(Result) || (Result.Rows.Count == 0)) { return(l); } foreach (DataRow row in Result.Rows) { PlaneInfo info = new PlaneInfo(row); try { l.Add(info); } catch (Exception ex) { Log.WriteMessage("Error inserting PlaneInfo[" + info.ToString() + "]: " + ex.ToString(), LogLevel.Error); } } return(l); }
/// <summary> /// 创建地图 /// </summary> private void CreateGround() { GameObject map_root = getMapRoot(); Transform ground_root_trans = map_root.transform.FindChild(ground_root_name); GameObject ground_root_go; if (ground_root_trans == null) { ground_root_go = new GameObject(ground_root_name); ground_root_go.transform.parent = map_root.transform; ground_root_go.transform.localPosition = Vector3.zero; } else { Debug.LogWarning("你已经创建地图了,不能再创建了。"); return; } Mesh mesh = PlaneInfo.CreateMesh(m_PerGroundWidth * 0.5f, m_PerGroundLength * 0.5f); // 按照大小创建一个片 高度为0 for (int w = 0; w < m_WidthNum; w++) { for (int h = 0; h < m_LengthNum; h++) { float pos_x = m_PerGroundWidth * w; float pos_z = m_PerGroundLength * h; string name = string.Format("ground_{0}_{1}", w, h); PlaneInfo.CreatePlaneWithMesh(new Vector3(pos_x, 0, pos_z), mesh, name, ground_root_go.transform, null); } } Transform bounds = BoundsRoot; }
PlaneInfo createGamePlaneInfo(GameObject planeObj, bool applyRotationCorrections = true, bool applySizeCorrections = false) { PlaneInfo newPlane = new PlaneInfo(); newPlane.origin = planeObj.transform.position; if (applyRotationCorrections) { newPlane.rotation = planeObj.transform.rotation * Quaternion.AngleAxis(-90, Vector2.right); } else { newPlane.rotation = planeObj.transform.rotation; } newPlane.inverseRotation = Quaternion.Inverse(newPlane.rotation); newPlane.normal = newPlane.rotation * Vector3.up; Vector2 size = new Vector2(); size.x = planeObj.transform.localScale.x; size.y = planeObj.transform.localScale.y; if (applySizeCorrections) { size.x *= 10.0f; size.y *= 10.0f; } newPlane.size = size; return(newPlane); }
public static void UnityXRMock_setPlaneData( TrackableId planeId, Pose pose, Vector2 center, Vector2 bounds, Vector2[] boundaryPoints, int numPoints, TrackingState trackingState) { if (!s_planes.ContainsKey(planeId) || s_addedPlanes.ContainsKey(planeId)) { if (!s_planes.ContainsKey(planeId)) { s_planes[planeId] = new PlaneInfo() { id = planeId }; } s_addedPlanes[planeId] = s_planes[planeId]; } else { s_updatedPlanes[planeId] = s_planes[planeId]; } var planeInfo = s_planes[planeId]; planeInfo.pose = pose; planeInfo.center = center; planeInfo.bounds = bounds; planeInfo.boundaryPoints = boundaryPoints; planeInfo.numPoints = numPoints; planeInfo.trackingState = trackingState; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void UpdatePlane(exPlane _plane) { PlaneInfo planeInfo = null; for (int i = 0; i < planeInfoList.Count; ++i) { if (planeInfoList[i].plane == _plane) { planeInfo = planeInfoList[i]; break; } } if (planeInfo == null) { Debug.LogWarning("Can't find plane info of " + _plane.name); return; } // update plane info material if (_plane.GetComponent <Renderer>() != null) { planeInfo.material = _plane.GetComponent <Renderer>().sharedMaterial; } // if we are in player or if we are running in editor if (Application.isPlaying) { exClipping clipPlane = _plane as exClipping; // if this is not a clip plane if (clipPlane == null) { ApplyClipMaterial(_plane); } } }
public SelectSeatOnPlaneMenu(int index) : base(new int[][] { new int[] { 2, 8 } }, new string[] { "Plane Seat Number:" }) { Console.WriteLine($"{index}, {SessionData.Planes.Length}"); Plane = SessionData.Planes[index]; }
public Dispatcher(PlaneInfo planeInfo) { this.planeInfo = planeInfo; Random random = new Random(); WeatherCorrection = random.Next(-200, 200); }
private bool ShouldBreakPlane(PlaneInfo plane, int spanIndex, int chunkSpanIndex, int chunkIndex, int subMaterial) { return(plane.Inspected[spanIndex] || Shapes[chunkSpanIndex].Value != Shapes[chunkIndex].Value || CulledFaces[chunkSpanIndex].Value.HasDirection(plane.direction) || !Materials[chunkSpanIndex].Equals(BatchIdentity) || SubMaterials[chunkSpanIndex].Value[plane.direction] != subMaterial); }
/// <summary> /// 创建地表元素 /// </summary> /// <param name="type"></param> private void CreateSurface(SurfaceElementType type) { GameObject root = getMapRoot(); Transform cover_trans = root.transform.FindChild(surface_root_name); GameObject cover; if (cover_trans == null) { cover = new GameObject(surface_root_name); cover.transform.parent = root.transform; cover.transform.localPosition = Vector3.zero; } else { cover = cover_trans.gameObject; } string name = ""; GameObject element = null; GameObject temp = null; switch (type) { case SurfaceElementType.Plane: name = string.Format("plane_cover_{0}_{1}", cover.transform.childCount, "p"); //p is short for plane element = PlaneInfo.CreatePlane(m_PlaneWidth * 0.5f, m_PlaneLength * 0.5f, name, cover.transform, null); element.transform.localPosition = new Vector3(0, m_PlaneHeight, 0); Selection.activeGameObject = element; break; case SurfaceElementType.PlaneWithCollider: name = string.Format("plane_cover_{0}_{1}", cover.transform.childCount, "pc"); //pc is short for plane collider element = PlaneInfo.CreatePlane(m_PlaneWidth * 0.5f, m_PlaneLength * 0.5f, name, cover.transform, null); temp = new GameObject("collider_0"); temp.AddComponent <BoxCollider>(); temp.transform.parent = element.transform; temp.transform.localPosition = Vector3.zero; element.transform.localPosition = new Vector3(0, m_PlaneHeight, 0); Selection.activeGameObject = element; break; case SurfaceElementType.Collider: name = string.Format("plane_cover_{0}_{1}", cover.transform.childCount, "c"); //c is short for collider temp = new GameObject(name); temp.AddComponent <BoxCollider>(); temp.transform.parent = cover.transform; temp.transform.localPosition = Vector3.zero; Selection.activeGameObject = temp; break; default: break; } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected void AddPlaneInfo(exPlane _plane) { PlaneInfo planeInfo = new PlaneInfo(); planeInfo.plane = _plane; if (_plane.renderer != null) { planeInfo.material = _plane.renderer.sharedMaterial; } planeInfoList.Add(planeInfo); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected void AddPlaneInfo(exPlane _plane) { PlaneInfo planeInfo = new PlaneInfo(); planeInfo.plane = _plane; if (_plane.GetComponent <Renderer>() != null) { planeInfo.material = _plane.GetComponent <Renderer>().sharedMaterial; } planeInfoList.Add(planeInfo); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected void InsertPlaneInfo(int _idx, exPlane _plane) { PlaneInfo planeInfo = new PlaneInfo(); planeInfo.plane = _plane; if (_plane.GetComponent <Renderer>() != null) { planeInfo.material = _plane.GetComponent <Renderer>().sharedMaterial; } planeInfoList.Insert(_idx, planeInfo); }
// ------------------------------------------------------------------ /// remove all planes from clipping list // ------------------------------------------------------------------ public void Clear() { for (int i = 0; i < planeInfoList.Count; ++i) { PlaneInfo pi = planeInfoList[i]; if (pi.plane && pi.plane.GetComponent <Renderer>() && pi.plane.GetComponent <Renderer>().sharedMaterial) { pi.plane.GetComponent <Renderer>().sharedMaterial = pi.material; } } planeInfoList.Clear(); textureToClipMaterialTable.Clear(); clipMaterialList.Clear(); }
void OnNewCollideWithPlane(IEventBase eventBase) { BallsPlaneCollideEvent ballscollide = eventBase as BallsPlaneCollideEvent; PlaneInfo planeinfo = new PlaneInfo() { planeNum = ballscollide.planeNum, levelNum = ballscollide.levelNum, finalPlane = ballscollide.finalPlane }; progressList.Add(planeinfo); CheckForFailOrWin(); }
// ------------------------------------------------------------------ /// OnDisable functoin inherit from exPlane. /// When enabled set to false, it will disable all the item in the planeInfoList // ------------------------------------------------------------------ protected new void OnDisable() { base.OnDisable(); // for (int i = 0; i < planeInfoList.Count; ++i) { PlaneInfo pi = planeInfoList[i]; if (pi.plane && pi.plane.GetComponent <Renderer>()) { pi.plane.GetComponent <Renderer>().sharedMaterial = pi.material; } } }
private void ShowPlaneUI() { foreach (Plane plane in planes) { if (plane.country.IsHostile) { continue; } PlaneInfo planeInfo = Instantiate(planeInfoPrefab); planeInfo.transform.SetParent(planeInfoParent); planeInfo.transform.position = Camera.main.WorldToScreenPoint(plane.transform.position); planeInfo.ShowInfo(plane); planeInfos.Add(planeInfo); } }
public static Action[] GenActionsForLength(int planeCount, PlaneInfo[] planes) { List <Action> actions = new List <Action>(); for (int i = 0; i < planeCount; i++) { PlaneInfo plane = planes[i]; actions.Add(() => { SelectPlane(plane); }); } actions.Add(() => Logout()); return(actions.ToArray()); }
// ------------------------------------------------------------------ /// OnEnable functoin inherit from exPlane. /// When enabled set to true, it will enable all the item in the planeInfoList // ------------------------------------------------------------------ protected new void OnEnable() { base.OnEnable(); Init(); // for (int i = 0; i < planeInfoList.Count; ++i) { PlaneInfo pi = planeInfoList[i]; exPlane plane = pi.plane; if (plane && plane.GetComponent <Renderer>() && plane.GetComponent <Renderer>().sharedMaterial) { Texture2D texture = plane.GetComponent <Renderer>().sharedMaterial.mainTexture as Texture2D; plane.GetComponent <Renderer>().material = textureToClipMaterialTable[texture]; } } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected bool RemovePlaneInfo(exPlane _plane) { for (int i = 0; i < planeInfoList.Count; ++i) { PlaneInfo pi = planeInfoList[i]; if (_plane == pi.plane) { if (_plane.GetComponent <Renderer>() != null) { _plane.GetComponent <Renderer>().sharedMaterial = pi.material; } planeInfoList.RemoveAt(i); return(true); } } return(false); }
private int GetChunkIndex(PlaneInfo plane, int major, int minor) { switch (plane.mode) { case PlaneMode.x: return(UnivoxUtil.GetIndex(plane.PlaneLevel, minor, major)); case PlaneMode.y: return(UnivoxUtil.GetIndex(minor, plane.PlaneLevel, major)); case PlaneMode.z: return(UnivoxUtil.GetIndex(minor, major, plane.PlaneLevel)); default: throw new ArgumentOutOfRangeException(); } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void CheckAndRemoveClipMaterial(Texture2D _texture) { bool hasPlaneUseIt = false; for (int i = 0; i < planeInfoList.Count; ++i) { PlaneInfo pi = planeInfoList[i]; if (pi.material != null && pi.material.mainTexture == _texture) { hasPlaneUseIt = true; break; } } if (hasPlaneUseIt == false) { Material clipMaterial = textureToClipMaterialTable[_texture]; textureToClipMaterialTable.Remove(_texture); clipMaterialList.Remove(clipMaterial); } }
public static void UnityXRMock_setPlaneTrackingState(TrackableId planeId, TrackingState trackingState) { if (!s_planes.ContainsKey(planeId) || s_addedPlanes.ContainsKey(planeId)) { if (!s_planes.ContainsKey(planeId)) { s_planes[planeId] = new PlaneInfo(); } s_addedPlanes[planeId] = s_planes[planeId]; } else { s_updatedPlanes[planeId] = s_planes[planeId]; } var planeInfo = s_planes[planeId]; planeInfo.trackingState = trackingState; }
// Use this for initialization void Awake() { planes = new PlaneInfo[transform.childCount]; int i = 0; foreach (Transform child in transform) { PlaneInfo newPlane = new PlaneInfo(); newPlane.origin = child.position; newPlane.rotation = child.rotation; newPlane.inverseRotation = Quaternion.Inverse(child.rotation); newPlane.normal = child.rotation * Vector3.up; Vector2 size = new Vector2(); size.x = child.localScale.x * 10; size.y = child.localScale.y * 10; newPlane.size = size; planes[i] = newPlane; i++; } }
public static void UnityXRMock_subsumedPlane(TrackableId planeId, TrackableId subsumedById) { if (!s_planes.ContainsKey(planeId) || s_addedPlanes.ContainsKey(planeId)) { if (!s_planes.ContainsKey(planeId)) { s_planes[planeId] = new PlaneInfo() { id = planeId }; } s_addedPlanes[planeId] = s_planes[planeId]; } else { s_updatedPlanes[planeId] = s_planes[planeId]; } var planeInfo = s_planes[planeId]; planeInfo.subsumedById = subsumedById; }
public Plane( ActorInitializer init, PlaneInfo info ) : base(init, info) { }
public Plane(ActorInitializer init, PlaneInfo info) : base(init, info) { self = init.self; Info = info; }
public ReturnToBase(Actor self, Actor dest) { this.dest = dest; plane = self.Trait<Plane>(); planeInfo = self.Info.Traits.Get<PlaneInfo>(); }
static PlaneIdHelper() { PlaneInfo planeIdInfo = new PlaneInfo(); planeIdInfo.PlaneId = PlaneId.XY; planeIdInfo.QuadrantInfo = new List <PlaneQuadrantInfo>() { new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.First, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Second, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Third, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Negative }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Fourth, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Negative } }; _planeInfo[(int)PlaneId.XY] = planeIdInfo; planeIdInfo = new PlaneInfo(); planeIdInfo.PlaneId = PlaneId.YZ; planeIdInfo.QuadrantInfo = new List <PlaneQuadrantInfo>() { new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.First, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Negative }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Second, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Third, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Fourth, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Negative } }; _planeInfo[(int)PlaneId.YZ] = planeIdInfo; planeIdInfo = new PlaneInfo(); planeIdInfo.PlaneId = PlaneId.ZX; planeIdInfo.QuadrantInfo = new List <PlaneQuadrantInfo>() { new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.First, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Second, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Positive }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Third, FirstAxisSign = AxisSign.Negative, SecondAxisSign = AxisSign.Negative }, new PlaneQuadrantInfo() { Quadrant = PlaneQuadrantId.Fourth, FirstAxisSign = AxisSign.Positive, SecondAxisSign = AxisSign.Negative } }; _planeInfo[(int)PlaneId.ZX] = planeIdInfo; }
protected override void OnDoWork(DoWorkEventArgs e) { Log.WriteMessage("Started."); Arguments = (PlaneFeedWorkEventArgs)e.Argument; if (String.IsNullOrEmpty(Thread.CurrentThread.Name)) { Thread.CurrentThread.Name = this.GetType().Name; } // use PlaneInfoConverter for plausibility check PlaneInfoConverter C = new PlaneInfoConverter(); // check boundaries if ((Arguments.MaxLat <= Arguments.MinLat) || (Arguments.MaxLon <= Arguments.MinLon)) { Status = STATUS.ERROR; this.ReportProgress((int)PROGRESS.ERROR, "Area boundaries mismatch. Check your Covered Area parameters!"); Log.WriteMessage("Area boundaries mismatch. Check your Covered Area parameters!", LogLevel.Error); } else { if (Arguments.Feed == null) { Status = STATUS.ERROR; this.ReportProgress((int)PROGRESS.ERROR, "Plane feed plugin not found. Check your settings!"); Log.WriteMessage("Plane feed plugin not found. Check your settings!", LogLevel.Error); } else { do { try { Status = STATUS.OK; int interval = Arguments.Interval; // build arguments PlaneFeedPluginArgs feedargs = new PlaneFeedPluginArgs(); feedargs.AppDirectory = Arguments.AppDirectory; feedargs.AppDataDirectory = Arguments.AppDataDirectory; feedargs.LogDirectory = Arguments.LogDirectory; feedargs.TmpDirectory = Arguments.TmpDirectory; feedargs.DatabaseDirectory = Arguments.DatabaseDirectory; feedargs.MaxLat = Arguments.MaxLat; feedargs.MinLon = Arguments.MinLon; feedargs.MinLat = Arguments.MinLat; feedargs.MaxLon = Arguments.MaxLon; feedargs.MyLat = Arguments.MyLat; feedargs.MyLon = Arguments.MyLon; feedargs.DXLat = Arguments.DXLat; feedargs.DXLon = Arguments.DXLon; feedargs.MinAlt = Arguments.MinAlt; feedargs.MaxAlt = Arguments.MaxAlt; feedargs.KeepHistory = Arguments.KeepHistory; feedargs.InstanceID = Arguments.InstanceID; feedargs.SessionKey = Arguments.SessionKey; feedargs.GetKeyURL = Arguments.GetKeyURL; // do start procedure Arguments.Feed.Start(feedargs); // run inner loop do { // call plugin's interface to get the planes try { Stopwatch st = new Stopwatch(); st.Start(); // get plane raw data and do addtional checks PlaneFeedPluginPlaneInfoList acs = Arguments.Feed.GetPlanes(feedargs); PlaneInfoList planes = new PlaneInfoList(); int total = acs.Count; int count = 0; int errors = 0; foreach (PlaneFeedPluginPlaneInfo ac in acs) { // skip without error when on ground if (ac.Ground) { continue; } // copy raw data to new PlaneInfo object PlaneInfo plane = new PlaneInfo(); plane.Hex = ac.Hex; plane.Lat = ac.Lat; plane.Lon = ac.Lon; plane.Alt = ac.Alt; plane.Call = ac.Call; plane.Reg = ac.Reg; plane.Track = ac.Track; plane.Speed = ac.Speed; plane.Time = ac.Time; plane.From = ac.From; plane.To = ac.To; plane.VSpeed = ac.VSpeed; try { plane.Category = (PLANECATEGORY)ac.Category; } catch { plane.Category = PLANECATEGORY.NONE; } plane.Type = ac.Type; plane.Model = ac.Model; plane.Manufacturer = ac.Manufacturer; // start checks // assuming that at least a timestamp is set! // do basic check on hex --> is strictly needed as identifier if (!PlaneInfoChecker.Check_Hex(plane.Hex)) { // try to fill hex from reg if (!PlaneInfoChecker.Check_Reg(plane.Reg)) { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Hex]: " + plane.Hex, LogLevel.Warning); } errors++; continue; } AircraftDesignator ad = AircraftData.Database.AircraftFindByReg(plane.Reg); if (ad == null) { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Hex]: " + plane.Hex, LogLevel.Warning); } errors++; continue; } plane.Hex = ad.Hex; } // check latitude if (!PlaneInfoChecker.Check_Lat(plane.Lat)) { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Lat]: " + plane.Lat.ToString("F8", CultureInfo.InvariantCulture), LogLevel.Warning); } errors++; continue; } // skip without error when latitude is out of scope if ((plane.Lat < Arguments.MinLat) || (plane.Lat > Arguments.MaxLat)) { continue; } // check longitude if (!PlaneInfoChecker.Check_Lon(plane.Lon)) { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Lon]: " + plane.Lon.ToString("F8", CultureInfo.InvariantCulture), LogLevel.Warning); } errors++; continue; } // skip without error when longitude is out of scope if ((plane.Lon < Arguments.MinLon) || (plane.Lon > Arguments.MaxLon)) { continue; } // check altitude if (!PlaneInfoChecker.Check_Alt(plane.Alt)) { // try to recover altitude from previuos messages PlaneInfo info = null; if (PlanePositions.TryGetValue(plane.Hex, out info)) { plane.Alt = info.Alt; } else { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Alt]: " + plane.Alt.ToString("F8", CultureInfo.InvariantCulture), LogLevel.Warning); } errors++; continue; } } // skip without error when altitude_ is out of bounds if ((plane.Alt_m < Arguments.MinAlt) || (plane.Alt_m > Arguments.MaxAlt)) { continue; } // check call if (!PlaneInfoChecker.Check_Call(plane.Call)) { // try to recover from cache if check fails or set it to [unknown] PlaneInfo info = null; if (PlanePositions.TryGetValue(plane.Hex, out info)) { plane.Call = info.Call; } else { plane.Call = "[unknown]"; } } // still unknown call --> try to recover last known call from database if (!PlaneInfoChecker.Check_Call(plane.Call)) { AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex); if (ad != null) { plane.Call = ad.Call; } else { plane.Call = "[unknown]"; } } // check registration if (!PlaneInfoChecker.Check_Reg(plane.Reg)) { // try to recover from cache if check fails or set it to [unknown] PlaneInfo info = null; if (PlanePositions.TryGetValue(plane.Hex, out info)) { plane.Reg = info.Reg; } else { plane.Reg = "[unknown]"; } } // still unknown --> try to recover last known reg from database if (!PlaneInfoChecker.Check_Reg(plane.Reg)) { AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex); if (ad != null) { plane.Reg = ad.Reg; } else { plane.Reg = "[unknown]"; } } // check speed if (!PlaneInfoChecker.Check_Track(plane.Track)) { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Track]: " + plane.Track.ToString("F8", CultureInfo.InvariantCulture), LogLevel.Warning); } errors++; continue; } // check speed if (!PlaneInfoChecker.Check_Speed(plane.Speed)) { // try to recover speed from previous messages PlaneInfo info = null; if (PlanePositions.TryGetValue(plane.Hex, out info)) { plane.Speed = info.Speed; } else { if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft data received [Speed]: " + plane.Speed.ToString("F8", CultureInfo.InvariantCulture), LogLevel.Warning); } errors++; continue; } } // check type if (!PlaneInfoChecker.Check_Type(plane.Type)) { AircraftDesignator ad = AircraftData.Database.AircraftFindByHex(plane.Hex); if (ad != null) { plane.Type = ad.TypeCode; // getrest of info later later } else { // set all type info to unknown plane.Type = "[unknown]"; plane.Model = "[unknown]"; plane.Manufacturer = "[unknown]"; plane.Category = PLANECATEGORY.NONE; } } // try to recover type info from database if check fails or unknown if (!PlaneInfoChecker.Check_Manufacturer(plane.Manufacturer) || !PlaneInfoChecker.Check_Model(plane.Model) || (plane.Manufacturer == "[unkonwn]") || (plane.Model == "[unknown]")) { AircraftTypeDesignator td = AircraftData.Database.AircraftTypeFindByICAO(plane.Type); if (td != null) { plane.Manufacturer = td.Manufacturer; plane.Model = td.Model; plane.Category = td.Category; } else { plane.Manufacturer = "[unknown]"; plane.Model = "[unknown]"; plane.Category = PLANECATEGORY.NONE; } } // remove manufacturer info if part of model description if (plane.Model.StartsWith(plane.Manufacturer)) { plane.Model = plane.Model.Remove(0, plane.Manufacturer.Length).Trim(); } // check position against estimated position from last konwn if possible PlaneInfo oldplane = PlanePositions.Get(plane.Hex, plane.Time, 5); double dist = 0; if (Arguments.ExtendedPlausibilityCheck_Enable && (oldplane != null) && ((dist = LatLon.Distance(oldplane.Lat, oldplane.Lon, plane.Lat, plane.Lon)) > Arguments.ExtendedPlausiblityCheck_MaxErrorDist)) { // report error if (Arguments.LogErrors) { Log.WriteMessage("Incorrect aircraft position received [(" + oldplane.Lat.ToString("F8") + "," + oldplane.Lon.ToString("F8") + ")<" + dist.ToString("F0") + "km>(" + plane.Lat.ToString("F8") + "," + plane.Lon.ToString("F8") + ")]: " + plane.ToString(), LogLevel.Warning); } errors++; continue; } // all checks successfully done --> add plane to list planes.Add(plane); count++; // cancel thread if requested if (this.CancellationPending) { return; } } // update local cache this.PlanePositions.BulkInsertOrUpdateIfNewer(planes); // report planes to main program this.ReportProgress((int)PROGRESS.PLANES, planes); // update global database AircraftData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(this, planes); // update position database if enabled if (Arguments.KeepHistory) { AircraftPositionData.Database.PlaneInfoBulkInsertOrUpdateIfNewer(planes); } st.Stop(); string msg = "[" + DateTime.UtcNow.ToString("HH:mm:ss") + "] " + total.ToString() + " Positions updated from " + Arguments.Feed.Name + ", " + st.ElapsedMilliseconds.ToString() + " ms. OK: " + count.ToString() + ", Errors: " + errors.ToString(); this.ReportProgress((int)PROGRESS.STATUS, msg); // write all planes to file try { using (StreamWriter sw = new StreamWriter(Path.Combine(Arguments.TmpDirectory, "planes.csv"))) { sw.WriteLine("Time;Hex;Lat;Lon;Alt;Track;Speed;Call;Reg;From;To;VSpeed"); foreach (PlaneInfo plane in planes) { sw.WriteLine(plane.Time + ";" + plane.Hex + ";" + plane.Lat + ";" + plane.Lon + ";" + plane.Alt + ";" + plane.Track + ";" + plane.Speed + ";" + plane.Call + ";" + plane.Reg + ";" + plane.From + ";" + plane.To + ";" + plane.VSpeed); } } } catch (Exception ex) { // do nothing } } catch (Exception ex) { Status = STATUS.ERROR; this.ReportProgress((int)PROGRESS.ERROR, "Plane Feed Execption: " + ex.Message); Log.WriteMessage(ex.ToString(), LogLevel.Error); } // wait for next execution int i = 0; while (!CancellationPending && (i < interval)) { Thread.Sleep(1000); i++; } }while (!CancellationPending); // do stop procedure Arguments.Feed.Stop(feedargs); } catch (Exception ex) { Status = STATUS.ERROR; this.ReportProgress((int)PROGRESS.ERROR, "Plane Feed Execption: " + ex.Message); Log.WriteMessage(ex.ToString(), LogLevel.Error); Console.WriteLine("Plane Feed Execption: " + ex.ToString(), LogLevel.Error); } }while (!this.CancellationPending); } } this.ReportProgress((int)PROGRESS.FINISHED); Log.WriteMessage("Finished."); }
/// <summary> /// 加载场景 /// </summary> /// <param name="sceneName">例如: Scene_1_1 酱紫 </param> public GameObject LoadScene(SceneConf conf_scene) { GameObject scene_go = GameObject.Find("Scene"); if (scene_go == null) { Debug.LogError("导入场景数据出错,场景中无Scene节点!"); return(null); } //create light Object light_prefab = Resources.Load("UI/Prefabs/" + conf_scene.Light.PrefabName); GameObject light_go = GameObject.Instantiate(light_prefab) as GameObject; light_go.name = conf_scene.Light.Name; light_go.transform.localPosition = conf_scene.Light.GetPosition(); light_go.transform.localRotation = conf_scene.Light.GetRotation(); light_go.transform.localScale = conf_scene.Light.GetScale(); light_go.transform.parent = scene_go.transform; //create camera Object ui_prefab = Resources.Load("UI/" + conf_scene.UI.PrefabName); GameObject ui_go = GameObject.Instantiate(ui_prefab) as GameObject; ui_go.name = conf_scene.UI.PrefabName; GameObject camera_go = ui_go.transform.FindChild("CameraScene").gameObject; camera_go.transform.localPosition = conf_scene.UI.GetPosition(); camera_go.transform.localRotation = conf_scene.UI.GetRotation(); camera_go.transform.localScale = conf_scene.UI.GetScale(); ui_go.transform.parent = scene_go.transform; GameObject camera_ui = ui_go.transform.FindChild("Camera").gameObject; camera_ui.transform.localRotation = conf_scene.UI.GetRotation(); /* * //create scene * scene_go = new GameObject("Scene"); * scene_go.name = conf_scene.Name; * scene_go.transform.localPosition = conf_scene.GetPosition(); * scene_go.transform.localRotation = conf_scene.GetRotation(); * scene_go.transform.localScale = conf_scene.GetScale(); */ //create map GameObject map_go = new GameObject(conf_scene.Map.Name); map_go.transform.parent = scene_go.transform; map_go.transform.localPosition = conf_scene.Map.GetPosition(); map_go.transform.localRotation = conf_scene.Map.GetRotation(); map_go.transform.localScale = conf_scene.Map.GetScale(); //create bounds GameObject bounds_root_go = new GameObject("Bounds"); Object point_prefab = Resources.Load("UI/Prefabs/Point_10"); bounds_root_go.transform.parent = map_go.transform; bounds_root_go.transform.localRotation = Quaternion.identity; bounds_root_go.transform.localScale = Vector3.one; bounds_root_go.transform.localPosition = Vector3.zero; if (conf_scene.Bounds != null) { foreach (var item in conf_scene.Bounds) { GameObject point_go = GameObject.Instantiate(point_prefab) as GameObject; point_go.name = item.Name; point_go.transform.parent = bounds_root_go.transform; point_go.transform.localPosition = item.GetPosition(); point_go.transform.localRotation = item.GetRotation(); point_go.transform.localScale = item.GetScale(); } } //create ground GameObject ground_go = new GameObject(conf_scene.Map.Ground.Name); ground_go.transform.parent = map_go.transform; ground_go.transform.localPosition = conf_scene.Map.Ground.GetPosition(); ground_go.transform.localRotation = conf_scene.Map.Ground.GetRotation(); ground_go.transform.localScale = conf_scene.Map.Ground.GetScale(); if (conf_scene.PlaceHolder != null) { foreach (var info in conf_scene.PlaceHolder) { //Debug.Log("位置点信息: " + info.GetPosition()); //todo: FightScene.s_InstanceThis.PushPos(info.GetPosition()); } } else { Debug.Log("位置点信息为空"); } Mesh ground_mesh = PlaneInfo.CreateMesh((float)conf_scene.Map.Ground.CellWidth * 0.5f, (float)conf_scene.Map.Ground.CellHeight * 0.5f); foreach (var cell in conf_scene.Map.Ground.GroundCells) { GameObject cell_go; Object res = Resources.Load("Materials/Map/" + cell.Materials[0]); if (res != null) { Material matX = res as Material; cell_go = PlaneInfo.CreatePlaneWithMesh(cell.GetPosition(), ground_mesh, cell.Name, ground_go.transform, matX); } else { Debug.LogError("NotFound " + cell.Materials[0]); cell_go = PlaneInfo.CreatePlaneWithMesh(cell.GetPosition(), ground_mesh, cell.Name, ground_go.transform, null); if (cell.Materials.Count > 0) { //todo: FightScene.s_InstanceThis.m_MBM.AddMaterial(cell_go, cell.Materials[0]); } } cell_go.transform.localRotation = cell.GetRotation(); cell_go.transform.localScale = cell.GetScale(); } //create surface GameObject surface_go = new GameObject(conf_scene.Map.Surface.Name); surface_go.transform.parent = map_go.transform; surface_go.transform.localPosition = conf_scene.Map.Surface.GetPosition(); surface_go.transform.localRotation = conf_scene.Map.Surface.GetRotation(); surface_go.transform.localScale = conf_scene.Map.Surface.GetScale(); if (conf_scene.Map.Surface.Planes != null) { foreach (var item in conf_scene.Map.Surface.Planes) { GameObject item_go; Object res = Resources.Load("Materials/Map/" + item.Materials[0]); if (res != null) { Material mat = res as Material; item_go = PlaneInfo.CreatePlane((float)item.CellWidth * 0.5f, (float)item.CellHeight * 0.5f, item.Name, surface_go.transform, mat); } else { Debug.LogError("NotFound " + item.Materials[0]); item_go = PlaneInfo.CreatePlane((float)item.CellWidth * 0.5f, (float)item.CellHeight * 0.5f, item.Name, surface_go.transform, null); if (item.Materials.Count > 0) { //todo: FightScene.s_InstanceThis.m_MBM.AddMaterial(item_go, item.Materials[0]); } } item_go.transform.localPosition = item.GetPosition(); item_go.transform.localRotation = item.GetRotation(); item_go.transform.localScale = item.GetScale(); } } if (conf_scene.Map.Surface.Colliders != null) { foreach (var item in conf_scene.Map.Surface.Colliders) { GameObject go = new GameObject(item.Name); go.transform.parent = surface_go.transform; go.transform.localPosition = item.GetPosition(); go.transform.localRotation = item.GetRotation(); go.transform.localScale = item.GetScale(); BoxCollider comp = go.AddComponent <BoxCollider>(); comp.center = item.ListToVector3(item.Center); comp.size = item.ListToVector3(item.Size); } } if (conf_scene.Map.Surface.PlaneWithColliders != null) { foreach (var item in conf_scene.Map.Surface.PlaneWithColliders) { GameObject item_go; Object res = Resources.Load("Materials/Map/" + item.Plane.Materials[0]); if (res != null) { Material mat = res as Material; item_go = PlaneInfo.CreatePlane((float)item.Plane.CellWidth * 0.5f, (float)item.Plane.CellHeight * 0.5f, item.Name, surface_go.transform, mat); } else { Debug.LogError("NotFound " + item.Plane.Materials[0]); item_go = PlaneInfo.CreatePlane((float)item.Plane.CellWidth * 0.5f, (float)item.Plane.CellHeight * 0.5f, item.Name, surface_go.transform, null); if (item.Plane.Materials.Count > 0) { //todo: FightScene.s_InstanceThis.m_MBM.AddMaterial(item_go, item.Plane.Materials[0]); } } item_go.transform.localPosition = item.GetPosition(); item_go.transform.localRotation = item.GetRotation(); item_go.transform.localScale = item.GetScale(); foreach (var item_collider in item.Colliders) { GameObject go = new GameObject(item_collider.Name); go.transform.parent = item_go.transform; go.transform.localPosition = item_collider.GetPosition(); go.transform.localRotation = item_collider.GetRotation(); go.transform.localScale = item_collider.GetScale(); BoxCollider comp = go.AddComponent <BoxCollider>(); comp.center = item_collider.ListToVector3(item_collider.Center); comp.size = item_collider.ListToVector3(item_collider.Size); } } } // Create Over return(scene_go); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected void InsertPlaneInfo( int _idx, exPlane _plane ) { PlaneInfo planeInfo = new PlaneInfo(); planeInfo.plane = _plane; if ( _plane.renderer != null ) planeInfo.material = _plane.renderer.sharedMaterial; planeInfoList.Insert(_idx,planeInfo); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected void AddPlaneInfo( exPlane _plane ) { PlaneInfo planeInfo = new PlaneInfo(); planeInfo.plane = _plane; if ( _plane.renderer != null ) planeInfo.material = _plane.renderer.sharedMaterial; planeInfoList.Add(planeInfo); }
private void ProccessPlane(PlaneInfo plane) { for (var major = 0; major < UnivoxDefine.AxisSize; major++) { for (var minor = 0; minor < UnivoxDefine.AxisSize; minor++) { var planeIndex = UnivoxUtil.GetIndex(minor, major); var chunkIndex = GetChunkIndex(plane, minor, major); if (plane.Inspected[planeIndex]) { continue; } // plane.Inspected[yzIndex] = true; if (CulledFaces[chunkIndex].Value.HasDirection(plane.direction) || !Materials[chunkIndex].Equals(BatchIdentity)) { plane.Inspected[planeIndex] = true; continue; } //Size excludes it's own voxel int2 size = int2.zero; int subMat = SubMaterials[chunkIndex].Value[plane.direction]; var cantMerge = false; for (var majorSpan = 0; majorSpan < UnivoxDefine.AxisSize - major; majorSpan++) { if (majorSpan == 0) { for (var minorSpan = 1; minorSpan < UnivoxDefine.AxisSize - minor; minorSpan++) { var spanIndex = UnivoxUtil.GetIndex(minor + minorSpan, major + majorSpan); var chunkSpanIndex = GetChunkIndex(plane, minor + minorSpan, major + majorSpan); if (ShouldBreakPlane(plane, spanIndex, chunkSpanIndex, chunkIndex, subMat)) { break; } size = new int2(minorSpan, 0); } } else { for (var minorSpan = 0; minorSpan <= size.x; minorSpan++) { var spanIndex = UnivoxUtil.GetIndex(minor + minorSpan, major + majorSpan); var chunkSpanIndex = GetChunkIndex(plane, minor + minorSpan, major + majorSpan); if (ShouldBreakPlane(plane, spanIndex, chunkSpanIndex, chunkIndex, subMat)) { cantMerge = true; break; } } if (cantMerge) { break; } size = new int2(size.x, majorSpan); } } for (var majorSpan = 0; majorSpan <= size.y; majorSpan++) { for (var minorSpan = 0; minorSpan <= size.x; minorSpan++) { var spanIndex = UnivoxUtil.GetIndex(minor + minorSpan, major + majorSpan); plane.Inspected[spanIndex] = true; } } Data.Enqueue(new PlanarData() { Direction = plane.direction, Position = UnivoxUtil.GetPosition3(chunkIndex), Shape = Shapes[chunkIndex], Size = size, SubMaterial = subMat }); } } }
public static void SelectPlane(PlaneInfo plane) { Program.MenuManager.ChangeMenu(new SelectSeatOnPlaneMenu(plane.PlaneID)); }
public ReturnToBase(Actor self, Actor dest) { this.dest = dest; plane = self.Trait <Plane>(); planeInfo = self.Info.Traits.Get <PlaneInfo>(); }