예제 #1
0
        private void GetStateFromDynamicData(VehicleEntity vehicle, ShipInternState state)
        {
            var data = (ShipDynamicDataComponent)vehicle.GetDynamicData();

            state.Flag = data.Flag;

            state.IsAccelerated = data.IsAccelerated;
            state.SteerInput    = data.SteerInput;
            state.ThrottleInput = data.ThrottleInput;

            state.Position        = data.Position.ShiftedVector3();
            state.Rotation        = data.Rotation;
            state.IsSleeping      = data.IsSleeping;
            state.LinearVelocity  = data.LinearVelocity;
            state.AngularVelocity = data.AngularVelocity;

            var indexArray = VehicleIndexHelper.GetRudderIndexArray();

            for (int i = 0; i < indexArray.Length; ++i)
            {
                var index = indexArray[i];
                if (ShipEntityUtility.HasRudder(vehicle, index))
                {
                    state.RudderStates[i] = GetRudderState(ShipEntityUtility.GetRudder(vehicle, index));
                }
            }

            data.Clear();
        }
예제 #2
0
        private void SyncStateFromComponentToDWP(VehicleEntity vehicle, ShipInternState state)
        {
            if (!state.IsSet() || SharedConfig.IsOffline)
            {
                return;
            }

            var currentState = GetCurrentState(vehicle);

            currentState.IsFlagSync    = state.IsRemoteSet();
            currentState.IsAccelerated = state.IsAccelerated;
            currentState.RudderInput   = state.SteerInput;
            currentState.ThrottleInput = state.ThrottleInput;

            currentState.Position   = state.Position;
            currentState.Rotation   = state.Rotation;
            currentState.IsSleeping = state.IsSleeping;
            currentState.BodyState.LinearVelocity  = state.LinearVelocity;
            currentState.BodyState.AngularVelocity = state.AngularVelocity;


            var rudderStates = currentState.RudderStates;
            var rudderCount  = rudderStates.Length;

            for (int i = 0; i < rudderCount; ++i)
            {
                var destState   = rudderStates[i];
                var sourceState = state.RudderStates[i];

                destState.Angle = sourceState.Angle;
            }

            ApplyState(vehicle);
        }
예제 #3
0
 private void SetRudderAnglesFromState(AdvancedShipController controller, ShipInternState state)
 {
     var rudders = controller.rudders;
     for (int i = 0; i < rudders.Count; ++i)
     {
         rudders[i].Angle = state.RudderStates[i].Angle;
     }
 }
예제 #4
0
 private void SyncFromComponentToDWP(VehicleEntity vehicle, ShipInternState state)
 {
     if (SharedConfig.DynamicPrediction)
     {
         DynamicSyncFromComponentToDWP(vehicle, state);
     }
     else
     {
         DirectSyncFromComponentToDWP(vehicle, state);
     }
 }
예제 #5
0
        private void DynamicSyncFromComponentToDWP(VehicleEntity vehicle, ShipInternState internalState)
        {
            var controller = GetController(vehicle);
            var state      = VehicleDynamicPredictionUtility.MoveToState(controller, internalState);

            SetRudderAnglesFromState(controller, internalState);
            SetShipInput(controller, internalState);
            VehicleDynamicPredictionUtility.SetControllerState(controller,
                                                               state.Position, state.Rotation,
                                                               state.LinearVelocity, state.AngularVelocity,
                                                               state.IsSleeping, state.SleepingOutSync);
        }
예제 #6
0
 private void DirectSyncFromComponentToDWP(VehicleEntity vehicle, ShipInternState state)
 {
     SyncStateFromComponentToDWP(vehicle, state);
 }
예제 #7
0
 private void SetShipInput(AdvancedShipController controller, ShipInternState state)
 {
     controller.ThrottleInput = state.ThrottleInput;
     controller.RudderInput   = state.SteerInput;
     controller.IsAccelerated = state.IsAccelerated;
 }