public OrbitIconBase(EntityState entityState, List <List <UserOrbitSettings> > settings) : base(entityState.Entity.GetDataBlob <PositionDB>()) { BodyType = entityState.BodyType; entityState.OrbitIcon = this; _mgr = entityState.Entity.Manager; _userOrbitSettingsMtx = settings; _orbitDB = entityState.Entity.GetDataBlob <OrbitDB>(); if (entityState.Entity.HasDataBlob <OrbitUpdateOftenDB>()) { _orbitDB = entityState.Entity.GetDataBlob <OrbitUpdateOftenDB>(); } BodyPositionDB = entityState.Position; //entityState.Entity.GetDataBlob<PositionDB>(); if (_orbitDB.Parent == null) //primary star { _positionDB = BodyPositionDB; } else { _positionDB = _orbitDB.Parent.GetDataBlob <PositionDB>(); //orbit's position is parent's body position. } SemiMaj = (float)_orbitDB.SemiMajorAxis_AU; SemiMinor = (float)EllipseMath.SemiMinorAxis(_orbitDB.SemiMajorAxis_AU, _orbitDB.Eccentricity); _linearEccentricity = (float)(_orbitDB.Eccentricity * _orbitDB.SemiMajorAxis_AU); //linear ecentricity if (_orbitDB.Inclination_Degrees > 90 && _orbitDB.Inclination_Degrees < 270) //orbitDB is in degrees. { IsRetrogradeOrbit = true; //_loP_Degrees = (float)(_orbitDB.LongitudeOfAscendingNode - _orbitDB.ArgumentOfPeriapsis); } /* * else * { * * _loP_Degrees = (float)(_orbitDB.LongitudeOfAscendingNode + _orbitDB.ArgumentOfPeriapsis); * } * _loP_radians = (float)(Angle.ToRadians(_loP_Degrees)); */ var i = _orbitDB.Inclination; var _aoP = _orbitDB.ArgumentOfPeriapsis; var loan = _orbitDB.LongitudeOfAscendingNode; var lop = OrbitMath.GetLongditudeOfPeriapsis(i, _aoP, loan); _loP_radians = (float)lop; _loP_Degrees = (float)Angle.ToDegrees(lop); }
public NameIcon(EntityState entityState, GlobalUIState state) : base(entityState.Entity.GetDataBlob <PositionDB>()) { _state = state; _entityGuid = entityState.Entity.Guid; StarSystem starsys = (StarSystem)entityState.Entity.Manager; _starSysGuid = starsys.Guid; _nameDB = entityState.Entity.GetDataBlob <NameDB>(); NameString = _nameDB.GetName(state.Faction); entityState.Name = NameString; entityState.NameIcon = this; _bodyType = entityState.BodyType; }
void SetBodyType() { if (Entity.HasDataBlob <SystemBodyInfoDB>()) { switch (Entity.GetDataBlob <SystemBodyInfoDB>().BodyType) { case ECSLib.BodyType.Asteroid: { BodyType = UserOrbitSettings.OrbitBodyType.Asteroid; break; } case ECSLib.BodyType.Comet: { BodyType = UserOrbitSettings.OrbitBodyType.Comet; break; } case ECSLib.BodyType.DwarfPlanet: case ECSLib.BodyType.GasDwarf: case ECSLib.BodyType.GasGiant: case ECSLib.BodyType.IceGiant: case ECSLib.BodyType.Terrestrial: { BodyType = UserOrbitSettings.OrbitBodyType.Planet; break; } case ECSLib.BodyType.Moon: { BodyType = UserOrbitSettings.OrbitBodyType.Moon; break; } default: break; } } if (Entity.HasDataBlob <StarInfoDB>()) { BodyType = UserOrbitSettings.OrbitBodyType.Star; } if (Entity.HasDataBlob <ShipInfoDB>()) { BodyType = UserOrbitSettings.OrbitBodyType.Ship; } }
public OrbitIconBase(EntityState entityState, List <List <UserOrbitSettings> > settings) : base(entityState.Entity.GetDataBlob <PositionDB>()) { BodyType = entityState.BodyType; entityState.OrbitIcon = this; _mgr = entityState.Entity.Manager; _userOrbitSettingsMtx = settings; _orbitDB = entityState.Entity.GetDataBlob <OrbitDB>(); BodyPositionDB = entityState.Position; //entityState.Entity.GetDataBlob<PositionDB>(); if (_orbitDB.Parent == null) //primary star { _positionDB = BodyPositionDB; } else { _positionDB = _orbitDB.Parent.GetDataBlob <PositionDB>(); //orbit's position is parent's body position. } SemiMaj = (float)_orbitDB.SemiMajorAxis; SemiMinor = (float)EllipseMath.SemiMinorAxis(_orbitDB.SemiMajorAxis, _orbitDB.Eccentricity); _linearEccentricity = (float)(_orbitDB.Eccentricity * _orbitDB.SemiMajorAxis); //linear ecentricity /* * if (_orbitDB.Inclination > 90 && _orbitDB.Inclination < 270) //orbitDB is in degrees. * { * IsClockwiseOrbit = false; * _loP_Degrees = (float)(_orbitDB.LongitudeOfAscendingNode - _orbitDB.ArgumentOfPeriapsis); * } * else * { * * _loP_Degrees = (float)(_orbitDB.LongitudeOfAscendingNode + _orbitDB.ArgumentOfPeriapsis); * } * _loP_radians = (float)(Angle.ToRadians(_loP_Degrees)); */ var i = Angle.ToRadians(_orbitDB.Inclination); var aop = Angle.ToRadians(_orbitDB.ArgumentOfPeriapsis); var loan = Angle.ToRadians(_orbitDB.LongitudeOfAscendingNode); var lop = OrbitMath.GetLongditudeOfPeriapsis(i, aop, loan); _loP_radians = (float)lop; _loP_Degrees = (float)Angle.ToDegrees(lop); }
internal override void Display() { if (IsActive) { Vector2 size = new Vector2(200, 100); Vector2 pos = new Vector2(0, 0); ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver); ImGui.SetNextWindowPos(pos, ImGuiCond.Appearing); if (ImGui.Begin("Settings", ref IsActive, _flags)) { ImGui.Checkbox("Show Pulsar Debug Window", ref DebugWindow.GetInstance().IsActive); ImGui.Checkbox("Show ImguiMetrix", ref _state.ShowMetrixWindow); ImGui.Checkbox("Show ImgDebug", ref _state.ShowImgDbg); ImGui.Checkbox("DemoWindow", ref _state.ShowDemoWindow); if (ImGui.Checkbox("DamageWindow", ref _state.ShowDamageWindow)) { if (_state.ShowDamageWindow) { DamageViewer.GetInstance().IsActive = true; } else { DamageViewer.GetInstance().IsActive = false; } } if (ImGui.CollapsingHeader("Process settings", _xpanderFlags)) { if (ImGui.Checkbox("MultiThreaded", ref IsThreaded)) { _state.Game.Settings.EnableMultiThreading = IsThreaded; } if (ImGui.Checkbox("Translate Uses Ralitive Velocity", ref RalitiveOrbitVelocity)) { ECSLib.OrbitProcessor.UseRalitiveVelocity = RalitiveOrbitVelocity; } if (ImGui.IsItemHovered()) { if (RalitiveOrbitVelocity) { ImGui.SetTooltip("Ships exiting from a non newtonion translation will enter an orbit: \n Using a vector ralitive to it's origin parent"); } else { ImGui.SetTooltip("Ships exiting from a non newtonion translation will enter an orbit: \n Using the absolute Vector (ie raltive to the root'sun'"); } } } if (ImGui.CollapsingHeader("Map Settings", _xpanderFlags)) { for (int i = 0; i < (int)UserOrbitSettings.OrbitBodyType.NumberOf; i++) { UserOrbitSettings.OrbitBodyType otype = (UserOrbitSettings.OrbitBodyType)i; string typeStr = otype.ToString(); if (ImGui.TreeNode(typeStr)) { float _nameZoomLevel = _state.DrawNameZoomLvl[(int)otype]; ImGui.SliderFloat("Draw Names at Zoom: ", ref _nameZoomLevel, 0.01f, 10000f); _state.DrawNameZoomLvl[(int)otype] = _nameZoomLevel; for (int j = 0; j < (int)UserOrbitSettings.OrbitTrajectoryType.NumberOf; j++) { UserOrbitSettings.OrbitTrajectoryType trtype = (UserOrbitSettings.OrbitTrajectoryType)j; string trtypeStr = trtype.ToString(); if (ImGui.TreeNode(trtypeStr)) { UserOrbitSettings _userOrbitSettings = _userOrbitSettingsMtx[i][j]; int _arcSegments = _userOrbitSettings.NumberOfArcSegments; Vector3 _colour = Helpers.Color(_userOrbitSettings.Red, _userOrbitSettings.Grn, _userOrbitSettings.Blu); int _maxAlpha = _userOrbitSettings.MaxAlpha; int _minAlpha = _userOrbitSettings.MinAlpha; //TODO: make this a knob/dial? need to create a custom control: https://github.com/ocornut/imgui/issues/942 if (ImGui.SliderAngle("Sweep Angle ##" + i + j, ref _userOrbitSettings.EllipseSweepRadians, 1f, 360f)) { _state.SelectedSysMapRender.UpdateUserOrbitSettings(); } if (ImGui.SliderInt("Number Of Segments ##" + i + j, ref _arcSegments, 1, 255, _userOrbitSettings.NumberOfArcSegments.ToString())) { _userOrbitSettings.NumberOfArcSegments = (byte)_arcSegments; _state.SelectedSysMapRender.UpdateUserOrbitSettings(); } if (ImGui.ColorEdit3("Orbit Ring Colour ##" + i + j, ref _colour)) { _userOrbitSettings.Red = Helpers.Color(_colour.X); _userOrbitSettings.Grn = Helpers.Color(_colour.Y); _userOrbitSettings.Blu = Helpers.Color(_colour.Z); } if (ImGui.SliderInt("Max Alpha ##" + i + j, ref _maxAlpha, _minAlpha, 255, "")) { _userOrbitSettings.MaxAlpha = (byte)_maxAlpha; _state.SelectedSysMapRender.UpdateUserOrbitSettings(); } if (ImGui.SliderInt("Min Alpha ##" + i + j, ref _minAlpha, 0, _maxAlpha, "")) { _userOrbitSettings.MinAlpha = (byte)_minAlpha; _state.SelectedSysMapRender.UpdateUserOrbitSettings(); } } } ImGui.TreePop(); } } } } ImGui.End(); } }