public void OnConstructionComplete(Entity industryEntity, CargoStorageDB storage, Guid productionLine, IndustryJob batchJob, IConstrucableDesign designInfo) { var colonyConstruction = industryEntity.GetDataBlob <IndustryAbilityDB>(); batchJob.NumberCompleted++; batchJob.ResourcesRequired = designInfo.ResourceCosts; batchJob.ProductionPointsLeft = designInfo.IndustryPointCosts; if (batchJob.InstallOn != null) { ComponentInstance specificComponent = new ComponentInstance((ComponentDesign)designInfo); if (batchJob.InstallOn == industryEntity || StorageSpaceProcessor.HasEntity(storage, batchJob.InstallOn.GetDataBlob <CargoAbleTypeDB>())) { EntityManipulation.AddComponentToEntity(batchJob.InstallOn, specificComponent); ReCalcProcessor.ReCalcAbilities(batchJob.InstallOn); } } else { StorageSpaceProcessor.AddCargo(storage, (ComponentDesign)designInfo, 1); } if (batchJob.NumberCompleted == batchJob.NumberOrdered) { colonyConstruction.ProductionLines[productionLine].Jobs.Remove(batchJob); if (batchJob.Auto) { colonyConstruction.ProductionLines[productionLine].Jobs.Add(batchJob); } } }
public static void LaunchMissile(Entity launchingEntity, Entity targetEntity, MissileLauncherAtb launcherAtb, OrdnanceDesign missileDesign) { var atDatetime = launchingEntity.Manager.StarSysDateTime; var positionDB = launchingEntity.GetDataBlob <PositionDB>(); Vector3 position = positionDB.AbsolutePosition_m; var tgtEntityOrbit = targetEntity.GetDataBlob <OrbitDB>(); //MissileLauncherAtb launcherAtb; CargoStorageDB cargo = launchingEntity.GetDataBlob <CargoStorageDB>(); int numMis = (int)StorageSpaceProcessor.GetAmount(cargo, missileDesign); if (numMis < 1) { return; } double launchSpeed = launcherAtb.LaunchForce / missileDesign.Mass; //missileDesign. double burnTime = (missileDesign.WetMass - missileDesign.DryMass) / missileDesign.BurnRate; double dv = OrbitMath.TsiolkovskyRocketEquation(missileDesign.WetMass, missileDesign.DryMass, missileDesign.ExaustVelocity); double avgSpd = launchSpeed + dv * 0.5; var tgtEstPos = OrbitMath.GetInterceptPosition_m(position, avgSpd, tgtEntityOrbit, atDatetime); Vector3 parentVelocity = Entity.GetVelocity_m(launchingEntity, launchingEntity.Manager.StarSysDateTime); Vector3 tgtEstVector = tgtEstPos.position - position; //future target position Vector3 launchVelocity = parentVelocity + tgtEstVector; List <BaseDataBlob> dataBlobs = new List <BaseDataBlob>(); dataBlobs.Add((PositionDB)positionDB.Clone()); var newMissile = Entity.Create(launchingEntity.Manager, launchingEntity.FactionOwner, dataBlobs); foreach (var tuple in missileDesign.Components) { EntityManipulation.AddComponentToEntity(newMissile, tuple.design, tuple.count); } StorageSpaceProcessor.RemoveCargo(cargo, missileDesign, 1); var thrusting = new NewtonMoveDB(positionDB.Parent, launchVelocity); thrusting.ActionOnDateTime = atDatetime; thrusting.DeltaVForManuver_m = Vector3.Normalise(tgtEstPos.position) * dv; newMissile.SetDataBlob(thrusting); }
public void StorageSpaceProcessor_When_AskedToCheckIfItHasACargoTypeThatItDoesnotHave_Should_ReturnFalse() { var cookies = SetupCookieTradeGood(); var cookiePile = new CargoStorageDB(); var cookieCheck = new Dictionary <ICargoable, int> { { cookies, 1 } }; var hasCookies = StorageSpaceProcessor.HasRequiredItems(cookiePile, cookieCheck); Assert.IsFalse(hasCookies); }
public void StorageSpaceProcessor_When_AskedToCheckIfItHasCargoThatItHasMoreTHanEnoughOf_Should_ReturnTrue() { var cookies = SetupCookieTradeGood(); var cookiePile = new CargoStorageDB(); cookiePile.StoredCargoTypes.Add(cookies.CargoTypeID, new CargoTypeStore() { MaxCapacityKg = 9999999999999, FreeCapacityKg = 9999999999999 }); StorageSpaceProcessor.AddCargo(cookiePile, cookies, 99); var cookieCheck = new Dictionary <ICargoable, int> { { cookies, 7 } }; var hasCookies = StorageSpaceProcessor.HasRequiredItems(cookiePile, cookieCheck); Assert.IsTrue(hasCookies); }
public void Initalise(CargoStorageDB storageDB, Guid storageTypeID) { _storageDB = storageDB; TypeID = storageTypeID; CargoTypeSD cargoType = _dataStore.CargoTypes[TypeID]; TypeName = cargoType.Name; foreach (var itemKVP in StorageSpaceProcessor.GetResourcesOfCargoType(storageDB, TypeID)) { CargoItemVM cargoItem = new CargoItemVM(_gameVM, _storageDB, itemKVP.Key); TypeStore.Add(cargoItem); } if (_storageDB.StoredEntities.ContainsKey(TypeID)) { InitEntities(); } HeaderText = cargoType.Name + ": " + NetWeight.ToString() + " of " + MaxWeight.ToString() + " used, " + RemainingWeight.ToString() + " remaining"; _storageDB.OwningEntity.Manager.ManagerSubpulses.SystemDateChangedEvent += ManagerSubpulses_SystemDateChangedEvent; _storageDB.MinsAndMatsByCargoType[TypeID].CollectionChanged += _storageDB_CollectionChanged; _storageDB.StoredEntities.CollectionChanged += StoredEntities_CollectionChanged; }
internal static void ConsumeResources(CargoStorageDB fromCargo, ref IDictionary <Guid, int> toUse) { foreach (KeyValuePair <Guid, int> kvp in toUse.ToArray()) { ICargoable cargoItem = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key);//fromCargo.OwningEntity.Manager.Game.StaticData.GetICargoable(kvp.Key); Guid cargoTypeID = cargoItem.CargoTypeID; int amountUsedThisTick = 0; if (fromCargo.StoredCargoTypes.ContainsKey(cargoTypeID)) { if (fromCargo.StoredCargoTypes[cargoTypeID].ItemsAndAmounts.ContainsKey(cargoItem.ID)) { amountUsedThisTick = Math.Min((int)fromCargo.StoredCargoTypes[cargoTypeID].ItemsAndAmounts[cargoItem.ID].amount, kvp.Value); } } if (amountUsedThisTick > 0) { StorageSpaceProcessor.RemoveCargo(fromCargo, cargoItem, amountUsedThisTick); toUse[kvp.Key] -= amountUsedThisTick; } } }
public void StorageSpaceProcessor_When_AskedToCheckAvailableStorageSpace_Should_ReturnCorrectAnswerForTheRequestedCargoItem() { var rocks = SetupRockTradeGood(); var library = new CargoDefinitionsLibrary(); library.LoadOtherDefinitions(new List <ICargoable>() { rocks }); var rockPile = new CargoStorageDB(); rockPile.StoredCargoTypes.Add(rocks.CargoTypeID, new CargoTypeStore() { MaxCapacityKg = 35007, FreeCapacityKg = 32154 }); rockPile.StoredCargoTypes.Add(Guid.NewGuid(), new CargoTypeStore() { MaxCapacityKg = 99998, FreeCapacityKg = 99997 }); rockPile.StoredCargoTypes.Add(Guid.NewGuid(), new CargoTypeStore() { MaxCapacityKg = 99996, FreeCapacityKg = 99995 }); var canStoreThisManyItems = StorageSpaceProcessor.GetAvailableSpace(rockPile, rocks.ID, library); Assert.AreEqual(3215, canStoreThisManyItems.FreeCapacityItem); Assert.AreEqual(32154, canStoreThisManyItems.FreeCapacityKg); StorageSpaceProcessor.AddCargo(rockPile, rocks, 215); canStoreThisManyItems = StorageSpaceProcessor.GetAvailableSpace(rockPile, rocks.ID, library); Assert.AreEqual(3000, canStoreThisManyItems.FreeCapacityItem); Assert.AreEqual(30004, canStoreThisManyItems.FreeCapacityKg); }
public void StorageSpaceProcessor_When_AskedToCheckIfItHasASpecificItemThatItDoesnotHave_Should_ReturnFalse() { var cookies = SetupCookieTradeGood(); var biscuits = SetupCookieTradeGood(); biscuits.CargoTypeID = cookies.CargoTypeID; var cookiePile = new CargoStorageDB(); cookiePile.StoredCargoTypes.Add(cookies.CargoTypeID, new CargoTypeStore() { MaxCapacityKg = 9999999999999, FreeCapacityKg = 9999999999999 }); StorageSpaceProcessor.AddCargo(cookiePile, biscuits, 1); var cookieCheck = new Dictionary <ICargoable, int> { { cookies, 1 } }; var hasCookies = StorageSpaceProcessor.HasRequiredItems(cookiePile, cookieCheck); Assert.IsFalse(hasCookies); }
internal override void Display() { _isRunningFrame = true; if (IsActive) { SetFrameRateArray(); if (ImGui.Begin("debug", ref IsActive)) { ImGui.Text(_state.CurrentSystemDateTime.ToString()); ImGui.Text("Cursor World Coordinate:"); var mouseWorldCoord = _state.Camera.MouseWorldCoordinate(); ImGui.Text("x" + mouseWorldCoord.X); ImGui.SameLine(); ImGui.Text("y" + mouseWorldCoord.Y); if (ImGui.CollapsingHeader("FrameRates", ImGuiTreeNodeFlags.CollapsingHeader)) { //plot vars: (label, values, valueOffset, overlayText, scaleMin, scaleMax, graphSize, Stride) //core game processing rate. //ImGui.PlotHistogram("##GRHistogram", _gameRatesDisplay, 10, _timeSpan.TotalSeconds.ToString(), 0, 1f, new ImVec2(0, 80), sizeof(float)); //ImGui.PlotHistogram("##GRHistogram1", _gameRatesDisplay, 0 , _timeSpan.TotalSeconds.ToString(), 0, 1f, new ImVec2(0, 80), sizeof(float)); ImGui.PlotHistogram("Game Tick ##GTHistogram", _gameRates, _gameRateIndex, _currentGFPS.ToString(), 0f, largestGFPS, new ImVec2(248, 60), sizeof(float)); ImGui.PlotLines("Game Tick ##GTPlotlines", _gameRates, _gameRateIndex, _currentGFPS.ToString(), 0, largestGFPS, new ImVec2(248, 60), sizeof(float)); //current star system processing rate. ImGui.PlotHistogram("System Tick ##STHistogram", _systemRates, _systemRateIndex, _currentSFPS.ToString(), 0f, 1f, new ImVec2(248, 60), sizeof(float)); ImGui.PlotLines("System Tick ##STPlotlines", _systemRates, _systemRateIndex, _currentSFPS.ToString(), 0, 1, new ImVec2(248, 60), sizeof(float)); //ui framerate ImGui.PlotHistogram("Frame Rate ##FPSHistogram", _frameRates, _frameRateIndex, _currentFPS.ToString(), 0f, 10000, new ImVec2(248, 60), sizeof(float)); } if (_state.LastClickedEntity.Name != null) { if (ImGui.CollapsingHeader("Selected Entity: " + _state.LastClickedEntity.Name + "###NameHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Text(_state.LastClickedEntity.Entity.Guid.ToString()); if (_state.LastClickedEntity.Entity.HasDataBlob <PositionDB>()) { var positiondb = _state.LastClickedEntity.Entity.GetDataBlob <PositionDB>(); var posv4 = positiondb.AbsolutePosition_AU; ImGui.Text("x: " + posv4.X); ImGui.Text("y: " + posv4.Y); ImGui.Text("z: " + posv4.Z); if (positiondb.Parent != null) { ImGui.Text("Parent: " + positiondb.Parent.GetDataBlob <NameDB>().DefaultName); ImGui.Text("Dist: " + Distance.AuToKm(positiondb.RelativePosition_AU.Length())); } } if (_state.LastClickedEntity.Entity.HasDataBlob <OrbitDB>()) { if (ImGui.CollapsingHeader("OrbitDB: ###OrbitDBHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { OrbitDB orbitDB = _state.LastClickedEntity.Entity.GetDataBlob <OrbitDB>(); //if (_state.CurrentSystemDateTime != lastDate) //{ pos = OrbitProcessor.GetAbsolutePosition_AU(orbitDB, _state.CurrentSystemDateTime); truAnomoly = OrbitProcessor.GetTrueAnomaly(orbitDB, _state.CurrentSystemDateTime); lastDate = _state.CurrentSystemDateTime; //} ImGui.Text("x: " + pos.X); ImGui.Text("y: " + pos.Y); ImGui.Text("z: " + pos.Z); ImGui.Text("Eccentricity: " + orbitDB.Eccentricity); ImGui.Text("AoP:" + orbitDB.ArgumentOfPeriapsis); ImGui.Text("TrueAnomaly: " + truAnomoly); ImGui.Text("MeanMotion: " + orbitDB.MeanMotion); ImGui.Text("SOI Radius: " + Distance.AuToKm(GMath.GetSOI(_state.LastClickedEntity.Entity))); ImGui.Text("Orbital Period:" + orbitDB.OrbitalPeriod); ImGui.Text("SemiMajAxis: " + orbitDB.SemiMajorAxis); if (orbitDB.Parent != null) { ImGui.Text("Parent: " + orbitDB.Parent.GetDataBlob <NameDB>().DefaultName); } if (orbitDB.Children.Count > 0) { foreach (var item in orbitDB.Children) { ImGui.Text(item.GetDataBlob <NameDB>().DefaultName); } } } } if (_state.LastClickedEntity.OrbitIcon != null) { if (ImGui.CollapsingHeader("OrbitIcon: ###OrbitIconHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { OrbitDB orbitDB = _state.LastClickedEntity.Entity.GetDataBlob <OrbitDB>(); string startRadian = _state.LastClickedEntity.OrbitIcon._ellipseStartArcAngleRadians.ToString(); string startDegrees = Angle.ToDegrees(_state.LastClickedEntity.OrbitIcon._ellipseStartArcAngleRadians).ToString(); ImGui.Text("StartAngleRadians: " + startRadian); ImGui.Text("StartAngleDegrees: " + startDegrees); } } if (_state.LastClickedEntity.Entity.HasDataBlob <PropulsionDB>()) { if (ImGui.CollapsingHeader("Propulsion: ###PropulsionHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { PropulsionDB propulsionDB = _state.LastClickedEntity.Entity.GetDataBlob <PropulsionDB>(); ImGui.Text("NonNewt Engine Power: " + propulsionDB.TotalEnginePower); ImGui.Text("Max Speed: " + propulsionDB.MaximumSpeed_MS); ImGui.Text("CurrentVector: " + propulsionDB.CurrentVectorMS); ImGui.Text("Current Speed: " + Vector4.Magnitude(propulsionDB.CurrentVectorMS)); if (_state.LastClickedEntity.Entity.HasDataBlob <CargoStorageDB>()) { var fuelsGuid = propulsionDB.FuelUsePerKM; var storage = _state.LastClickedEntity.Entity.GetDataBlob <CargoStorageDB>(); foreach (var fuelItemGuid in fuelsGuid.Keys) { var fuel = _state.Game.StaticData.GetICargoable(fuelItemGuid); ImGui.Text(fuel.Name); ImGui.SameLine(); ImGui.Text(StorageSpaceProcessor.GetAmount(storage, fuel).ToString()); } } } if (_state.LastClickedEntity.Entity.HasDataBlob <TranslateMoveDB>()) { var db = _state.LastClickedEntity.Entity.GetDataBlob <TranslateMoveDB>(); if (ImGui.CollapsingHeader("Transit: ###TransitHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Text("EntryPoint " + db.TranslateEntryPoint_AU); ImGui.Text("ExitPoint " + db.TranslationExitPoint_AU); ImGui.Text("EDA " + db.PredictedExitTime.ToString()); double distance = Distance.DistanceBetween(db.TranslateEntryPoint_AU, db.TranslationExitPoint_AU); ImGui.Text("Distance " + distance + " AU"); ImGui.SameLine(); double distancekm = Distance.AuToKm(distance); ImGui.Text(distancekm.ToString() + " KM"); var timeToTarget = db.PredictedExitTime - _state.CurrentSystemDateTime; ImGui.Text("Remaining TTT " + timeToTarget); var totalTime = db.PredictedExitTime - db.EntryDateTime; ImGui.Text("Total TTT " + totalTime); double speed = ((distancekm * 1000) / totalTime.TotalSeconds); ImGui.Text("speed2 " + speed); ImGui.Text("LastDateTime: "); ImGui.Text(db.LastProcessDateTime.ToString()); ImGui.Text("Time Since Last: "); var timelen = _state.CurrentSystemDateTime - db.LastProcessDateTime; ImGui.Text(timelen.ToString()); } } } } } } //else IsActive = false; ImGui.End(); } _isRunningFrame = false; _dateChangeSinceLastFrame = false; }
internal override void Display() { _isRunningFrame = true; if (IsActive) { SetFrameRateArray(); if (ImGui.Begin("debug", ref IsActive)) { ImGui.Text(_state.PrimarySystemDateTime.ToString()); ImGui.Text("Cursor World Coordinate:"); var mouseWorldCoord = _state.Camera.MouseWorldCoordinate(); ImGui.Text("x" + mouseWorldCoord.X); ImGui.SameLine(); ImGui.Text("y" + mouseWorldCoord.Y); if (ImGui.CollapsingHeader("FrameRates", ImGuiTreeNodeFlags.CollapsingHeader)) { //plot vars: (label, values, valueOffset, overlayText, scaleMin, scaleMax, graphSize, Stride) //core game processing rate. //ImGui.PlotHistogram("##GRHistogram", _gameRatesDisplay, 10, _timeSpan.TotalSeconds.ToString(), 0, 1f, new ImVec2(0, 80), sizeof(float)); //ImGui.PlotHistogram("##GRHistogram1", _gameRatesDisplay, 0 , _timeSpan.TotalSeconds.ToString(), 0, 1f, new ImVec2(0, 80), sizeof(float)); //string label, ref float values... //ImGui.PlotHistogram( ImGui.PlotHistogram("Game Tick ##GTHistogram", ref _gameRates[0], _gameRates.Length, _gameRateIndex, _currentGFPS.ToString(), 0f, largestGFPS, new Vector2(248, 60), sizeof(float)); ImGui.PlotLines("Game Tick ##GTPlotlines", ref _gameRates[0], _gameRates.Length, _gameRateIndex, _currentGFPS.ToString(), 0, largestGFPS, new Vector2(248, 60), sizeof(float)); //current star system processing rate. ImGui.PlotHistogram("System Tick ##STHistogram", ref _systemRates[0], _systemRates.Length, _systemRateIndex, _currentSFPS.ToString(), 0f, 1f, new Vector2(248, 60), sizeof(float)); ImGui.PlotLines("System Tick ##STPlotlines", ref _systemRates[0], _systemRates.Length, _systemRateIndex, _currentSFPS.ToString(), 0, 1, new Vector2(248, 60), sizeof(float)); //ui framerate ImGui.PlotHistogram("Frame Rate ##FPSHistogram", ref _frameRates[0], _frameRates.Length, _frameRateIndex, _currentFPS.ToString(), 0f, 10000, new Vector2(248, 60), sizeof(float)); foreach (var item in _systemState.StarSystem.ManagerSubpulses.ProcessTime) { ImGui.Text(item.Key.Name); ImGui.SameLine(); ImGui.Text(item.Value.ToString()); } } if (ImGui.CollapsingHeader("GraphicTests", ImGuiTreeNodeFlags.CollapsingHeader)) { var window = GraphicDebugWindow.GetWindow(_state); window.Display(); window.Enable(true, _state); } ImGui.Text("Selected Star System: " + _state.SelectedStarSysGuid); ImGui.Text("Number Of Entites: " + _state.SelectedSystem.NumberOfEntites); if (ImGui.CollapsingHeader("Log")) { ImGui.BeginChild("LogChild", new Vector2(800, 300), true); ImGui.Columns(4, "Events", true); ImGui.Text("DateTime"); ImGui.NextColumn(); ImGui.Text("Faction"); ImGui.NextColumn(); ImGui.Text("Entity"); ImGui.NextColumn(); ImGui.Text("Event Message"); ImGui.NextColumn(); foreach (var gameEvent in StaticRefLib.EventLog.GetAllEvents()) { string entityStr = ""; if (gameEvent.Entity != null) { if (gameEvent.Entity.HasDataBlob <NameDB>()) { entityStr = gameEvent.Entity.GetDataBlob <NameDB>().DefaultName; } else { entityStr = gameEvent.Entity.Guid.ToString(); } } string factionStr = ""; if (gameEvent.Faction != null) { if (gameEvent.Faction.HasDataBlob <NameDB>()) { factionStr = gameEvent.Faction.GetDataBlob <NameDB>().DefaultName; } else { factionStr = gameEvent.Faction.Guid.ToString(); } } ImGui.Separator(); ImGui.Text(gameEvent.Time.ToString()); ImGui.NextColumn(); ImGui.Text(factionStr); ImGui.NextColumn(); ImGui.Text(entityStr); ImGui.NextColumn(); ImGui.TextWrapped(gameEvent.Message); ImGui.NextColumn(); } //ImGui.Separator(); //ImGui.Columns(); ImGui.EndChild(); } if (ImGui.CollapsingHeader("Entity List")) { List <Entity> factionOwnedEntites = _state.SelectedSystem.GetEntitiesByFaction(_state.Faction.Guid); List <string> entityNames = new List <string>(); foreach (var entity in factionOwnedEntites) { var name = entity.GetDataBlob <NameDB>(); if (name != null) { entityNames.Add(name.GetName(_state.Faction.Guid)); } } int item = 0; ImGui.ListBox("Entites", ref item, entityNames.ToArray(), entityNames.Count); } if (_selectedEntityState != null && _selectedEntityState.Name != null && _selectedEntity.IsValid) { if (ImGui.CollapsingHeader("Selected Entity: " + _state.LastClickedEntity.Name + "###NameHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Text(_state.LastClickedEntity.Entity.Guid.ToString()); if (_selectedEntity.HasDataBlob <PositionDB>()) { var positiondb = _selectedEntity.GetDataBlob <PositionDB>(); var posv4 = positiondb.AbsolutePosition_AU; ImGui.Text("x: " + posv4.X); ImGui.Text("y: " + posv4.Y); ImGui.Text("z: " + posv4.Z); if (positiondb.Parent != null) { ImGui.Text("Parent: " + positiondb.Parent.GetDataBlob <NameDB>().DefaultName); ImGui.Text("Dist: " + Distance.AuToKm(positiondb.RelativePosition_AU.Length())); } } if (_selectedEntity.HasDataBlob <MassVolumeDB>()) { if (ImGui.CollapsingHeader("MassVolumeDB: ###MassVolDBHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { MassVolumeDB mvdb = _selectedEntity.GetDataBlob <MassVolumeDB>(); ImGui.Text("Mass " + mvdb.Mass + "Kg"); ImGui.Text("Volume " + mvdb.Volume + "Km^3"); ImGui.Text("Density " + mvdb.Density + "g/cm^3"); ImGui.Text("Radius " + mvdb.Radius + "Km"); } } if (_selectedEntity.HasDataBlob <OrbitDB>()) { if (ImGui.Checkbox("Draw SOI", ref _drawSOI)) { SimpleCircle cir; if (_drawSOI) { var soiradius = OrbitProcessor.GetSOI(_selectedEntity); var colour = new SDL2.SDL.SDL_Color() { r = 0, g = 255, b = 0, a = 100 }; cir = new SimpleCircle(_selectedEntity.GetDataBlob <PositionDB>(), soiradius, colour); _state.SelectedSysMapRender.UIWidgets.Add(nameof(cir), cir); } else { _state.SelectedSysMapRender.UIWidgets.Remove(nameof(cir)); } } if (ImGui.CollapsingHeader("OrbitDB: ###OrbitDBHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { OrbitDB orbitDB = _selectedEntity.GetDataBlob <OrbitDB>(); //if (_state.CurrentSystemDateTime != lastDate) //{ pos = OrbitProcessor.GetAbsolutePosition_AU(orbitDB, _state.PrimarySystemDateTime); truAnomoly = OrbitProcessor.GetTrueAnomaly(orbitDB, _state.PrimarySystemDateTime); lastDate = _state.PrimarySystemDateTime; //} ImGui.Text("x: " + pos.X); ImGui.Text("y: " + pos.Y); ImGui.Text("z: " + pos.Z); ImGui.Text("Eccentricity: " + orbitDB.Eccentricity); ImGui.Text("AoP:" + orbitDB.ArgumentOfPeriapsis); ImGui.Text("TrueAnomaly: " + truAnomoly); ImGui.Text("MeanMotion: " + orbitDB.MeanMotion + " in Deg/s"); ImGui.Text("MeanVelocity: " + OrbitMath.MeanOrbitalVelocityInAU(orbitDB) + "Au/s"); ImGui.Text("MeanVelocity: " + Distance.AuToKm(OrbitMath.MeanOrbitalVelocityInAU(orbitDB)) + "Km/s"); ImGui.Text("SOI Radius: " + Distance.AuToKm(OrbitProcessor.GetSOI(_state.LastClickedEntity.Entity))); ImGui.Text("Orbital Period:" + orbitDB.OrbitalPeriod); ImGui.Text("SemiMajAxis: " + orbitDB.SemiMajorAxis); ImGui.Text("Periapsis: " + Distance.AuToKm(orbitDB.Periapsis).ToString("g3") + " Km"); ImGui.Text("Appoapsis: " + Distance.AuToKm(orbitDB.Apoapsis).ToString("g3") + " Km"); if (orbitDB.Parent != null) { ImGui.Text("Parent: " + orbitDB.Parent.GetDataBlob <NameDB>().DefaultName); } if (orbitDB.Children.Count > 0) { foreach (var item in orbitDB.Children) { ImGui.Text(item.GetDataBlob <NameDB>().DefaultName); } } } } if (_selectedEntity.HasDataBlob <NewtonMoveDB>()) { if (ImGui.Checkbox("Draw Parent SOI", ref _drawParentSOI)) { SimpleCircle psoi; SimpleLine psoilin; if (_drawParentSOI) { var myPos = _selectedEntity.GetDataBlob <PositionDB>(); var parent = myPos.Parent; var pObt = parent.GetDataBlob <OrbitDB>(); var cnmve = _selectedEntity.GetDataBlob <NewtonMoveDB>(); var soiradius = OrbitProcessor.GetSOI(parent); var colour = new SDL2.SDL.SDL_Color() { r = 0, g = 255, b = 0, a = 100 }; psoi = new SimpleCircle(parent.GetDataBlob <PositionDB>(), soiradius, colour); var pmass = parent.GetDataBlob <MassVolumeDB>().Mass; var mymass = _selectedEntity.GetDataBlob <MassVolumeDB>().Mass; var sgp = GameConstants.Science.GravitationalConstant * (pmass + mymass) / 3.347928976e33; var vel = Distance.KmToAU(cnmve.CurrentVector_kms); var cpos = myPos.RelativePosition_AU; var eccentVector = OrbitMath.EccentricityVector(sgp, cpos, vel); double ce = eccentVector.Length(); var r = cpos.Length(); var v = vel.Length(); var ca = 1 / (2 / r - Math.Pow(v, 2) / sgp); var cp = EllipseMath.SemiLatusRectum(ca, ce); var cAoP = Math.Atan2(eccentVector.Y, eccentVector.X); /* * var pa = pObt.SemiMajorAxis; * var pe = pObt.Eccentricity; * var pp = EllipseMath.SemiLatusRectum(pa, pe); */ double θ = OrbitMath.AngleAtRadus(soiradius, cp, ce); θ += cAoP; var x = soiradius * Math.Cos(θ); var y = soiradius * Math.Sin(θ); psoilin = new SimpleLine(parent.GetDataBlob <PositionDB>(), new PointD() { X = x, Y = y }, colour); _state.SelectedSysMapRender.UIWidgets.Add(nameof(psoi), psoi); _state.SelectedSysMapRender.UIWidgets.Add(nameof(psoilin), psoilin); } else { _state.SelectedSysMapRender.UIWidgets.Remove(nameof(psoi)); _state.SelectedSysMapRender.UIWidgets.Remove(nameof(psoilin)); } } } if (_state.LastClickedEntity.OrbitIcon != null) { if (ImGui.CollapsingHeader("OrbitIcon: ###OrbitIconHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { OrbitDB orbitDB = _selectedEntity.GetDataBlob <OrbitDB>(); //string startRadian = _state.LastClickedEntity.OrbitIcon._ellipseStartArcAngleRadians.ToString(); //string startDegrees = Angle.ToDegrees(_state.LastClickedEntity.OrbitIcon._ellipseStartArcAngleRadians).ToString(); //ImGui.Text("StartAngleRadians: " + startRadian); //ImGui.Text("StartAngleDegrees: " + startDegrees); if (ImGui.CollapsingHeader("OrbitIconLines", ImGuiTreeNodeFlags.CollapsingHeader)) { var window = OrbitalDebugWindow.GetWindow(_state.LastClickedEntity); window.Display(); window.Enable(true, _state); } } } if (_selectedEntity.HasDataBlob <PropulsionAbilityDB>()) { if (ImGui.CollapsingHeader("Propulsion: ###PropulsionHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { PropulsionAbilityDB propulsionDB = _selectedEntity.GetDataBlob <PropulsionAbilityDB>(); ImGui.Text("NonNewt Engine Power: " + propulsionDB.TotalEnginePower); ImGui.Text("Max Speed: " + propulsionDB.MaximumSpeed_MS); ImGui.Text("CurrentVector: " + propulsionDB.CurrentVectorMS); ImGui.Text("Current Speed: " + ECSLib.Vector3.Magnitude(propulsionDB.CurrentVectorMS)); if (_state.LastClickedEntity.Entity.HasDataBlob <CargoStorageDB>()) { var fuelsGuid = propulsionDB.FuelUsePerKM; var storage = _state.LastClickedEntity.Entity.GetDataBlob <CargoStorageDB>(); foreach (var fuelItemGuid in fuelsGuid.Keys) { var fuel = _state.Game.StaticData.GetICargoable(fuelItemGuid); ImGui.Text(fuel.Name); ImGui.SameLine(); ImGui.Text(StorageSpaceProcessor.GetAmount(storage, fuel).ToString()); } } } if (_state.LastClickedEntity.Entity.HasDataBlob <TranslateMoveDB>()) { var db = _state.LastClickedEntity.Entity.GetDataBlob <TranslateMoveDB>(); if (ImGui.CollapsingHeader("Transit: ###TransitHeader", ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Text("EntryPoint " + db.TranslateEntryPoint_AU); ImGui.Text("ExitPoint " + db.TranslateExitPoint_AU); ImGui.Text("EDA " + db.PredictedExitTime.ToString()); double distance = Distance.DistanceBetween(db.TranslateEntryPoint_AU, db.TranslateExitPoint_AU); ImGui.Text("Distance " + distance + " AU"); ImGui.SameLine(); double distancekm = Distance.AuToKm(distance); ImGui.Text(distancekm.ToString() + " KM"); var timeToTarget = db.PredictedExitTime - _state.PrimarySystemDateTime; ImGui.Text("Remaining TTT " + timeToTarget); var totalTime = db.PredictedExitTime - db.EntryDateTime; ImGui.Text("Total TTT " + totalTime); double speed = ((distancekm * 1000) / totalTime.TotalSeconds); ImGui.Text("speed2 " + speed); ImGui.Text("LastDateTime: "); ImGui.Text(db.LastProcessDateTime.ToString()); ImGui.Text("Time Since Last: "); var timelen = _state.PrimarySystemDateTime - db.LastProcessDateTime; ImGui.Text(timelen.ToString()); } } } if (_selectedEntity.HasDataBlob <SensorInfoDB>()) { var actualEntity = _selectedEntity.GetDataBlob <SensorInfoDB>().DetectedEntity; if (actualEntity.IsValid && actualEntity.HasDataBlob <AsteroidDamageDB>()) { var dmgDB = actualEntity.GetDataBlob <AsteroidDamageDB>(); ImGui.Text("Remaining HP: " + dmgDB.Health.ToString()); } } } } } //else IsActive = false; ImGui.End(); } _isRunningFrame = false; _dateChangeSinceLastFrame = false; }