2020-05-31 19:07:22 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SanAndreasUnity.Behaviours;
|
2020-06-20 16:18:09 +02:00
|
|
|
|
using System.Linq;
|
2021-02-22 20:21:14 +01:00
|
|
|
|
using SanAndreasUnity.Behaviours.Vehicles;
|
2020-05-31 19:07:22 +02:00
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.UI {
|
|
|
|
|
|
|
|
|
|
public class UtilitiesWindow : PauseMenuWindow {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UtilitiesWindow() {
|
|
|
|
|
|
|
|
|
|
// set default parameters
|
|
|
|
|
|
|
|
|
|
this.windowName = "Utilities";
|
|
|
|
|
this.useScrollView = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start () {
|
|
|
|
|
|
|
|
|
|
this.RegisterButtonInPauseMenu ();
|
|
|
|
|
|
|
|
|
|
// adjust rect
|
2019-07-27 01:34:55 +02:00
|
|
|
|
float width = 240;
|
2019-07-29 00:58:50 +02:00
|
|
|
|
float height = 210;
|
2019-07-28 22:38:10 +02:00
|
|
|
|
if (Utilities.F.ScreenHasHighDensity)
|
|
|
|
|
{
|
2019-07-29 00:58:50 +02:00
|
|
|
|
width = Screen.width * 0.375f;
|
|
|
|
|
height = Screen.height * 0.4f;
|
2019-07-28 22:38:10 +02:00
|
|
|
|
}
|
|
|
|
|
this.windowRect = new Rect(Screen.width / 2 - width / 2, 10, width, height);
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnWindowGUI ()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (Ped.Instance) {
|
|
|
|
|
// display player position
|
|
|
|
|
// Vector2 pos = new Vector2 (_player.transform.position.x + 3000, 6000 - (_player.transform.position.z + 3000));
|
|
|
|
|
GUILayout.Label ("Pos: " + Ped.InstancePos);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 21:01:29 +02:00
|
|
|
|
if (Utilities.NetUtils.IsServer)
|
|
|
|
|
DisplayServerGui();
|
2021-02-22 19:43:17 +01:00
|
|
|
|
else if (Net.Player.Local != null)
|
2019-07-06 00:39:47 +02:00
|
|
|
|
DisplayClientOnlyGui();
|
2019-07-05 21:01:29 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisplayServerGui()
|
|
|
|
|
{
|
2019-07-08 21:32:03 +02:00
|
|
|
|
Transform nearbyTransform = Ped.Instance != null ? Ped.Instance.transform : null;
|
2019-07-05 21:01:29 +02:00
|
|
|
|
|
2021-09-13 01:17:17 +02:00
|
|
|
|
if (GUILayout.Button ("Spawn vehicle")) {
|
2019-07-08 23:43:13 +02:00
|
|
|
|
if (Ped.Instance != null)
|
2021-02-22 20:21:14 +01:00
|
|
|
|
Vehicle.CreateRandomInFrontOf(nearbyTransform);
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Change player model"))
|
|
|
|
|
{
|
2021-09-13 01:17:17 +02:00
|
|
|
|
SendCommand("/skin");
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Spawn 5 peds"))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
2021-09-13 00:12:41 +02:00
|
|
|
|
Ped.SpawnPedAI(Ped.RandomPedId, nearbyTransform);
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 01:17:17 +02:00
|
|
|
|
if (GUILayout.Button("Spawn stalker ped"))
|
2020-05-31 19:07:22 +02:00
|
|
|
|
{
|
2021-09-13 01:17:17 +02:00
|
|
|
|
SendCommand("/stalker");
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 00:24:26 +02:00
|
|
|
|
if (GUILayout.Button("Spawn enemy ped"))
|
|
|
|
|
{
|
|
|
|
|
SendCommand("/enemy");
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 19:07:22 +02:00
|
|
|
|
if (GUILayout.Button("Destroy all vehicles"))
|
|
|
|
|
{
|
2020-06-20 16:18:09 +02:00
|
|
|
|
var vehicles = Behaviours.Vehicles.Vehicle.AllVehicles.ToArray();
|
2019-06-24 00:31:53 +02:00
|
|
|
|
|
2020-05-31 19:07:22 +02:00
|
|
|
|
foreach (var v in vehicles) {
|
2020-06-20 16:18:09 +02:00
|
|
|
|
v.Explode();
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 19:43:17 +01:00
|
|
|
|
void SendCommand(string command)
|
2019-07-06 00:39:47 +02:00
|
|
|
|
{
|
2021-02-22 19:43:17 +01:00
|
|
|
|
Chat.ChatManager.SendChatMessageToAllPlayersAsLocalPlayer(command);
|
|
|
|
|
}
|
2019-07-06 00:39:47 +02:00
|
|
|
|
|
2021-02-22 19:43:17 +01:00
|
|
|
|
void DisplayClientOnlyGui()
|
|
|
|
|
{
|
2019-07-06 00:39:47 +02:00
|
|
|
|
|
2019-07-08 21:48:06 +02:00
|
|
|
|
if (GUILayout.Button("Request vehicle"))
|
2019-07-06 00:39:47 +02:00
|
|
|
|
{
|
2021-02-22 19:53:41 +01:00
|
|
|
|
SendCommand("/veh");
|
2019-07-06 00:39:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 21:48:06 +02:00
|
|
|
|
if (GUILayout.Button("Request ped model change"))
|
2019-07-06 00:39:47 +02:00
|
|
|
|
{
|
2021-02-22 19:43:17 +01:00
|
|
|
|
SendCommand("/skin");
|
2019-07-06 00:39:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GUILayout.Button("Request suicide"))
|
|
|
|
|
{
|
2021-02-22 19:43:17 +01:00
|
|
|
|
SendCommand("/suicide");
|
2019-07-06 00:39:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 21:48:06 +02:00
|
|
|
|
if (GUILayout.Button("Request ped stalker"))
|
2019-07-08 21:45:33 +02:00
|
|
|
|
{
|
2021-02-22 19:43:17 +01:00
|
|
|
|
SendCommand("/stalker");
|
2019-07-08 21:45:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 00:24:26 +02:00
|
|
|
|
if (GUILayout.Button("Request enemy ped"))
|
|
|
|
|
{
|
|
|
|
|
SendCommand("/enemy");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-09 00:16:10 +02:00
|
|
|
|
if (GUILayout.Button("Request to destroy my vehicles"))
|
2019-07-06 00:39:47 +02:00
|
|
|
|
{
|
2021-02-22 19:43:17 +01:00
|
|
|
|
SendCommand("/dveh");
|
2019-07-06 00:39:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 19:07:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|