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)); } }
private async Task ToggleSpotlight() { var vehicle = API.GetVehiclePedIsIn(API.GetPlayerPed(-1), false); if (API.GetVehicleClass(vehicle) == 18 || !Config.GetValueBool(Config.EMERGENCY_ONLY, true)) { if (IsSpotlightEnabled(vehicle)) { API.DecorSetBool(vehicle, DECOR_NAME_STATUS, false); API.DecorSetFloat(vehicle, DECOR_NAME_BRIGHTNESS, 0f); } else { API.DecorSetBool(vehicle, DECOR_NAME_STATUS, true); await TranslateDecorSmoothly(vehicle, DECOR_NAME_BRIGHTNESS, 0f, Config.GetValueFloat(Config.BRIGHTNESS_LEVEL, 30f), 30); } } await Task.FromResult(0); }
private static bool IsSpotlightUsageAllowed(int handle) { int vehicleClass = API.GetVehicleClass(handle); bool isHelicopter = vehicleClass == 15; bool isEmergency = vehicleClass == 18; if (isHelicopter) { if (Config.GetValueBool(Config.HELICOPTER_SUPPORT, true)) { if (Config.GetValueBool(Config.HELICOPTER_POLMAV_ONLY, false)) { if (API.IsVehicleModel(handle, (uint)API.GetHashKey("polmav"))) { return(true); } return(false); } else { return(true); } } else { return(false); } } if (VehicleHasRotatableTargetBone(handle) && Config.GetValueBool(Config.TURRET_SUPPORT, true)) { return(true); } if (isEmergency || !Config.GetValueBool(Config.EMERGENCY_ONLY, true)) { return(true); } return(true); }
private async Task MoveSpotlightHorizontal(bool left) { var vehicle = API.GetVehiclePedIsIn(API.GetPlayerPed(-1), Config.GetValueBool(Config.REMOTE_CONTROL, true)); var current = API.DecorGetFloat(vehicle, DECOR_NAME_XY); bool isHeli = API.GetVehicleClass(vehicle) == 15; if (left) { if (isHeli || current <= Config.GetValueFloat(Config.RANGE_LEFT, 90f)) { await TranslateDecorSmoothly(vehicle, DECOR_NAME_XY, current, current + 10f, 10); } } else { if (isHeli || current >= -Config.GetValueFloat(Config.RANGE_RIGHT, 30f)) { await TranslateDecorSmoothly(vehicle, DECOR_NAME_XY, current, current - 10f, 10); } } }