Beispiel #1
0
        public static unsafe int GetBoneIndex(Vehicle vehicle, string boneName)
        {
            if (vehicle == null)
            {
                return(-1);
            }

            CVehicle *      veh       = (CVehicle *)vehicle.MemoryAddress;
            crSkeletonData *skelData  = veh->inst->archetype->skeleton->skeletonData;
            uint            boneCount = skelData->bonesCount;

            for (uint i = 0; i < boneCount; i++)
            {
                if (skelData->GetBoneNameForIndex(i) == boneName)
                {
                    return(unchecked ((int)i));
                }
            }

            return(-1);
        }
        // unlike the native/RPH's method, this one works with bones with custom names,
        // for example for a bone named "ladder_base", the native will return -1 but
        // this method will return the proper index.
        public static int GetBoneIndex(Vehicle vehicle, string boneName)
        {
            if (!vehicle)
            {
                throw new InvalidHandleableException(vehicle);
            }

            CVehicle *      veh       = (CVehicle *)vehicle.MemoryAddress;
            crSkeletonData *skelData  = veh->inst->archetype->skeleton->skeletonData;
            uint            boneCount = skelData->bonesCount;

            for (uint i = 0; i < boneCount; i++)
            {
                if (skelData->GetBoneNameForIndex(i) == boneName)
                {
                    return(unchecked ((int)i));
                }
            }

            return(-1);
        }