void CloseWindow() { IsActive = false; CurrentState = States.NeedsEntity; _state.SelectedSystem.ManagerSubpulses.SystemDateChangedEvent -= OnSystemDateTimeChange; if (_orbitWidget != null) { _state.SelectedSysMapRender.UIWidgets.Remove(nameof(_orbitWidget)); _orbitWidget = null; } if (_moveWidget != null) { _state.SelectedSysMapRender.UIWidgets.Remove(nameof(_moveWidget)); _moveWidget = null; } }
void EntitySelected() { OrderingEntity = _state.LastClickedEntity; _orderEntityOrbit = OrderingEntity.Entity.GetDataBlob <OrbitDB>(); CurrentState = States.NeedsTarget; _massCurrentBody = _orderEntityOrbit.Parent.GetDataBlob <MassVolumeDB>().Mass; _massOrderingEntity = OrderingEntity.Entity.GetDataBlob <MassVolumeDB>().Mass; _stdGravParamCurrentBody = GameConstants.Science.GravitationalConstant * (_massCurrentBody + _massOrderingEntity) / 3.347928976e33; if (_moveWidget == null) { _moveWidget = new TranslateMoveOrderWidget(_state, OrderingEntity.Entity); _state.SelectedSysMapRender.UIWidgets.Add(nameof(_moveWidget), _moveWidget); } DepartureCalcs(); //debug code: var sgpCur = _orderEntityOrbit.GravitationalParameterAU; var ralitiveVel1 = OrbitProcessor.InstantaneousOrbitalVelocityVector(_orderEntityOrbit, _departureDateTime); var ralPosCBAU = OrderingEntity.Entity.GetDataBlob <PositionDB>().RelativePosition_AU; var smaCurrOrbtAU = _orderEntityOrbit.SemiMajorAxis; //var ralitiveVel2 = OrbitMath.PreciseOrbitalVelocityVector(_stdGravParamCurrentBody, ralPosCBAU, smaCurrOrbtAU, _orderEntityOrbit.Eccentricity, _orderEntityOrbit.LongitudeOfAscendingNode + _orderEntityOrbit.ArgumentOfPeriapsis); }
private OrbitOrderWindow(EntityState entity, bool smMode = false) { OrderingEntity = entity; _smMode = smMode; IsActive = true; _displayText = "Orbit Order: " + OrderingEntity.Name; _tooltipText = "Select target to orbit"; CurrentState = States.NeedsTarget; //TargetEntity = new EntityState(Entity.InvalidEntity) { Name = "" }; if (OrderingEntity.Entity.HasDataBlob <OrbitDB>()) { //_orbitWidget = new OrbitOrderWiget(OrderingEntity.Entity.GetDataBlob<OrbitDB>()); //_state.MapRendering.UIWidgets.Add(_orbitWidget); if (_moveWidget == null) { _moveWidget = new TranslateMoveOrderWidget(_state, OrderingEntity.Entity); _state.SelectedSysMapRender.UIWidgets.Add(nameof(_moveWidget), _moveWidget); } } if (OrderingEntity.Entity.HasDataBlob <PropulsionAbilityDB>()) { var propDB = OrderingEntity.Entity.GetDataBlob <PropulsionAbilityDB>(); _maxDV = propDB.RemainingDV_MS; } fsm = new Action[4, 4] { //selectEntity selectPos clickAction altClick { DoNothing, DoNothing, DoNothing, AbortOrder, }, //needsEntity { TargetSelected, DoNothing, DoNothing, GoBackState, }, //needsTarget { DoNothing, InsertionPntSelected, DoNothing, GoBackState, }, //needsApopapsis //{DoNothing, PeriapsisPntSelected, DoNothing, GoBackState, }, //needsPeriapsis { DoNothing, DoNothing, ActionCmd, GoBackState, } //needsActoning }; }