protected override void DoUpdate(VehicleEntity vehicle)
        {
            var hitBoxComp = vehicle.carHitBox;

            var config = WheelEntityUtility.GetCarConfig(vehicle);

            hitBoxComp.BodyPosition = config.hitBoxRoot.position;
            hitBoxComp.BodyRotation = config.hitBoxRoot.rotation;

            var flexibleCount = config.flexibleHitBoxes.Length;

            for (int i = 0; i < flexibleCount; ++i)
            {
                var flexibleTransform = config.flexibleHitBoxes[i];
                if (flexibleTransform != null)
                {
                    hitBoxComp.FlexiblePositionList[i] = flexibleTransform.position;
                    hitBoxComp.FlexibleRotationList[i] = flexibleTransform.rotation;
                }
            }

            var hitBoxList = config.wheelHitBoxes;
            int wheelCount = hitBoxList.Length;

            for (int i = 0; i < wheelCount; i++)
            {
                var hitBoxTransform = config.wheelHitBoxes[i].GetHitBoxRoot();
                if (hitBoxTransform != null)
                {
                    hitBoxComp.WheelPositionList[i] = hitBoxTransform.position;
                    hitBoxComp.WheelRotationList[i] = hitBoxTransform.rotation;
                }
            }
        }
        private void OnWheelHpChange(VehicleEntity vehicle, VehiclePartIndex index)
        {
            if (!WheelEntityUtility.HasWheel(vehicle, index))
            {
                return;
            }

            if (vehicle.carGameData.GetWheelHp(index) <= 0.0f)
            {
                if (_isServer)
                {
                    vehicle.vehicleBrokenFlag.SetVehiclePartBroken(index);
                }
                else
                {
                    WheelEntityEffectUtility.PlayWheelExplosion(vehicle, index);

                    if (_isOffline)
                    {
                        vehicle.vehicleBrokenFlag.SetVehiclePartBroken(index);
                    }
                }
            }
            else
            {
                if (!_isServer && !_isOffline)
                {
                    WheelEntityEffectUtility.EnableWheelRender(vehicle, index, true);
                }
            }
        }
        protected override void OnBodyBroken(VehicleEntity vehicle)
        {
            var comp       = vehicle.vehicleBrokenFlag;
            var indexArray = VehicleIndexHelper.GetWheelIndexArray();

            foreach (var index in indexArray)
            {
                if (WheelEntityUtility.HasWheel(vehicle, index) &&
                    comp.IsVehiclePartBroken(index) &&
                    !comp.IsVehiclePartColliderBroken(index))
                {
                    SetWheelBroken(vehicle, index);
                }
            }
        }
示例#4
0
        public bool IsWheelBrokeByIndex(VehiclePartIndex index, out VehicleUiWheelIndex uiIndex)
        {
            AssertUtility.Assert(IsOnVehicle);

            uiIndex = VehicleUiWheelIndex.None;
            var vehicle = GetCurrentVehicle();

            if (vehicle != null && vehicle.IsCar())
            {
                uiIndex = WheelEntityUtility.GetUiWheelIndex(vehicle, index);
                return(vehicle.vehicleBrokenFlag.IsVehiclePartBroken(index));
            }

            return(false);
        }