diff --git a/vMenu/EntitySpawner.cs b/vMenu/EntitySpawner.cs index 47d8cd31..0febb710 100644 --- a/vMenu/EntitySpawner.cs +++ b/vMenu/EntitySpawner.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using CitizenFX.Core; @@ -22,16 +23,16 @@ public class EntitySpawner : BaseScript public EntitySpawner() { #if DEBUG - RegisterCommand("testEntity", new Action>((source, args) => - { - string prop = (string)args[0]; - SpawnEntity(prop, Game.PlayerPed.Position); - }), false); - - RegisterCommand("endTest", new Action(() => - { - FinishPlacement(); - }), false); + RegisterCommand("testEntity", new Action>((source, args) => + { + var prop = (string)args[0]; + SpawnEntity(prop, Game.PlayerPed.Position); + }), false); + + RegisterCommand("endTest", new Action(() => + { + FinishPlacement(); + }), false); #endif } @@ -109,8 +110,8 @@ public static async void FinishPlacement(bool duplicate = false) { if (duplicate) { - int hash = CurrentEntity.Model.Hash; - Vector3 position = CurrentEntity.Position; + var hash = CurrentEntity.Model.Hash; + var position = CurrentEntity.Position; CurrentEntity = null; await Delay(1); // Mandatory SpawnEntity((uint)hash, position); @@ -154,7 +155,7 @@ private void DrawButtons() //TODO: Right keys /// Output direction vector private Vector3 RotationToDirection(Vector3 rotation) { - Vector3 adj = new Vector3( + var adj = new Vector3( (float)Math.PI / 180f * rotation.X, (float)Math.PI / 180f * rotation.Y, (float)Math.PI / 180f * rotation.Z @@ -173,20 +174,20 @@ private Vector3 RotationToDirection(Vector3 rotation) /// destination if no hit was found and coords of hit if there was one private Vector3 GetCoordsPlayerIsLookingAt() { - Vector3 camRotation = GetGameplayCamRot(0); - Vector3 camCoords = GetGameplayCamCoord(); - Vector3 camDirection = RotationToDirection(camRotation); + var camRotation = GetGameplayCamRot(0); + var camCoords = GetGameplayCamCoord(); + var camDirection = RotationToDirection(camRotation); - Vector3 dest = new Vector3( + var dest = new Vector3( camCoords.X + (camDirection.X * RayDistance), camCoords.Y + (camDirection.Y * RayDistance), camCoords.Z + (camDirection.Z * RayDistance) ); - RaycastResult res = World.Raycast(camCoords, dest, IntersectOptions.Everything, Game.PlayerPed); + var res = World.Raycast(camCoords, dest, IntersectOptions.Everything, Game.PlayerPed); #if DEBUG - DrawLine(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y,Game.PlayerPed.Position.Z, dest.X, dest.Y, dest.Z, 255, 0, 0, 255); + DrawLine(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z, dest.X, dest.Y, dest.Z, 255, 0, 0, 255); #endif return res.DitHit ? res.HitPosition : dest; @@ -219,7 +220,7 @@ private async Task MoveHandler() } } - float headingOffset = 0f; + var headingOffset = 0f; while (Active) { if (CurrentEntity == null || !CurrentEntity.Exists()) @@ -228,7 +229,7 @@ private async Task MoveHandler() CurrentEntity = null; break; } - int handle = CurrentEntity.Handle; + var handle = CurrentEntity.Handle; DrawButtons(); @@ -238,7 +239,7 @@ private async Task MoveHandler() SetEntityAlpha(handle, (int)(255 * 0.4), 0); CurrentEntity.Heading = (GetGameplayCamRot(0).Z + headingOffset) % 360f; - Vector3 newPosition = GetCoordsPlayerIsLookingAt(); + var newPosition = GetCoordsPlayerIsLookingAt(); CurrentEntity.Position = newPosition; if (CurrentEntity.HeightAboveGround < 3.0f)