Skip to content

Commit

Permalink
Fix missing using
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGrobbe committed Mar 4, 2023
1 parent 7504416 commit f448464
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions vMenu/EntitySpawner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using CitizenFX.Core;
Expand All @@ -22,16 +23,16 @@ public class EntitySpawner : BaseScript
public EntitySpawner()
{
#if DEBUG
RegisterCommand("testEntity", new Action<int, List<object>>((source, args) =>
{
string prop = (string)args[0];
SpawnEntity(prop, Game.PlayerPed.Position);
}), false);
RegisterCommand("endTest", new Action(() =>
{
FinishPlacement();
}), false);
RegisterCommand("testEntity", new Action<int, List<object>>((source, args) =>
{
var prop = (string)args[0];
SpawnEntity(prop, Game.PlayerPed.Position);
}), false);

RegisterCommand("endTest", new Action(() =>
{
FinishPlacement();
}), false);
#endif
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -154,7 +155,7 @@ private void DrawButtons() //TODO: Right keys
/// <returns>Output direction vector</returns>
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
Expand All @@ -173,20 +174,20 @@ private Vector3 RotationToDirection(Vector3 rotation)
/// <returns>destination if no hit was found and coords of hit if there was one</returns>
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;
Expand Down Expand Up @@ -219,7 +220,7 @@ private async Task MoveHandler()
}
}

float headingOffset = 0f;
var headingOffset = 0f;
while (Active)
{
if (CurrentEntity == null || !CurrentEntity.Exists())
Expand All @@ -228,7 +229,7 @@ private async Task MoveHandler()
CurrentEntity = null;
break;
}
int handle = CurrentEntity.Handle;
var handle = CurrentEntity.Handle;

DrawButtons();

Expand All @@ -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)
Expand Down

0 comments on commit f448464

Please sign in to comment.