예제 #1
0
        private async Task OnTick()
        {
            foreach (var vehicle in World.GetAllVehicles())
            {
                var handle = vehicle.Handle;
                if (IsSpotlightEnabled(handle))
                {
                    var door                  = API.GetEntityBoneIndexByName(handle, "door_dside_f");
                    var coords                = API.GetWorldPositionOfEntityBone(handle, door);
                    var doorCoords            = API.GetWorldPositionOfEntityBone(handle, door);
                    var carHeadingVector      = (Vector2)API.GetEntityForwardVector(handle);
                    var carHeadingVectorAngle = AngleConverter(Convert.ToDouble(carHeadingVector.X), Convert.ToDouble(carHeadingVector.Y));

                    SetSpotlightDefaultsIfNull(handle);

                    var finalVector = new Vector3(
                        new Vector2(
                            Convert.ToSingle(Math.Cos((carHeadingVectorAngle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131)),
                            Convert.ToSingle(Math.Sin((carHeadingVectorAngle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131))
                            ),
                        API.DecorGetFloat(handle, DECOR_NAME_Z)
                        );

                    API.DrawSpotLight(coords.X, doorCoords.Y, coords.Z + 0.35f, finalVector.X, finalVector.Y, finalVector.Z, 221, 221, 221, 70.0f, API.DecorGetFloat(handle, DECOR_NAME_BRIGHTNESS), 4.3f, 15.0f, 28.6f);
                }
            }
            await Task.FromResult(0);
        }
예제 #2
0
        private static Vector3 GetDirectionalCoordinates(int handle, string bone)
        {
            if (bone == "door_dside_f") // target bone is not rotatable, use default orientation
            {
                Vector2 vehicleHeading      = (Vector2)API.GetEntityForwardVector(handle);
                double  vehicleHeadingAngle = Utilities.DirectionToAngle(Convert.ToDouble(vehicleHeading.X), Convert.ToDouble(vehicleHeading.Y));

                return(new Vector3(
                           new Vector2(
                               Convert.ToSingle(Math.Cos((vehicleHeadingAngle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131)),
                               Convert.ToSingle(Math.Sin((vehicleHeadingAngle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131))
                               ),
                           API.DecorGetFloat(handle, DECOR_NAME_Z)
                           ));
            }
            else // target bone is rotatable, convert to direction
            {
                Vector3 boneHeading = API.GetWorldRotationOfEntityBone(handle, API.GetEntityBoneIndexByName(handle, bone));

                if (API.GetVehicleClass(handle) == 15) // helicopters retain manual offset
                {
                    double angle = Utilities.DirectionToAngle((Vector2)Utilities.RotationToDirection(boneHeading));

                    return(new Vector3(
                               new Vector2(
                                   Convert.ToSingle(Math.Cos((angle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131)),
                                   Convert.ToSingle(Math.Sin((angle + API.DecorGetFloat(handle, DECOR_NAME_XY)) / 57.2957795131))
                                   ),
                               API.DecorGetFloat(handle, DECOR_NAME_Z)
                               ));
                }

                return(Utilities.RotationToDirection(boneHeading));
            }
        }
예제 #3
0
 private static string GetBaseBone(int handle)
 {
     foreach (string bone in TRACKER_BONES)
     {
         var boneIndex = API.GetEntityBoneIndexByName(handle, bone);
         if (boneIndex != -1)
         {
             return(bone);
         }
     }
     return("door_dside_f");
 }
예제 #4
0
 private static Vector3 GetBaseCoordinates(int handle, string bone)
 {
     return(API.GetWorldPositionOfEntityBone(handle, API.GetEntityBoneIndexByName(handle, bone)));
 }