示例#1
0
        public virtual void SetFrom(VehicleEntity vehicle)
        {
            var comp = (CarDynamicDataComponent)vehicle.GetDynamicData();

            Flag = comp.Flag;

            IsHornOn       = comp.IsHornOn;
            HandbrakeInput = comp.HandbrakeInput;
            IsAccelerated  = comp.IsAccelerated;
            SteerInput     = comp.SteerInput;
            ThrottleInput  = comp.ThrottleInput;

            Position        = comp.Position;
            Rotation        = comp.Rotation;
            LinearVelocity  = comp.LinearVelocity;
            AngularVelocity = comp.AngularVelocity;
            IsSleeping      = comp.IsSleeping;

            var indexArray = VehicleIndexHelper.GetWheelIndexArray();

            for (int i = 0; i < indexArray.Length; ++i)
            {
                var index = indexArray[i];
                if (WheelEntityUtility.HasWheel(vehicle, index))
                {
                    GetWheelState(WheelEntityUtility.GetWheel(vehicle, index), Wheels[i]);
                }
            }
        }
示例#2
0
        public virtual void FromStateToComponent(VehicleAbstractState state, VehicleEntity vehicle)
        {
            var comp = vehicle.GetDynamicData();

            comp.Flag = (int)VehicleFlag.LocalSet;

            comp.IsAccelerated = state.IsAccelerated;
            comp.SteerInput    = state.SteerInput;
            comp.ThrottleInput = state.ThrottleInput;

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

            var wheelCount = state.WheelStates.Length;
            var indexArray = VehicleIndexHelper.GetWheelIndexArray();

            AssertUtility.Assert(wheelCount <= indexArray.Length);
            for (int i = 0; i < wheelCount; ++i)
            {
                var index = indexArray[i];
                if (WheelEntityUtility.HasWheel(vehicle, index))
                {
                    SetWheel(vehicle, index, state.WheelStates[i]);
                }
            }
        }
示例#3
0
        protected override void SetWheel(VehicleEntity vehicle, VehiclePartIndex index, WheelAbstractState state)
        {
            base.SetWheel(vehicle, index, state);

            var fromState = (WheelState)state;
            var comp      = WheelEntityUtility.GetWheel(vehicle, index);

            comp.SteerAngle = fromState.SteerAngle;
        }
示例#4
0
        protected virtual void SetWheel(VehicleEntity vehicle, VehiclePartIndex index, WheelAbstractState state)
        {
            var comp = WheelEntityUtility.GetWheel(vehicle, index);

            comp.ColliderSteerAngle = state.ColliderSteerAngle;
        }