/// <summary> /// Creates a star entity in the system. /// Does not initialize an orbit. /// </summary> public Entity CreateStar(StarSystem system, double mass, double radius, double age, string starClass, double temperature, float luminosity, SpectralType spectralType, string starName = null) { double tempRange = temperature / _galaxyGen.Settings.StarTemperatureBySpectralType[spectralType].Max; // temp range from 0 to 1. ushort subDivision = (ushort)Math.Round((1 - tempRange) * 10); LuminosityClass luminosityClass = LuminosityClass.V; if (starName == null) { starName = system.NameDB.DefaultName; } int starIndex = system.GetAllEntitiesWithDataBlob <StarInfoDB>().Count; starName += " " + (char)('A' + starIndex) + " " + spectralType + subDivision + luminosityClass; MassVolumeDB starMassVolumeDB = MassVolumeDB.NewFromMassAndRadius(mass, radius); StarInfoDB starInfoDB = new StarInfoDB { Age = age, Class = starClass, Luminosity = luminosity, SpectralType = spectralType, Temperature = temperature, LuminosityClass = luminosityClass, SpectralSubDivision = subDivision }; PositionDB starPositionDB = new PositionDB(new Vector3(0, 0, 0), system.Guid); NameDB starNameDB = new NameDB(starName); OrbitDB starOrbitDB = new OrbitDB(); SensorProfileDB emmisionSignature = SensorProcessorTools.SetStarEmmisionSig(starInfoDB, starMassVolumeDB); return(new Entity(system, new List <BaseDataBlob> { starOrbitDB, starMassVolumeDB, starInfoDB, starNameDB, starPositionDB, emmisionSignature })); }
/// <summary> /// creates an asteroid that will collide with the given entity on the given date. /// </summary> /// <param name="starSys"></param> /// <param name="target"></param> /// <param name="collisionDate"></param> /// <returns></returns> public static Entity CreateAsteroid(StarSystem starSys, Entity target, DateTime collisionDate, double asteroidMass = -1.0) { //todo rand these a bit. double radius = Distance.KmToAU(0.5); double mass; if (asteroidMass == -1.0) { mass = 1.5e+12; //about 1.5 billion tonne } else { mass = asteroidMass; } Vector3 velocity = new Vector3(8, 7, 0); var position = new PositionDB(0, 0, 0, Guid.Empty); var massVolume = MassVolumeDB.NewFromMassAndRadius(mass, radius); var planetInfo = new SystemBodyInfoDB(); var balisticTraj = new NewtonBalisticDB(target.Guid, collisionDate); var name = new NameDB("Ellie"); var AsteroidDmg = new AsteroidDamageDB(); var sensorPfil = new SensorProfileDB(); planetInfo.SupportsPopulations = false; planetInfo.BodyType = BodyType.Asteroid; Vector3 targetPos = OrbitProcessor.GetAbsolutePosition_AU(target.GetDataBlob <OrbitDB>(), collisionDate); TimeSpan timeToCollision = collisionDate - StaticRefLib.CurrentDateTime; Vector3 offset = velocity * timeToCollision.TotalSeconds; targetPos -= Distance.KmToAU(offset); position.AbsolutePosition_AU = targetPos; position.SystemGuid = starSys.Guid; balisticTraj.CurrentSpeed = velocity; var planetDBs = new List <BaseDataBlob> { position, massVolume, planetInfo, name, balisticTraj, AsteroidDmg, sensorPfil }; Entity newELE = new Entity(starSys, planetDBs); return(newELE); }
private static ProtoEntity CreateSurveyPoint(double x, double y, int nameNumber) { // TODO: Rebalance "pointsRequired" here. // TODO: Load "pointsRequired" from GalaxyGen settings const int pointsRequired = 400; var surveyDB = new JPSurveyableDB(pointsRequired, new Dictionary <Entity, int>(), 10000000); var posDB = new PositionDB(x, y, 0, Guid.Empty); var nameDB = new NameDB($"Survey Point #{nameNumber}"); //for testing purposes var sensorProfileDB = new SensorProfileDB(); return(ProtoEntity.Create(Guid.Empty, new BaseDataBlob[] { surveyDB, posDB, nameDB, sensorProfileDB })); }
/// <summary> /// returns a dictionary of all emmisions including reflected emmisions. /// </summary> /// <returns>The for distance.</returns> /// <param name="emission">Emission.</param> /// <param name="distance">Distance.</param> internal static Dictionary <EMWaveForm, double> AttenuatedForDistance(SensorProfileDB emission, double distance) { var dict = new Dictionary <EMWaveForm, double>(); foreach (var emitedItem in emission.EmittedEMSpectra) { var powerAtDistance = AttenuationCalc(emitedItem.Value, distance); dict.Add(emitedItem.Key, powerAtDistance); } foreach (var reflectedItem in emission.ReflectedEMSpectra) { var reflectedValue = AttenuationCalc(reflectedItem.Value, distance); dict.Add(reflectedItem.Key, reflectedValue); } return(dict); }
/// <summary> /// probibly only needs to be done at entity creation, once the bodies mass is set. /// </summary> /// <returns>The emmision sig.</returns> /// <param name="sysBodyInfoDB">Sys body info db.</param> /// <param name="massVolDB">Mass vol db.</param> internal static void PlanetEmmisionSig(SensorProfileDB profile, SystemBodyInfoDB sysBodyInfoDB, MassVolumeDB massVolDB) { var tempDegreesC = sysBodyInfoDB.BaseTemperature; var kelvin = tempDegreesC + 273.15; var wavelength = 2.9 * Math.Pow(10, 6) / kelvin; var magnitude = tempDegreesC / massVolDB.Volume; EMWaveForm waveform = new EMWaveForm() { WavelengthAverage_nm = wavelength, WavelengthMin_nm = wavelength - 400, //4k angstrom, semi arbitrary number pulled outa my ass from 0min of internet research. WavelengthMax_nm = wavelength + 600 }; profile.EmittedEMSpectra.Add(waveform, magnitude);//TODO this may need adjusting to make good balanced detections. profile.Reflectivity = sysBodyInfoDB.Albedo; }
internal static void DetectEntites(SensorReceverAtbDB receverDB, Entity detectableEntity, DateTime atDate) { Entity receverFaction = receverDB.OwningEntity.GetDataBlob <OwnedDB>().OwnedByFaction; var knownContacts = receverFaction.GetDataBlob <FactionInfoDB>().SensorEntites; SensorProfileDB sensorProfile = detectableEntity.GetDataBlob <SensorProfileDB>(); TimeSpan timeSinceLastCalc = atDate - sensorProfile.LastDatetimeOfReflectionSet; PositionDB positionOfSensorProfile = detectableEntity.GetDataBlob <PositionDB>();//sensorProfile.OwningEntity.GetDataBlob<ComponentInstanceInfoDB>().ParentEntity.GetDataBlob<PositionDB>(); double distanceInAUSinceLastCalc = PositionDB.GetDistanceBetween(sensorProfile.LastPositionOfReflectionSet, positionOfSensorProfile); //Only set the reflectedEMProfile of the target if it's not been done recently: //TODO: is this still neccicary now that I've found and fixed the loop? (refelctions were getting bounced around) if (timeSinceLastCalc > TimeSpan.FromMinutes(30) || distanceInAUSinceLastCalc > 0.1) //TODO: move the time and distance numbers here to settings? { SetReflectedEMProfile.SetEntityProfile(detectableEntity, atDate); } SensorReturnValues detectionValues = DetectonQuality(receverDB, sensorProfile); SensorInfoDB sensorInfo; if (detectionValues.SignalStrength_kW > 0.0) { if (knownContacts.ContainsKey(detectableEntity.Guid)) { sensorInfo = knownContacts[detectableEntity.Guid].GetDataBlob <SensorInfoDB>(); sensorInfo.LatestDetectionQuality = detectionValues; sensorInfo.LastDetection = atDate; if (sensorInfo.HighestDetectionQuality.SignalQuality < detectionValues.SignalQuality) { sensorInfo.HighestDetectionQuality.SignalQuality = detectionValues.SignalQuality; } if (sensorInfo.HighestDetectionQuality.SignalStrength_kW < detectionValues.SignalStrength_kW) { sensorInfo.HighestDetectionQuality.SignalStrength_kW = detectionValues.SignalStrength_kW; } SensorEntityFactory.UpdateSensorContact(receverFaction, sensorInfo); } else { sensorInfo = new SensorInfoDB(receverFaction, detectableEntity, atDate); //knownContacts.Add(detectableEntity.Guid, SensorEntityFactory.UpdateSensorContact(receverFaction, sensorInfo)); moved this line to the SensorInfoDB constructor } } }
/// <summary> /// Probibly only needs to be done at star creation, unless we do funky stuff like change a stars temprature and stuff. /// </summary> /// <returns>The star emmision sig.</returns> /// <param name="starInfoDB">Star info db.</param> /// <param name="starMassVolumeDB">Star mass volume db.</param> internal static SensorProfileDB SetStarEmmisionSig(StarInfoDB starInfoDB, MassVolumeDB starMassVolumeDB) { var tempDegreesC = starInfoDB.Temperature; var kelvin = tempDegreesC + 273.15; double b = 2898000; //Wien's displacement constant for nanometers. var wavelength = b / kelvin; //Wien's displacement law https://en.wikipedia.org/wiki/Wien%27s_displacement_law var magnitudeInKW = starInfoDB.Luminosity * 3.827e23; //tempDegreesC / starMassVolumeDB.Volume_km3; //maybe this should be lum / volume? //-300, + 600, semi arbitrary number pulled outa my ass from 10min of internet research. EMWaveForm waveform = new EMWaveForm(wavelength - 300, wavelength, wavelength + 600); var emisionSignature = new SensorProfileDB() { }; emisionSignature.EmittedEMSpectra.Add(waveform, magnitudeInKW);// this will need adjusting... return(emisionSignature); }
/// <summary> /// probibly only needs to be done at entity creation, once the bodies mass is set. /// </summary> /// <returns>The emmision sig.</returns> /// <param name="sysBodyInfoDB">Sys body info db.</param> /// <param name="massVolDB">Mass vol db.</param> internal static void PlanetEmmisionSig(SensorProfileDB profile, SystemBodyInfoDB sysBodyInfoDB, MassVolumeDB massVolDB) { var tempDegreesC = sysBodyInfoDB.BaseTemperature; var kelvin = tempDegreesC + 273.15; double b = 2898000; //Wien's displacement constant for nanometers. var wavelength = b / kelvin; //Wien's displacement law https://en.wikipedia.org/wiki/Wien%27s_displacement_law var cop = 5.670373E-8; var emisivity = 1 - sysBodyInfoDB.Albedo; var j = emisivity * cop * Math.Pow(kelvin, 4); var surfaceArea = 4 * Math.PI * massVolDB.RadiusInM * massVolDB.RadiusInM; var magnitude = j * surfaceArea * 0.001; //-400 & +600, semi arbitrary number pulled outa my ass from 0min of internet research. EMWaveForm waveform = new EMWaveForm(wavelength - 400, wavelength, wavelength + 600); profile.EmittedEMSpectra.Add(waveform, magnitude);//TODO this may need adjusting to make good balanced detections. profile.Reflectivity = sysBodyInfoDB.Albedo; }
public void OnComponentInstallation(Entity parentEntity, ComponentInstance componentInstance) { if (!parentEntity.HasDataBlob <SensorProfileDB>()) { parentEntity.SetDataBlob(new SensorProfileDB()); } SensorProfileDB _PartSensorProfile = parentEntity.GetDataBlob <SensorProfileDB>(); if (_PartSensorProfile.EmittedEMSpectra.ContainsKey(PartWaveForm)) { _PartSensorProfile.EmittedEMSpectra[PartWaveForm] = _PartSensorProfile.EmittedEMSpectra[PartWaveForm] + PartWaveFormMag; } else { _PartSensorProfile.EmittedEMSpectra.Add(PartWaveForm, PartWaveFormMag); } parentEntity.SetDataBlob <SensorProfileDB>(_PartSensorProfile); }
/// <summary> /// Probibly only needs to be done at star creation, unless we do funky stuff like change a stars temprature and stuff. /// </summary> /// <returns>The star emmision sig.</returns> /// <param name="starInfoDB">Star info db.</param> /// <param name="starMassVolumeDB">Star mass volume db.</param> internal static SensorProfileDB SetStarEmmisionSig(StarInfoDB starInfoDB, MassVolumeDB starMassVolumeDB) { var tempDegreesC = starInfoDB.Temperature; var kelvin = tempDegreesC + 273.15; var wavelength = 2.9 * Math.Pow(10, 6) / kelvin; var magnitudeInKW = starInfoDB.Luminosity * 3.827e23; //tempDegreesC / starMassVolumeDB.Volume; //maybe this should be lum / volume? EMWaveForm waveform = new EMWaveForm() { WavelengthAverage_nm = wavelength, WavelengthMin_nm = wavelength - 300, //3k angstrom, semi arbitrary number pulled outa my ass from 10min of internet research. WavelengthMax_nm = wavelength + 600 }; var emisionSignature = new SensorProfileDB() { }; emisionSignature.EmittedEMSpectra.Add(waveform, magnitudeInKW);// this will need adjusting... return(emisionSignature); }
public static SensorReturnValues[] GetDetectedEntites(SensorReceverAtbDB sensorAtb, Vector3 position, List <Entity> detectableEntities, DateTime atDate, Guid factionOwner, bool filterSameFaction = true) { SensorReturnValues[] detectionValues = new SensorReturnValues[detectableEntities.Count]; for (int i = 0; i < detectableEntities.Count; i++) { var detectableEntity = detectableEntities[i]; if (filterSameFaction && detectableEntity.FactionOwner == factionOwner) { continue; } else { SensorProfileDB detectableProfile = detectableEntity.GetDataBlob <SensorProfileDB>(); PositionDB detectablePosDB = detectableEntity.GetDataBlob <PositionDB>(); if (detectablePosDB == null) { StaticRefLib.EventLog.AddEvent(new Event("Error: Attempt to get a sensor position on a positionless entity, ID: " + detectableEntity.Guid)); continue; } //TODO: check if the below actualy saves us anything. it might be better just to seperatly loop through each of the entites and set the reflection profiles every so often.. TimeSpan timeSinceLastCalc = atDate - detectableProfile.LastDatetimeOfReflectionSet; double distanceSinceLastCalc = detectablePosDB.GetDistanceTo_m(detectableProfile.LastPositionOfReflectionSet); if (timeSinceLastCalc > TimeSpan.FromMinutes(30) || distanceSinceLastCalc > 5000) //TODO: move the time and distance numbers here to settings? { SetReflectedEMProfile.SetEntityProfile(detectableEntity, atDate); } var distance = detectablePosDB.GetDistanceTo_m(position); var attentuatedSignal = AttenuatedForDistance(detectableProfile, distance); SensorReturnValues detectionValue = DetectonQuality(sensorAtb, attentuatedSignal); //if(detectionValue.SignalStrength_kW > 0) detectionValues[i] = detectionValue; } } return(detectionValues); }
/// <summary> /// returns a dictionary of all emmisions including reflected emmisions. /// </summary> /// <returns>The for distance.</returns> /// <param name="emissionProfile">Emission.</param> /// <param name="distance">Distance.</param> public static Dictionary <EMWaveForm, double> AttenuatedForDistance(SensorProfileDB emissionProfile, double distance) { var dict = new Dictionary <EMWaveForm, double>(); foreach (var emitedItem in emissionProfile.EmittedEMSpectra) { var powerAtDistance = AttenuationCalc(emitedItem.Value, distance); dict.Add(emitedItem.Key, powerAtDistance); } foreach (var reflectedItem in emissionProfile.ReflectedEMSpectra) { var reflectedValue = AttenuationCalc(reflectedItem.Value, distance); if (!dict.ContainsKey(reflectedItem.Key)) { dict.Add(reflectedItem.Key, reflectedValue); } else { dict[reflectedItem.Key] += reflectedValue; } } return(dict); }
internal static void DetectEntites(SystemSensorContacts sensorMgr, FactionInfoDB factionInfo, PositionDB receverPos, SensorReceverAtbDB receverDB, Entity detectableEntity, DateTime atDate) { Entity receverFaction = sensorMgr.FactionEntity; //Entity receverFaction;// = receverDB.OwningEntity.GetDataBlob<OwnedDB>().OwnedByFaction; //detectableEntity.Manager.FindEntityByGuid(receverDB.OwningEntity.FactionOwner, out receverFaction); var knownContacts = factionInfo.SensorContacts; //receverFaction.GetDataBlob<FactionInfoDB>().SensorEntites; var knownContacts1 = sensorMgr.GetAllContacts(); SensorProfileDB sensorProfile = detectableEntity.GetDataBlob <SensorProfileDB>(); TimeSpan timeSinceLastCalc = atDate - sensorProfile.LastDatetimeOfReflectionSet; PositionDB positionOfSensorProfile = detectableEntity.GetDataBlob <PositionDB>();//sensorProfile.OwningEntity.GetDataBlob<ComponentInstanceInfoDB>().ParentEntity.GetDataBlob<PositionDB>(); double distanceSinceLastCalc = PositionDB.GetDistanceBetween_m(sensorProfile.LastPositionOfReflectionSet, positionOfSensorProfile); //Only set the reflectedEMProfile of the target if it's not been done recently: //TODO: is this still neccicary now that I've found and fixed the loop? (refelctions were getting bounced around) if (timeSinceLastCalc > TimeSpan.FromMinutes(30) || distanceSinceLastCalc > 5000) //TODO: move the time and distance numbers here to settings? { SetReflectedEMProfile.SetEntityProfile(detectableEntity, atDate); } PositionDB targetPosition; if (detectableEntity.HasDataBlob <PositionDB>()) { targetPosition = detectableEntity.GetDataBlob <PositionDB>(); } else { throw new NotImplementedException("This might be a colony on a planet, not sure how I'll handle that yet"); } var distance = PositionDB.GetDistanceBetween_AU(receverPos, targetPosition); SensorReturnValues detectionValues = DetectonQuality(receverDB, AttenuatedForDistance(sensorProfile, distance)); SensorInfoDB sensorInfo; if (detectionValues.SignalStrength_kW > 0.0) { if (sensorMgr.SensorContactExists(detectableEntity.Guid)) { //sensorInfo = knownContacts[detectableEntity.Guid].GetDataBlob<SensorInfoDB>(); sensorInfo = sensorMgr.GetSensorContact(detectableEntity.Guid).SensorInfo; sensorInfo.LatestDetectionQuality = detectionValues; sensorInfo.LastDetection = atDate; if (sensorInfo.HighestDetectionQuality.SignalQuality < detectionValues.SignalQuality) { sensorInfo.HighestDetectionQuality.SignalQuality = detectionValues.SignalQuality; } if (sensorInfo.HighestDetectionQuality.SignalStrength_kW < detectionValues.SignalStrength_kW) { sensorInfo.HighestDetectionQuality.SignalStrength_kW = detectionValues.SignalStrength_kW; } SensorEntityFactory.UpdateSensorContact(receverFaction, sensorInfo); } else { SensorContact contact = new SensorContact(receverFaction, detectableEntity, atDate); sensorMgr.AddContact(contact); //knownContacts.Add(detectableEntity.Guid, SensorEntityFactory.UpdateSensorContact(receverFaction, sensorInfo)); moved this line to the SensorInfoDB constructor } } }
internal static SensorReturnValues DetectonQuality(SensorReceverAtbDB recever, SensorProfileDB target) { /* * Thoughts (spitballing): * * What we need: * detect enough of a signal to get a position * decide what "enough" is. probibly get this from the signal strength. - should the target SensorSigDB define what enough is? * we could require more than one detection (ie two ships in different locations) to get an acurate position, but that could get tricky to code. * and how would we display a non acurate position? maybe a line out to a question mark, showing the angle of detection but not range? * * detect enough of a signal to get intel if it's a ship * decide what "enough" for this is. maybe compare the detected waveform and the emited waveform and compare the angles to see if the triangle is simular. * * it'd be nifty if we could include background noise in there too, ie so ships close to a sun would be hidden. * also have resoulution be required to pick out multiple ships close together instead of just one big signal. * * With range attenuation, we'll never get the full signal uneless we're right ontop of it. * maybe if we get half the emited strength and its a simular triange (all same angles) we get "Full" intel? * * should we add time into the mix as well? multiple detections over a given time period to get position/velocity/orbitDB? * * * how are multiple components on a ship going to work? they are entitys in and of themselfs, so they could have a SensorSigDB all of thier own. * that could help with getting intel on individual components of a target. * * recever resolution should play into how much gets detected. * * Note that each entity will(may) have multiple waveforms. * * Data that can be glened from this detection system: * detectedStrength (altitide of the intersecting triangle) * detectedArea - the area of the detected intersection, could compare this to the target signal as well. * compare angles of the detected intersection and the target signal to see if the shape is simular? * if range is known acurately, this could affect the intel gathered. */ var myPosition = recever.OwningEntity.GetDataBlob <ComponentInstanceInfoDB>().ParentEntity.GetDataBlob <PositionDB>();//recever is a componentDB. not a shipDB PositionDB targetPosition; if (target.OwningEntity.HasDataBlob <PositionDB>()) { targetPosition = target.OwningEntity.GetDataBlob <PositionDB>(); } else { targetPosition = target.OwningEntity.GetDataBlob <ComponentInstanceInfoDB>().ParentEntity.GetDataBlob <PositionDB>();//target may be a componentDB. not a shipDB } double distance = PositionDB.GetDistanceBetween(myPosition, targetPosition); var detectionResolution = recever.Resolution; var signalAtPosition = AttenuatedForDistance(target, distance); double receverSensitivityFreqMin = recever.RecevingWaveformCapabilty.WavelengthMin_nm; double receverSensitivityFreqAvg = recever.RecevingWaveformCapabilty.WavelengthAverage_nm; double receverSensitivityFreqMax = recever.RecevingWaveformCapabilty.WavelengthMax_nm; double receverSensitivityBest = recever.BestSensitivity_kW; double receverSensitivityAltitiude = recever.BestSensitivity_kW - recever.WorstSensitivity_kW; PercentValue quality = new PercentValue(0.0f); double detectedMagnatude = 0; foreach (var waveSpectra in signalAtPosition) { double signalWaveSpectraFreqMin = waveSpectra.Key.WavelengthMin_nm; double signalWaveSpectraFreqAvg = waveSpectra.Key.WavelengthAverage_nm; double signalWaveSpectraFreqMax = waveSpectra.Key.WavelengthMax_nm; double signalWaveSpectraMagnatude_kW = waveSpectra.Value; if (signalWaveSpectraMagnatude_kW > recever.BestSensitivity_kW) //check if the sensitivy is enough to pick anything up at any frequency. { if (Math.Max(receverSensitivityFreqMin, signalWaveSpectraFreqMin) < Math.Max(signalWaveSpectraFreqMin, signalWaveSpectraFreqMax)) { //we've got something we can detect double minDetectableWavelength = Math.Min(receverSensitivityFreqMin, signalWaveSpectraFreqMin); double maxDetectableWavelenght = Math.Min(receverSensitivityFreqMax, signalWaveSpectraFreqMax); double detectedAngleA = Math.Atan(receverSensitivityAltitiude / (receverSensitivityFreqAvg - receverSensitivityFreqMin)); double receverBaseLen = maxDetectableWavelenght - minDetectableWavelength; double detectedAngleB = Math.Atan(signalWaveSpectraMagnatude_kW / (signalWaveSpectraFreqAvg - signalWaveSpectraFreqMax)); bool doesIntersect; double intersectPointX; double intersectPointY; double distortion; if (signalWaveSpectraFreqAvg < receverSensitivityFreqAvg) //RightsideDetection (recever's ideal wavelenght is higher than the signal wavelenght at it's loudest) { doesIntersect = Get_line_intersection( signalWaveSpectraFreqAvg, signalWaveSpectraMagnatude_kW, signalWaveSpectraFreqMin, 0, receverSensitivityFreqAvg, recever.BestSensitivity_kW, receverSensitivityFreqMax, recever.WorstSensitivity_kW, out intersectPointX, out intersectPointY); //offsetFromCenter = intersectPointX - signalWaveSpectraFreqAvg; //was going to use this for distortion but decided to simplify. distortion = receverSensitivityFreqAvg - signalWaveSpectraFreqAvg; } else //LeftSideDetection { doesIntersect = Get_line_intersection( signalWaveSpectraFreqAvg, signalWaveSpectraMagnatude_kW, signalWaveSpectraFreqMax, 0, receverSensitivityFreqAvg, recever.BestSensitivity_kW, receverSensitivityFreqMin, recever.WorstSensitivity_kW, out intersectPointX, out intersectPointY); //offsetFromCenter = intersectPointX - signalWaveSpectraFreqAvg; distortion = signalWaveSpectraFreqAvg - receverSensitivityFreqAvg; } if (doesIntersect) // then we're not detecting the peak of the signal { detectedMagnatude = intersectPointY - recever.BestSensitivity_kW; distortion *= 2; //pentalty to quality of signal } else { detectedMagnatude = signalWaveSpectraMagnatude_kW - recever.BestSensitivity_kW; } quality = new PercentValue((float)(100 - distortion / signalWaveSpectraFreqMax)); } } } return(new SensorReturnValues() { SignalStrength_kW = detectedMagnatude, SignalQuality = quality }); }
public static Entity CreateAsteroid2(StarSystem starSys, Entity target, DateTime collisionDate, double asteroidMass = -1.0) { //todo rand these a bit. double radius = Distance.KmToAU(0.5); double mass; if (asteroidMass == -1.0) { mass = 1.5e+12; //about 1.5 billion tonne } else { mass = asteroidMass; } Vector3 velocity = new Vector3(8, 7, 0); var position = new PositionDB(0, 0, 0, Guid.Empty); var massVolume = MassVolumeDB.NewFromMassAndRadius(mass, radius); var planetInfo = new SystemBodyInfoDB(); var balisticTraj = new NewtonBalisticDB(target.Guid, collisionDate); var name = new NameDB("Ellie"); var AsteroidDmg = new AsteroidDamageDB(); var sensorPfil = new SensorProfileDB(); planetInfo.SupportsPopulations = false; planetInfo.BodyType = BodyType.Asteroid; Vector3 targetPos = OrbitProcessor.GetAbsolutePosition_AU(target.GetDataBlob <OrbitDB>(), collisionDate); TimeSpan timeToCollision = collisionDate - StaticRefLib.CurrentDateTime; Vector3 offset = velocity * timeToCollision.TotalSeconds; targetPos -= Distance.KmToAU(offset); position.AbsolutePosition_AU = targetPos; position.SystemGuid = starSys.Guid; balisticTraj.CurrentSpeed = velocity; var parent = target.GetDataBlob <OrbitDB>().Parent; var parentMass = parent.GetDataBlob <MassVolumeDB>().Mass; var myMass = massVolume.Mass; var mySemiMajorAxis = 5.055; var myEccentricity = 0.8; var myInclination = 0; var myLoAN = 0; var myAoP = -10; //var EccentricAnomaly = Math.Atan2() //var meanAnomaly =; double myLoP = 0; double myMeanLongd = 355.5; //OrbitDB orbit = OrbitDB.FromAsteroidFormat(parent, parentMass, myMass, mySemiMajorAxis, myEccentricity, myInclination, myLoAN, myAoP, meanAnomaly, starSys.Game.CurrentDateTime); OrbitDB orbit = OrbitDB.FromMajorPlanetFormat(parent, parentMass, myMass, mySemiMajorAxis, myEccentricity, myInclination, myLoAN, myLoP, myMeanLongd, StaticRefLib.CurrentDateTime); var planetDBs = new List <BaseDataBlob> { position, massVolume, planetInfo, name, orbit, AsteroidDmg, sensorPfil }; Entity newELE = new Entity(starSys, planetDBs); return(newELE); }
public SensorProfileDB(SensorProfileDB db) { EmittedEMSpectra = new Dictionary <EMWaveForm, double>(db.EmittedEMSpectra); ReflectedEMSpectra = new Dictionary <EMWaveForm, double>(db.ReflectedEMSpectra); _targetCrossSection = db._targetCrossSection; }
public StarSystem CreateTestSystem(Game game, int x = 0, int y = 0) { StarSystem sol = new StarSystem(game, "something", -1); Entity sun = _starFactory.CreateStar(sol, GameConstants.Units.SolarMassInKG, GameConstants.Units.SolarRadiusInAu, 4.6E9, "G", 5778, 1, SpectralType.G, "something"); sun.GetDataBlob <PositionDB>().X_AU += x; sun.GetDataBlob <PositionDB>().Y_AU += x; MassVolumeDB sunMVDB = sun.GetDataBlob <MassVolumeDB>(); SystemBodyInfoDB mercuryBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.068f }; //Albedo = 0.068f MassVolumeDB mercuryMVDB = MassVolumeDB.NewFromMassAndRadius_AU(3.3022E23, Distance.KmToAU(2439.7)); NameDB mercuryNameDB = new NameDB("LOLXDWTF"); double mercurySemiMajAxis = 0.387098; double mercuryEccentricity = 0.205630; double mercuryInclination = 0; double mercuryLoAN = 48.33167; double mercuryLoP = 77.45645; double mercuryMeanLongd = 252.25084; OrbitDB mercuryOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, mercuryMVDB.MassDry, mercurySemiMajAxis, mercuryEccentricity, mercuryInclination, mercuryLoAN, mercuryLoP, mercuryMeanLongd, GalaxyGen.Settings.J2000); PositionDB mercuryPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(mercuryOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); //AtmosphereDB mercuryAtmo = new AtmosphereDB(); SensorProfileDB sensorProfile = new SensorProfileDB(); mercuryPositionDB.X_AU += x; mercuryPositionDB.Y_AU += x; Entity mercury = new Entity(sol, new List <BaseDataBlob> { sensorProfile, mercuryPositionDB, mercuryBodyDB, mercuryMVDB, mercuryNameDB, mercuryOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, mercury); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, mercuryBodyDB, mercuryMVDB); SystemBodyInfoDB venusBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.77f }; MassVolumeDB venusMVDB = MassVolumeDB.NewFromMassAndRadius_AU(4.8676E24, Distance.KmToAU(6051.8)); NameDB venusNameDB = new NameDB("AYLMAOROFL"); double venusSemiMajAxis = 0.72333199; double venusEccentricity = 0.00677323; double venusInclination = 0; double venusLoAN = 76.68069; double venusLoP = 131.53298; double venusMeanLongd = 181.97973; OrbitDB venusOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, venusMVDB.MassDry, venusSemiMajAxis, venusEccentricity, venusInclination, venusLoAN, venusLoP, venusMeanLongd, GalaxyGen.Settings.J2000); PositionDB venusPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(venusOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); sensorProfile = new SensorProfileDB(); Entity venus = new Entity(sol, new List <BaseDataBlob> { sensorProfile, venusPositionDB, venusBodyDB, venusMVDB, venusNameDB, venusOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, venus); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, venusBodyDB, venusMVDB); SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.306f }; MassVolumeDB earthMVDB = MassVolumeDB.NewFromMassAndRadius_AU(5.9726E24, Distance.KmToAU(6378.1)); NameDB earthNameDB = new NameDB("OMG"); double earthSemiMajAxis = 1.00000011; double earthEccentricity = 0.01671022; double earthInclination = 0; double earthLoAN = -11.26064; double earthLoP = 102.94719; double earthMeanLongd = 100.46435; OrbitDB earthOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, earthMVDB.MassDry, earthSemiMajAxis, earthEccentricity, earthInclination, earthLoAN, earthLoP, earthMeanLongd, GalaxyGen.Settings.J2000); earthBodyDB.Tectonics = TectonicActivity.EarthLike; PositionDB earthPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(earthOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); Dictionary <AtmosphericGasSD, float> atmoGasses = new Dictionary <AtmosphericGasSD, float>(); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(6), 0.78f); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(9), 0.12f); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(11), 0.01f); AtmosphereDB earthAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? sensorProfile = new SensorProfileDB(); Entity earth = new Entity(sol, new List <BaseDataBlob> { sensorProfile, earthPositionDB, earthBodyDB, earthMVDB, earthNameDB, earthOrbitDB, earthAtmosphereDB }); _systemBodyFactory.HomeworldMineralGeneration(game.StaticData, sol, earth); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, earthBodyDB, earthMVDB); SystemBodyInfoDB lunaBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Moon, SupportsPopulations = true }; MassVolumeDB lunaMVDB = MassVolumeDB.NewFromMassAndRadius_AU(0.073E24, Distance.KmToAU(1738.14)); NameDB lunaNameDB = new NameDB("NOWAY"); double lunaSemiMajAxis = Distance.KmToAU(0.3844E6); double lunaEccentricity = 0.0549; double lunaInclination = 0;//5.1; // Next three values are unimportant. Luna's LoAN and AoP regress/progress by one revolution every 18.6/8.85 years respectively. // Our orbit code it not advanced enough to deal with LoAN/AoP regression/progression. double lunaLoAN = 125.08; double lunaAoP = 318.0634; double lunaMeanAnomaly = 115.3654; OrbitDB lunaOrbitDB = OrbitDB.FromAsteroidFormat(earth, earthMVDB.MassDry, lunaMVDB.MassDry, lunaSemiMajAxis, lunaEccentricity, lunaInclination, lunaLoAN, lunaAoP, lunaMeanAnomaly, GalaxyGen.Settings.J2000); PositionDB lunaPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(lunaOrbitDB, StaticRefLib.CurrentDateTime) + earthPositionDB.AbsolutePosition_AU, sol.Guid, earth); sensorProfile = new SensorProfileDB(); Entity luna = new Entity(sol, new List <BaseDataBlob> { sensorProfile, lunaPositionDB, lunaBodyDB, lunaMVDB, lunaNameDB, lunaOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, luna); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, lunaBodyDB, lunaMVDB); SystemBodyInfoDB halleysBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Comet, SupportsPopulations = false, Albedo = 0.04f }; //Albedo = 0.04f MassVolumeDB halleysMVDB = MassVolumeDB.NewFromMassAndRadius_AU(2.2e14, Distance.KmToAU(11)); NameDB halleysNameDB = new NameDB("ASSHOLE"); double halleysSemiMajAxis = 17.834; //AU double halleysEccentricity = 0.96714; double halleysInclination = 180; //162.26° note retrograde orbit. double halleysLoAN = 58.42; //° double halleysAoP = 111.33; //° double halleysMeanAnomaly = 38.38; //° OrbitDB halleysOrbitDB = OrbitDB.FromAsteroidFormat(sun, sunMVDB.MassDry, halleysMVDB.MassDry, halleysSemiMajAxis, halleysEccentricity, halleysInclination, halleysLoAN, halleysAoP, halleysMeanAnomaly, new System.DateTime(1994, 2, 17)); PositionDB halleysPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(halleysOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); // + earthPositionDB.AbsolutePosition_AU, sol.ID); sensorProfile = new SensorProfileDB(); Entity halleysComet = new Entity(sol, new List <BaseDataBlob> { sensorProfile, halleysPositionDB, halleysBodyDB, halleysMVDB, halleysNameDB, halleysOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, halleysComet); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, halleysBodyDB, halleysMVDB); JPSurveyFactory.GenerateJPSurveyPoints(sol); game.GameMasterFaction.GetDataBlob <FactionInfoDB>().KnownSystems.Add(sol.Guid); return(sol); }
/// <summary> /// Creates our own solar system. /// This probibly needs to be Json! (since we're getting atmo stuff) /// Adds sol to game.StarSystems. /// </summary> public StarSystem CreateSol(Game game) { // WIP Function. Not complete. StarSystem sol = new StarSystem(game, "Sol", -1); Entity sun = _starFactory.CreateStar(sol, GameConstants.Units.SolarMassInKG, GameConstants.Units.SolarRadiusInAu, 4.6E9, "G", 5778, 1, SpectralType.G, "Sol"); MassVolumeDB sunMVDB = sun.GetDataBlob <MassVolumeDB>(); SystemBodyInfoDB mercuryBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.068f }; //Albedo = 0.068f MassVolumeDB mercuryMVDB = MassVolumeDB.NewFromMassAndRadius_AU(3.3022E23, Distance.KmToAU(2439.7)); NameDB mercuryNameDB = new NameDB("Mercury"); double mercurySemiMajAxis = 0.387098; double mercuryEccentricity = 0.205630; double mercuryInclination = 0; double mercuryLoAN = 48.33167; double mercuryLoP = 77.45645; double mercuryMeanLongd = 252.25084; OrbitDB mercuryOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, mercuryMVDB.MassDry, mercurySemiMajAxis, mercuryEccentricity, mercuryInclination, mercuryLoAN, mercuryLoP, mercuryMeanLongd, GalaxyGen.Settings.J2000); mercuryBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, mercuryOrbitDB); PositionDB mercuryPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(mercuryOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); //AtmosphereDB mercuryAtmo = new AtmosphereDB(); SensorProfileDB sensorProfile = new SensorProfileDB(); Entity mercury = new Entity(sol, new List <BaseDataBlob> { sensorProfile, mercuryPositionDB, mercuryBodyDB, mercuryMVDB, mercuryNameDB, mercuryOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, mercury); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, mercuryBodyDB, mercuryMVDB); SystemBodyInfoDB venusBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.77f }; MassVolumeDB venusMVDB = MassVolumeDB.NewFromMassAndRadius_AU(4.8676E24, Distance.KmToAU(6051.8)); NameDB venusNameDB = new NameDB("Venus"); double venusSemiMajAxis = 0.72333199; double venusEccentricity = 0.00677323; double venusInclination = 0; double venusLoAN = 76.68069; double venusLoP = 131.53298; double venusMeanLongd = 181.97973; OrbitDB venusOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, venusMVDB.MassDry, venusSemiMajAxis, venusEccentricity, venusInclination, venusLoAN, venusLoP, venusMeanLongd, GalaxyGen.Settings.J2000); venusBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, venusOrbitDB); PositionDB venusPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(venusOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); sensorProfile = new SensorProfileDB(); Entity venus = new Entity(sol, new List <BaseDataBlob> { sensorProfile, venusPositionDB, venusBodyDB, venusMVDB, venusNameDB, venusOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, venus); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, venusBodyDB, venusMVDB); SystemBodyInfoDB earthBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.306f }; MassVolumeDB earthMVDB = MassVolumeDB.NewFromMassAndRadius_AU(5.9726E24, Distance.KmToAU(6378.1)); NameDB earthNameDB = new NameDB("Earth"); double earthSemiMajAxis = 1.00000011; double earthEccentricity = 0.01671022; double earthInclination = 0; double earthLoAN = -11.26064; double earthLoP = 102.94719; double earthMeanLongd = 100.46435; OrbitDB earthOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, earthMVDB.MassDry, earthSemiMajAxis, earthEccentricity, earthInclination, earthLoAN, earthLoP, earthMeanLongd, GalaxyGen.Settings.J2000); earthBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, earthOrbitDB); earthBodyDB.Tectonics = TectonicActivity.EarthLike; PositionDB earthPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(earthOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); Dictionary <AtmosphericGasSD, float> atmoGasses = new Dictionary <AtmosphericGasSD, float>(); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(6), 0.78f); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(9), 0.12f); atmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(11), 0.01f); AtmosphereDB earthAtmosphereDB = new AtmosphereDB(1f, true, 71, 1f, 1f, 57.2f, atmoGasses); //TODO what's our greenhouse factor an pressure? sensorProfile = new SensorProfileDB(); Entity earth = new Entity(sol, new List <BaseDataBlob> { sensorProfile, earthPositionDB, earthBodyDB, earthMVDB, earthNameDB, earthOrbitDB, earthAtmosphereDB }); _systemBodyFactory.HomeworldMineralGeneration(game.StaticData, sol, earth); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, earthBodyDB, earthMVDB); SystemBodyInfoDB lunaBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Moon, SupportsPopulations = true }; MassVolumeDB lunaMVDB = MassVolumeDB.NewFromMassAndRadius_AU(0.073E24, Distance.KmToAU(1738.14)); NameDB lunaNameDB = new NameDB("Luna"); double lunaSemiMajAxis = Distance.KmToAU(0.3844E6); double lunaEccentricity = 0.0549; double lunaInclination = 0;//5.1; // Next three values are unimportant. Luna's LoAN and AoP regress/progress by one revolution every 18.6/8.85 years respectively. // Our orbit code it not advanced enough to deal with LoAN/AoP regression/progression. double lunaLoAN = 125.08; double lunaAoP = 318.0634; double lunaMeanAnomaly = 115.3654; OrbitDB lunaOrbitDB = OrbitDB.FromAsteroidFormat(earth, earthMVDB.MassDry, lunaMVDB.MassDry, lunaSemiMajAxis, lunaEccentricity, lunaInclination, lunaLoAN, lunaAoP, lunaMeanAnomaly, GalaxyGen.Settings.J2000); lunaBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, earthOrbitDB); //yes, using earth orbit here, since this is the DB it calculates the average distance from. PositionDB lunaPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(lunaOrbitDB, StaticRefLib.CurrentDateTime) + earthPositionDB.AbsolutePosition_AU, sol.Guid, earth); sensorProfile = new SensorProfileDB(); Entity luna = new Entity(sol, new List <BaseDataBlob> { sensorProfile, lunaPositionDB, lunaBodyDB, lunaMVDB, lunaNameDB, lunaOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, luna); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, lunaBodyDB, lunaMVDB); SystemBodyInfoDB marsBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true, Albedo = 0.25f }; MassVolumeDB marsMVDB = MassVolumeDB.NewFromMassAndRadius_AU(0.64174E24, Distance.KmToAU(3396.2)); NameDB marsNameDB = new NameDB("Mars"); double marsSemiMajAxis = Distance.KmToAU(227.92E6); double marsEccentricity = 0.0934; //wiki says .0934 double marsInclination = 0; //1.85; double marsLoAN = 49.57854; double marsAoP = 336.04084; double marsMeanLong = 355.45332; OrbitDB marsOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.MassDry, marsMVDB.MassDry, marsSemiMajAxis, marsEccentricity, marsInclination, marsLoAN, marsAoP, marsMeanLong, GalaxyGen.Settings.J2000); marsBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, marsOrbitDB); Dictionary <AtmosphericGasSD, float> marsAtmoGasses = new Dictionary <AtmosphericGasSD, float>(); marsAtmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(12), 0.95f * 0.01f); // C02% * Mars Atms marsAtmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(6), 0.027f * 0.01f); // N% * Mars Atms marsAtmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(9), 0.007f * 0.01f); // O% * Mars Atms marsAtmoGasses.Add(game.StaticData.AtmosphericGases.SelectAt(11), 0.016f * 0.01f); // Ar% * Mars Atms AtmosphereDB marsAtmo = new AtmosphereDB(0.087f, false, 0, 0, 0, -55, marsAtmoGasses); PositionDB marsPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(marsOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); sensorProfile = new SensorProfileDB(); Entity mars = new Entity(sol, new List <BaseDataBlob> { sensorProfile, marsPositionDB, marsBodyDB, marsMVDB, marsNameDB, marsOrbitDB, marsAtmo }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, mars); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, marsBodyDB, marsMVDB); SystemBodyInfoDB halleysBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Comet, SupportsPopulations = false, Albedo = 0.04f }; //Albedo = 0.04f MassVolumeDB halleysMVDB = MassVolumeDB.NewFromMassAndRadius_AU(2.2e14, Distance.KmToAU(11)); NameDB halleysNameDB = new NameDB("Halleys Comet"); double halleysSemiMajAxis = 17.834; //AU double halleysEccentricity = 0.96714; double halleysInclination = 180; //162.26° note retrograde orbit. double halleysLoAN = 58.42; //° double halleysAoP = 111.33; //° double halleysMeanAnomaly = 38.38; //° OrbitDB halleysOrbitDB = OrbitDB.FromAsteroidFormat(sun, sunMVDB.MassDry, halleysMVDB.MassDry, halleysSemiMajAxis, halleysEccentricity, halleysInclination, halleysLoAN, halleysAoP, halleysMeanAnomaly, new System.DateTime(1994, 2, 17)); halleysBodyDB.BaseTemperature = (float)SystemBodyFactory.CalculateBaseTemperatureOfBody(sun, halleysOrbitDB); PositionDB halleysPositionDB = new PositionDB(OrbitProcessor.GetPosition_AU(halleysOrbitDB, StaticRefLib.CurrentDateTime), sol.Guid, sun); // + earthPositionDB.AbsolutePosition_AU, sol.ID); sensorProfile = new SensorProfileDB(); Entity halleysComet = new Entity(sol, new List <BaseDataBlob> { sensorProfile, halleysPositionDB, halleysBodyDB, halleysMVDB, halleysNameDB, halleysOrbitDB }); _systemBodyFactory.MineralGeneration(game.StaticData, sol, halleysComet); SensorProcessorTools.PlanetEmmisionSig(sensorProfile, halleysBodyDB, halleysMVDB); /* * * SystemBody Jupiter = new SystemBody(sun, SystemBody.PlanetType.GasGiant); * Jupiter.Name = "Jupiter"; * Jupiter.Orbit = Orbit.FromMajorPlanetFormat(1898.3E24, sun.Orbit.Mass, 5.20336301, 0.04839266, 1.30530, 100.55615, 14.75385, 34.40438, GalaxyGen.J2000); * Jupiter.Radius = Distance.ToAU(71492); * Jupiter.Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y); * Jupiter.Position.System = Sol; * Jupiter.Position.X = x; * Jupiter.Position.Y = y; * sun.Planets.Add(Jupiter); * * SystemBody Saturn = new SystemBody(sun, SystemBody.PlanetType.GasGiant); * Saturn.Name = "Saturn"; * Saturn.Orbit = Orbit.FromMajorPlanetFormat(568.36E24, sun.Orbit.Mass, 9.53707032, 0.05415060, 2.48446, 113.71504, 92.43194, 49.94432, GalaxyGen.J2000); * Saturn.Radius = Distance.ToAU(60268); * Saturn.Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y); * Saturn.Position.System = Sol; * Saturn.Position.X = x; * Saturn.Position.Y = y; * sun.Planets.Add(Saturn); * * SystemBody Uranus = new SystemBody(sun, SystemBody.PlanetType.IceGiant); * Uranus.Name = "Uranus"; * Uranus.Orbit = Orbit.FromMajorPlanetFormat(86.816E24, sun.Orbit.Mass, 19.19126393, 0.04716771, 0.76986, 74.22988, 170.96424, 313.23218, GalaxyGen.J2000); * Uranus.Radius = Distance.ToAU(25559); * Uranus.Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y); * Uranus.Position.System = Sol; * Uranus.Position.X = x; * Uranus.Position.Y = y; * sun.Planets.Add(Uranus); * * SystemBody Neptune = new SystemBody(sun, SystemBody.PlanetType.IceGiant); * Neptune.Name = "Neptune"; * Neptune.Orbit = Orbit.FromMajorPlanetFormat(102E24, sun.Orbit.Mass, Distance.ToAU(4495.1E6), 0.011, 1.8, 131.72169, 44.97135, 304.88003, GalaxyGen.J2000); * Neptune.Radius = Distance.ToAU(24764); * Neptune.Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y); * Neptune.Position.System = Sol; * Neptune.Position.X = x; * Neptune.Position.Y = y; * sun.Planets.Add(Neptune); * * SystemBody Pluto = new SystemBody(sun, SystemBody.PlanetType.DwarfPlanet); * Pluto.Name = "Pluto"; * Pluto.Orbit = Orbit.FromMajorPlanetFormat(0.0131E24, sun.Orbit.Mass, Distance.ToAU(5906.38E6), 0.24880766, 17.14175, 110.30347, 224.06676, 238.92881, GalaxyGen.J2000); * Pluto.Radius = Distance.ToAU(1195); * Pluto.Orbit.GetPosition(GameState.Instance.CurrentDate, out x, out y); * Pluto.Position.System = Sol; * Pluto.Position.X = x; * Pluto.Position.Y = y; * sun.Planets.Add(Pluto); * * GenerateJumpPoints(Sol); * * // Clean up cached RNG: * m_RNG = null; * GameState.Instance.StarSystems.Add(Sol); * GameState.Instance.StarSystemCurrentIndex++; */ /* * double planetSemiMajAxis = 0.387098; * double planetEccentricity = 0.205630; * double planetInclination = 0; * double planetLoAN = 0;//48.33167; * double planetLoP = 0;//77.45645; * double planetMeanLongd = 252.25084; * * EMWaveForm waveform; * * for (int i = 0; i < 8; i++) * { * NameDB planetNameDB = new NameDB("planetE" + i); * * SystemBodyInfoDB planetBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true }; * MassVolumeDB planetMVDB = MassVolumeDB.NewFromMassAndRadius_AU(3.3022E23, Distance.KmToAU(2439.7)); * PositionDB planetPositionDB = new PositionDB(sol.ID); * planetEccentricity = i * 2 / 16.0; * OrbitDB planetOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.Mass, planetMVDB.Mass, planetSemiMajAxis, planetEccentricity, planetInclination, planetLoAN, planetLoP, planetMeanLongd, GalaxyGen.Settings.J2000); * planetPositionDB.AbsolutePosition = OrbitProcessor.GetPosition(planetOrbitDB, game.CurrentDateTime); * * waveform = new EMWaveForm() * { * WavelengthAverage_nm = 600, * WavelengthMin_nm = 600 - 400, //4k angstrom, semi arbitrary number pulled outa my ass from 0min of internet research. * WavelengthMax_nm = 600 + 600 * }; * * sensorProfile = new SensorProfileDB(); * sensorProfile.EmittedEMSpectra.Add(waveform, 3.827e23); * Entity planet = new Entity(sol, new List<BaseDataBlob> { sensorProfile, planetPositionDB, planetBodyDB, planetMVDB, planetNameDB, planetOrbitDB }); * } * * planetEccentricity = 0.9; * for (int i = 0; i < 8; i++) * { * NameDB planetNameDB = new NameDB("planetL" + i); * SystemBodyInfoDB planetBodyDB = new SystemBodyInfoDB { BodyType = BodyType.Terrestrial, SupportsPopulations = true }; * MassVolumeDB planetMVDB = MassVolumeDB.NewFromMassAndRadius_AU(3.3022E23, Distance.KmToAU(2439.7)); * PositionDB planetPositionDB = new PositionDB(sol.ID); * planetLoP = i * 15; * OrbitDB planetOrbitDB = OrbitDB.FromMajorPlanetFormat(sun, sunMVDB.Mass, planetMVDB.Mass, planetSemiMajAxis, planetEccentricity, planetInclination, planetLoAN, planetLoP, planetMeanLongd, GalaxyGen.Settings.J2000); * planetPositionDB.AbsolutePosition = OrbitProcessor.GetPosition(planetOrbitDB, game.CurrentDateTime); * * waveform = new EMWaveForm() * { * WavelengthAverage_nm = 600, * WavelengthMin_nm = 600 - 400, //4k angstrom, semi arbitrary number pulled outa my ass from 0min of internet research. * WavelengthMax_nm = 600 + 600 * }; * * sensorProfile = new SensorProfileDB(); * sensorProfile.EmittedEMSpectra.Add(waveform, 3.827e23); * Entity planet = new Entity(sol, new List<BaseDataBlob> {sensorProfile, planetPositionDB, planetBodyDB, planetMVDB, planetNameDB, planetOrbitDB }); * } */ JPSurveyFactory.GenerateJPSurveyPoints(sol); game.GameMasterFaction.GetDataBlob <FactionInfoDB>().KnownSystems.Add(sol.Guid); return(sol); }
public static Entity CreateAsteroid4(Vector3 position, OrbitDB origOrbit, DateTime atDateTime, double asteroidMass = -1.0) { //todo rand these a bit. double radius = Distance.KmToAU(0.5); double mass; if (asteroidMass == -1.0) { mass = 1.5e+12; //about 1.5 billion tonne } else { mass = asteroidMass; } var speed = Distance.KmToAU(40); Vector3 velocity = new Vector3(speed, 0, 0); var massVolume = MassVolumeDB.NewFromMassAndRadius_AU(mass, radius); var planetInfo = new SystemBodyInfoDB(); var name = new NameDB("Ellie"); var AsteroidDmg = new AsteroidDamageDB(); AsteroidDmg.FractureChance = new PercentValue(0.75f); var dmgPfl = EntityDamageProfileDB.AsteroidDamageProfile(massVolume.Volume_km3, massVolume.Density, massVolume.RadiusInM, 50); var sensorPfil = new SensorProfileDB(); planetInfo.SupportsPopulations = false; planetInfo.BodyType = BodyType.Asteroid; var parent = origOrbit.Parent; var parentMass = parent.GetDataBlob <MassVolumeDB>().Mass; var myMass = massVolume.Mass; double sgp = GameConstants.Science.GravitationalConstant * (parentMass + myMass) / 3.347928976e33; //OrbitDB orbit = OrbitDB.FromVector(parent, myMass, parentMass, sgp, position, velocity, atDateTime); //OrbitDB orbit = (OrbitDB)origOrbit.Clone(); OrbitDB orbit = new OrbitDB(origOrbit.Parent, parentMass, myMass, origOrbit.SemiMajorAxis_AU, origOrbit.Eccentricity, origOrbit.Inclination_Degrees, origOrbit.LongitudeOfAscendingNode_Degrees, origOrbit.ArgumentOfPeriapsis_Degrees, origOrbit.MeanMotion_DegreesSec, origOrbit.Epoch); var posDB = new PositionDB(position.X, position.Y, position.Z, parent.Manager.ManagerGuid, parent); var planetDBs = new List <BaseDataBlob> { posDB, massVolume, planetInfo, name, orbit, AsteroidDmg, dmgPfl, sensorPfil }; Entity newELE = new Entity(origOrbit.OwningEntity.Manager, planetDBs); return(newELE); }
/// <summary> /// creates an asteroid that will collide with the given entity on the given date. /// </summary> /// <param name="starSys"></param> /// <param name="target"></param> /// <param name="collisionDate"></param> /// <returns></returns> public static Entity CreateAsteroid(StarSystem starSys, Entity target, DateTime collisionDate, double asteroidMass = -1.0) { //todo rand these a bit. double radius = Distance.KmToAU(0.5); double mass; if (asteroidMass < 0) { mass = 1.5e+12; //about 1.5 billion tonne } else { mass = asteroidMass; } var speed = 40000; Vector3 velocity = new Vector3(speed, 0, 0); var massVolume = MassVolumeDB.NewFromMassAndRadius_AU(mass, radius); var planetInfo = new SystemBodyInfoDB(); var name = new NameDB("Ellie"); var AsteroidDmg = new AsteroidDamageDB(); AsteroidDmg.FractureChance = new PercentValue(0.75f); var dmgPfl = EntityDamageProfileDB.AsteroidDamageProfile(massVolume.Volume_km3, massVolume.Density, massVolume.RadiusInM, 50); var sensorPfil = new SensorProfileDB(); planetInfo.SupportsPopulations = false; planetInfo.BodyType = BodyType.Asteroid; Vector3 targetPos = OrbitProcessor.GetAbsolutePosition_m(target.GetDataBlob <OrbitDB>(), collisionDate); TimeSpan timeToCollision = collisionDate - StaticRefLib.CurrentDateTime; var parent = target.GetDataBlob <OrbitDB>().Parent; var parentMass = parent.GetDataBlob <MassVolumeDB>().Mass; var myMass = massVolume.Mass; double sgp = OrbitMath.CalculateStandardGravityParameterInM3S2(myMass, parentMass); OrbitDB orbit = OrbitDB.FromVector(parent, myMass, parentMass, sgp, targetPos, velocity, collisionDate); var currentpos = OrbitProcessor.GetAbsolutePosition_AU(orbit, StaticRefLib.CurrentDateTime); var posDB = new PositionDB(currentpos.X, currentpos.Y, currentpos.Z, parent.Manager.ManagerGuid, parent); var planetDBs = new List <BaseDataBlob> { posDB, massVolume, planetInfo, name, orbit, AsteroidDmg, dmgPfl, sensorPfil }; Entity newELE = new Entity(starSys, planetDBs); return(newELE); }
public static Entity CreateNewShipClass(Game game, Entity faction, string className = null) { //check className before any to use it in NameDB constructor if (string.IsNullOrEmpty(className)) { ///< @todo source the class name from faction theme. className = "New Class"; // <- Hack for now. } // lets start by creating all the Datablobs that make up a ship class: TODO only need to add datablobs for compoents it has abilites for. var shipInfo = new ShipInfoDB(); var armor = new ArmorDB(); var buildCost = new BuildCostDB(); var cargotype = new CargoAbleTypeDB(); var crew = new CrewDB(); var damage = new DamageDB(); var maintenance = new MaintenanceDB(); var sensorProfile = new SensorProfileDB(); var name = new NameDB(className); name.SetName(faction.Guid, className); var componentInstancesDB = new ComponentInstancesDB(); var massVolumeDB = new MassVolumeDB(); // now lets create a list of all these datablobs so we can create our new entity: List <BaseDataBlob> shipDBList = new List <BaseDataBlob>() { shipInfo, armor, buildCost, cargotype, crew, damage, maintenance, sensorProfile, name, componentInstancesDB, massVolumeDB, }; // now lets create the ship class: Entity shipClassEntity = new Entity(game.GlobalManager, faction.Guid, shipDBList); FactionOwnerDB factionOwner = faction.GetDataBlob <FactionOwnerDB>(); factionOwner.SetOwned(shipClassEntity); // also gets factionDB: FactionInfoDB factionDB = faction.GetDataBlob <FactionInfoDB>(); // and add it to the faction: factionDB.ShipClasses.Add(shipClassEntity); // now lets set some ship info: shipInfo.ShipClassDefinition = Guid.Empty; // just make sure it is marked as a class and not a ship. // now lets add some components: ///< @todo Add ship components // -- basic armour of current faction tech level // -- minimum crew quaters defaulting to 3 months deployment time. // -- a bridge // -- an engineering space // -- a fuel tank // now update the ship system DBs to reflect the components: ///< @todo update ship to reflect added components return(shipClassEntity); }