SanAndreasUnity/Assets/Scripts/Behaviours/UIVehicleSpawner.cs

37 lines
801 B
C#
Raw Normal View History

2020-05-31 19:07:22 +02:00
using SanAndreasUnity.Behaviours;
using UnityEngine;
2019-07-06 00:55:42 +02:00
namespace SanAndreasUnity.Behaviours
2020-05-31 19:07:22 +02:00
{
2019-07-06 00:55:42 +02:00
public class UIVehicleSpawner : MonoBehaviour
2020-05-31 19:07:22 +02:00
{
2019-07-06 00:55:42 +02:00
public KeyCode spawnKey = KeyCode.V;
2020-05-31 19:07:22 +02:00
2019-07-06 00:55:42 +02:00
private void Update()
{
if (Input.GetKeyDown(spawnKey) && GameManager.CanPlayerReadInput())
2019-07-06 00:55:42 +02:00
{
if (Utilities.NetUtils.IsServer)
SpawnVehicle();
else if (Net.PlayerRequests.Local != null)
Net.PlayerRequests.Local.RequestVehicleSpawn(-1);
2019-07-06 00:55:42 +02:00
}
}
2020-05-31 19:07:22 +02:00
private void SpawnVehicle()
2019-07-06 00:55:42 +02:00
{
var ped = Ped.Instance;
2020-05-31 19:07:22 +02:00
2019-07-06 00:55:42 +02:00
if (null == ped)
return;
Vehicles.Vehicle.CreateRandomInFrontOf(ped.transform);
2019-07-06 00:55:42 +02:00
}
2019-07-05 23:46:59 +02:00
}
2019-07-06 00:55:42 +02:00
}