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