void OnEntityChange(EntityState entity)
        {
            OrderingEntity    = entity;
            _actionDateTime   = _uiState.PrimarySystemDateTime;
            _orderEntityOrbit = entity.Entity.GetDataBlob <OrbitDB>();

            _massParentBody     = _orderEntityOrbit.Parent.GetDataBlob <MassVolumeDB>().Mass;
            _massOrderingEntity = OrderingEntity.Entity.GetDataBlob <MassVolumeDB>().Mass;
            _stdGravParam_m     = OrbitMath.CalculateStandardGravityParameterInM3S2(_massOrderingEntity, _massParentBody);

            _positonAtChange_m = OrbitProcessor.GetPosition_m(_orderEntityOrbit, _actionDateTime);
            var velAtChange2d = OrbitProcessor.GetOrbitalVector_m(_orderEntityOrbit, _actionDateTime);

            _orbitalVelocityAtChange_m = new Vector3(velAtChange2d.X, velAtChange2d.Y, 0);
            _origionalAngle            = Math.Atan2(_orbitalVelocityAtChange_m.X, _orbitalVelocityAtChange_m.Y);


            var newtondb = entity.Entity.GetDataBlob <NewtonThrustAbilityDB>();

            _newtonUI = new NewtonionOrderUI(newtondb, _massOrderingEntity);



            IsActive = true;
        }
Exemple #2
0
        void EntitySelected()
        {
            OrderingEntityState = _uiState.LastClickedEntity;

            if (OrderingEntityState.Entity.HasDataBlob <OrbitDB>())
            {
                _massCurrentBody = Entity.GetSOIParentEntity(OrderingEntityState.Entity).GetDataBlob <MassVolumeDB>().MassDry;
            }
            else
            {
                var foo = OrderingEntityState.Entity.GetDataBlob <NewtonMoveDB>();
                if (foo == null)
                {
                }
                else
                {
                    _massCurrentBody = foo.ParentMass;
                }
            }

            //else if(OrderingEntity.Entity.HasDataBlob<newton>())
            CurrentState = States.NeedsTarget;

            _massOrderingEntity      = OrderingEntityState.Entity.GetDataBlob <MassVolumeDB>().MassDry;
            _stdGravParamCurrentBody = GameConstants.Science.GravitationalConstant * (_massCurrentBody + _massOrderingEntity) / 3.347928976e33;
            if (_moveWidget == null)
            {
                _moveWidget = new WarpMoveOrderWidget(_uiState, OrderingEntityState.Entity);
                _uiState.SelectedSysMapRender.UIWidgets.Add(nameof(_moveWidget), _moveWidget);
            }
            DepartureCalcs();

            if (OrderingEntityState.Entity.HasDataBlob <NewtonThrustAbilityDB>())
            {
                var db = OrderingEntityState.Entity.GetDataBlob <NewtonThrustAbilityDB>();
                _newtonUI = new NewtonionOrderUI(db, _massOrderingEntity);
            }

            //debug code:
            //var sgpCur = _orderEntityOrbit.GravitationalParameterAU;
            //var ralitiveVel1 = OrbitProcessor.InstantaneousOrbitalVelocityVector_AU(_orderEntityOrbit, _departureDateTime);
            //var ralPosCBAU = OrderingEntityState.Entity.GetDataBlob<PositionDB>().RelativePosition_AU;
            //var smaCurrOrbtAU = _orderEntityOrbit.SemiMajorAxisAU;
            //var ralitiveVel2 = OrbitMath.PreciseOrbitalVelocityVector(_stdGravParamCurrentBody, ralPosCBAU, smaCurrOrbtAU, _orderEntityOrbit.Eccentricity, _orderEntityOrbit.LongitudeOfAscendingNode + _orderEntityOrbit.ArgumentOfPeriapsis);
        }