void SetOrbitHere(Entity entity, PositionDB positionDB, WarpMovingDB moveDB, DateTime atDateTime) { //propulsionDB.CurrentVectorMS = new Vector3(0, 0, 0); double targetSOI = OrbitProcessor.GetSOI_m(moveDB.TargetEntity); Entity targetEntity; if (moveDB.TargetEntity.GetDataBlob <PositionDB>().GetDistanceTo_m(positionDB) > targetSOI) { targetEntity = moveDB.TargetEntity.GetDataBlob <OrbitDB>().Parent; //TODO: it's concevable we could be in another SOI not the parent (ie we could be in a target's moon's SOI) } else { targetEntity = moveDB.TargetEntity; } OrbitDB targetOrbit = targetEntity.GetDataBlob <OrbitDB>(); Vector3 insertionVector_m = OrbitProcessor.GetOrbitalInsertionVector_m(moveDB.SavedNewtonionVector, targetOrbit, atDateTime); positionDB.SetParent(targetEntity); if (moveDB.ExpendDeltaV.Length() != 0) { NewtonThrustCommand.CreateCommand(entity.FactionOwner, entity, entity.StarSysDateTime, moveDB.ExpendDeltaV); entity.RemoveDataBlob <WarpMovingDB>(); moveDB.IsAtTarget = true; } else { OrbitDB newOrbit = OrbitDB.FromVelocity_m(targetEntity, entity, insertionVector_m, atDateTime); entity.RemoveDataBlob <WarpMovingDB>(); if (newOrbit.Apoapsis < targetSOI) //furtherst point within soi, normal orbit { entity.SetDataBlob(newOrbit); } else if (newOrbit.Periapsis > targetSOI) //closest point outside soi { //find who's SOI we are in, and create an orbit around that. targetEntity = OrbitProcessor.FindSOIForPosition((StarSystem)entity.Manager, positionDB.AbsolutePosition_m); newOrbit = OrbitDB.FromVelocity_m(targetEntity, entity, insertionVector_m, atDateTime); entity.SetDataBlob(newOrbit); } else //closest point inside soi, but furtherest point outside. make a newtonion trajectory. { var newtmove = new NewtonMoveDB(targetEntity, insertionVector_m); entity.SetDataBlob(newtmove); } positionDB.SetParent(targetEntity); moveDB.IsAtTarget = true; } }
public TranslationMoveVM(Game game, CommandReferences cmdRef, Entity entity) { _tMoveDB = entity.GetDataBlob <WarpMovingDB>(); _posDB = entity.GetDataBlob <PositionDB>(); //_propDB = entity.GetDataBlob<PropulsionAbilityDB>(); _cmdRef = cmdRef; TargetList.SelectionChangedEvent += OnTargetSelectonChange; Entity faction; entity.Manager.FindEntityByGuid(entity.FactionOwner, out faction); UpdateTargetList(faction, entity.Manager); }
/* * private static void SetOrbitClone(OrbitDB detectedEntitesOrbit, SensorInfoDB sensorInfo) * { * * //var quality = sensorInfo.HighestDetectionQuality.detectedSignalQuality.Percent; //quality shouldn't affect positioning. * double signalBestMagnatude = sensorInfo.HighestDetectionQuality.SignalStrength_kW; * double signalNowMagnatude = sensorInfo.LatestDetectionQuality.SignalStrength_kW; * if (signalNowMagnatude > 0) * { * OrbitDB sensorEntityOrbit = GenericClone<OrbitDB>(detectedEntitesOrbit, sensorInfo); * //tweak add some random noise to the ecentricity etc of the sensorEntityOrbit depending on magnatude; * } * } */ private static void SetTranslateClone(WarpMovingDB detectedEntitiesMove, SensorInfoDB sensorInfo) { //var quality = sensorInfo.HighestDetectionQuality.detectedSignalQuality.Percent; //quality shouldn't affect positioning. //double signalBestMagnatude = sensorInfo.HighestDetectionQuality.detectedSignalStrength_kW; double signalNowMagnatude = sensorInfo.LatestDetectionQuality.SignalStrength_kW; if (signalNowMagnatude > 0.0) { var sensorEntityMove = GenericClone <WarpMovingDB>(detectedEntitiesMove, sensorInfo); sensorEntityMove.TargetPositionDB = null; //the sensorEntity shouldn't know the final destination. Vector3 velocityDetectionInacuracy = new Vector3() { }; //some random noise depending on quality value sensorEntityMove.CurrentNonNewtonionVectorMS = detectedEntitiesMove.CurrentNonNewtonionVectorMS + velocityDetectionInacuracy; } }
internal override void ActionCommand(DateTime atDateTime) { if (!IsRunning) { var warpDB = _entityCommanding.GetDataBlob <WarpAbilityDB>(); var powerDB = _entityCommanding.GetDataBlob <EnergyGenAbilityDB>(); Guid eType = warpDB.EnergyType; double estored = powerDB.EnergyStored[eType]; double creationCost = warpDB.BubbleCreationCost; if (creationCost <= estored) { _db = new WarpMovingDB(_entityCommanding, _targetEntity, TargetOffsetPosition_m); _db.ExpendDeltaV = ExpendDeltaV; if (EntityCommanding.HasDataBlob <OrbitDB>()) { EntityCommanding.RemoveDataBlob <OrbitDB>(); } if (EntityCommanding.HasDataBlob <NewtonMoveDB>()) { EntityCommanding.RemoveDataBlob <NewtonMoveDB>(); } EntityCommanding.SetDataBlob(_db); WarpMoveProcessor.StartNonNewtTranslation(EntityCommanding); IsRunning = true; //debug code: double distance = (_db.EntryPointAbsolute - _db.ExitPointAbsolute).Length(); double time = distance / _entityCommanding.GetDataBlob <WarpAbilityDB>().MaxSpeed; //Assert.AreEqual((_db.PredictedExitTime - _db.EntryDateTime).TotalSeconds, time, 1.0e-10); } } }