2020-05-31 17:07:22 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using SanAndreasUnity.UI;
|
|
|
|
|
using SanAndreasUnity.Utilities;
|
|
|
|
|
using SanAndreasUnity.Behaviours;
|
|
|
|
|
using SanAndreasUnity.Behaviours.Weapons;
|
2019-05-05 23:45:33 +00:00
|
|
|
|
using SanAndreasUnity.Behaviours.Vehicles;
|
2021-07-23 22:27:02 +00:00
|
|
|
|
using SanAndreasUnity.Net;
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Settings {
|
|
|
|
|
|
2021-07-23 22:27:02 +00:00
|
|
|
|
public class MiscSettings : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
static string s_playerName = Player.DefaultPlayerName;
|
|
|
|
|
|
|
|
|
|
OptionsWindow.StringInput m_playerNameInput = new OptionsWindow.StringInput
|
|
|
|
|
{
|
|
|
|
|
description = "Player name",
|
|
|
|
|
displayWidth = 200,
|
|
|
|
|
maxNumCharacters = Player.MaxPlayerNameLength,
|
|
|
|
|
getValue = () => s_playerName,
|
|
|
|
|
setValue = ApplyPlayerName,
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
};
|
2020-05-31 17:07:22 +00:00
|
|
|
|
OptionsWindow.FloatInput m_timeScaleInput = new OptionsWindow.FloatInput( "Time scale", 0f, 4f ) {
|
|
|
|
|
getValue = () => Time.timeScale,
|
2019-06-22 20:37:21 +00:00
|
|
|
|
setValue = (value) => { Time.timeScale = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.None
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
2019-07-27 16:42:50 +00:00
|
|
|
|
OptionsWindow.FloatInput m_physicsUpdateRate = new OptionsWindow.FloatInput( "Physics update rate", 3f, 100f ) {
|
2019-07-29 16:29:56 +00:00
|
|
|
|
getValue = () => 1.0f / Time.fixedDeltaTime,
|
2019-07-27 16:42:50 +00:00
|
|
|
|
setValue = (value) => { Time.fixedDeltaTime = 1.0f / value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
};
|
2020-05-31 17:07:22 +00:00
|
|
|
|
OptionsWindow.FloatInput m_gravityInput = new OptionsWindow.FloatInput( "Gravity", -10f, 50f ) {
|
|
|
|
|
getValue = () => -Physics.gravity.y,
|
|
|
|
|
setValue = (value) => { Physics.gravity = new Vector3(Physics.gravity.x, -value, Physics.gravity.z); },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
|
|
|
|
OptionsWindow.BoolInput m_displayMinimapInput = new OptionsWindow.BoolInput ("Display minimap") {
|
|
|
|
|
isAvailable = () => MiniMap.Instance != null,
|
|
|
|
|
getValue = () => MiniMap.Instance.gameObject.activeSelf,
|
|
|
|
|
setValue = (value) => { MiniMap.Instance.gameObject.SetActive (value); },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.AfterLoaderFinishes
|
|
|
|
|
};
|
|
|
|
|
OptionsWindow.BoolInput m_runInBackgroundInput = new OptionsWindow.BoolInput ("Run in background") {
|
|
|
|
|
getValue = () => Application.runInBackground,
|
|
|
|
|
setValue = (value) => { Application.runInBackground = value; },
|
2019-06-22 20:36:42 +00:00
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
OptionsWindow.BoolInput m_drawLineFromGunInput = new OptionsWindow.BoolInput ("Draw line from gun") {
|
|
|
|
|
isAvailable = () => WeaponsManager.Instance != null,
|
|
|
|
|
getValue = () => WeaponsManager.Instance.drawLineFromGun,
|
|
|
|
|
setValue = (value) => { WeaponsManager.Instance.drawLineFromGun = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2020-04-25 19:15:59 +00:00
|
|
|
|
OptionsWindow.BoolInput m_displayFpsInput = new OptionsWindow.BoolInput("Display FPS")
|
|
|
|
|
{
|
|
|
|
|
isAvailable = () => FPSDisplay.Instance != null,
|
2020-04-26 14:30:52 +00:00
|
|
|
|
getValue = () => FPSDisplay.Instance.updateFPS,
|
2020-04-25 19:15:59 +00:00
|
|
|
|
setValue = (value) => { DisplayFPS(value); },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2019-07-26 22:48:02 +00:00
|
|
|
|
// OptionsWindow.IntInput m_imguiFontSize = new OptionsWindow.IntInput ("Imgui font size", 0, 25) {
|
|
|
|
|
// //isAvailable = () => UIManager.Instance != null,
|
|
|
|
|
// getValue = () => UIManager.Instance.ImguiFontSize,
|
|
|
|
|
// setValue = (value) => { UIManager.Instance.ImguiFontSize = value; GUIUtility.ExitGUI(); },
|
|
|
|
|
// persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
// };
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2019-05-22 20:43:15 +00:00
|
|
|
|
OptionsWindow.BoolInput m_enableCamera = new OptionsWindow.BoolInput ("Enable camera") {
|
|
|
|
|
getValue = () => Camera.main != null && Camera.main.enabled,
|
|
|
|
|
setValue = (value) => { Camera cam = F.FindMainCameraEvenIfDisabled(); if (cam != null) cam.enabled = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.None,
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-26 00:03:13 +00:00
|
|
|
|
OptionsWindow.BoolInput m_pausePlayerSpawning = new OptionsWindow.BoolInput ("Pause player spawning") {
|
2019-06-25 23:55:16 +00:00
|
|
|
|
isAvailable = () => SpawnManager.Instance != null,
|
|
|
|
|
getValue = () => SpawnManager.Instance.IsSpawningPaused,
|
|
|
|
|
setValue = (value) => { SpawnManager.Instance.IsSpawningPaused = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2019-06-26 00:03:13 +00:00
|
|
|
|
OptionsWindow.FloatInput m_playerSpawnInterval = new OptionsWindow.FloatInput ("Player spawn interval", 0, 30) {
|
|
|
|
|
isAvailable = () => SpawnManager.Instance != null,
|
|
|
|
|
getValue = () => SpawnManager.Instance.spawnInterval,
|
|
|
|
|
setValue = (value) => { SpawnManager.Instance.spawnInterval = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2020-12-26 16:40:30 +00:00
|
|
|
|
OptionsWindow.FloatInput m_projectileReloadTime = new OptionsWindow.FloatInput ("Projectile reload time", 0, 5) {
|
|
|
|
|
isAvailable = () => WeaponsManager.Instance != null,
|
|
|
|
|
getValue = () => WeaponsManager.Instance.projectileReloadTime,
|
|
|
|
|
setValue = (value) => { WeaponsManager.Instance.projectileReloadTime = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2020-12-28 00:41:11 +00:00
|
|
|
|
OptionsWindow.FloatInput m_vehicleDetachedPartLifetime = new OptionsWindow.FloatInput ("Vehicle's detached part lifetime", 10, 120) {
|
|
|
|
|
isAvailable = () => VehicleManager.Instance != null,
|
|
|
|
|
getValue = () => VehicleManager.Instance.explosionLeftoverPartsLifetime,
|
|
|
|
|
setValue = (value) => { VehicleManager.Instance.explosionLeftoverPartsLifetime = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
|
|
|
|
};
|
2021-01-02 19:46:19 +00:00
|
|
|
|
OptionsWindow.BoolInput m_showSpeedometerInput = new OptionsWindow.BoolInput() {
|
|
|
|
|
description = "Show speedometer",
|
|
|
|
|
isAvailable = () => PedManager.Instance != null,
|
|
|
|
|
getValue = () => PedManager.Instance.showPedSpeedometer,
|
|
|
|
|
setValue = (value) => { PedManager.Instance.showPedSpeedometer = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
};
|
|
|
|
|
OptionsWindow.FloatInput m_turnSpeedInput = new OptionsWindow.FloatInput() {
|
|
|
|
|
description = "Turn speed",
|
|
|
|
|
minValue = 3,
|
|
|
|
|
maxValue = 30,
|
|
|
|
|
isAvailable = () => PedManager.Instance != null,
|
|
|
|
|
getValue = () => PedManager.Instance.pedTurnSpeed,
|
|
|
|
|
setValue = (value) => { PedManager.Instance.pedTurnSpeed = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
};
|
2021-01-05 02:28:14 +00:00
|
|
|
|
OptionsWindow.FloatInput m_deadBodyLifetime = new OptionsWindow.FloatInput
|
|
|
|
|
{
|
|
|
|
|
description = "Dead body lifetime",
|
|
|
|
|
minValue = 0.5f,
|
|
|
|
|
maxValue = 300f,
|
|
|
|
|
getValue = () => PedManager.Instance.ragdollLifetime,
|
|
|
|
|
setValue = (value) => { PedManager.Instance.ragdollLifetime = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
|
|
|
|
};
|
2019-06-25 23:55:16 +00:00
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake ()
|
|
|
|
|
{
|
2021-07-23 22:27:02 +00:00
|
|
|
|
var inputs = new OptionsWindow.Input[]
|
|
|
|
|
{
|
|
|
|
|
m_playerNameInput,
|
|
|
|
|
m_timeScaleInput,
|
|
|
|
|
m_physicsUpdateRate,
|
|
|
|
|
m_gravityInput,
|
|
|
|
|
m_showSpeedometerInput,
|
|
|
|
|
m_displayMinimapInput,
|
|
|
|
|
m_runInBackgroundInput,
|
|
|
|
|
m_drawLineFromGunInput,
|
|
|
|
|
m_enableCamera,
|
|
|
|
|
m_displayFpsInput,
|
|
|
|
|
m_pausePlayerSpawning,
|
|
|
|
|
m_playerSpawnInterval,
|
2020-12-28 00:41:11 +00:00
|
|
|
|
m_vehicleDetachedPartLifetime,
|
2021-01-05 02:28:14 +00:00
|
|
|
|
m_deadBodyLifetime,
|
2020-12-26 16:40:30 +00:00
|
|
|
|
m_projectileReloadTime,
|
2021-01-02 19:46:19 +00:00
|
|
|
|
m_turnSpeedInput,
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var input in inputs)
|
|
|
|
|
{
|
|
|
|
|
input.category = "MISC";
|
|
|
|
|
OptionsWindow.RegisterInput (input);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 22:27:02 +00:00
|
|
|
|
Player.onStart += OnPlayerStart;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-25 19:15:59 +00:00
|
|
|
|
static void DisplayFPS(bool bDisplay)
|
|
|
|
|
{
|
|
|
|
|
FPSDisplay.Instance.fpsImage.enabled = bDisplay;
|
|
|
|
|
FPSDisplay.Instance.fpsText.enabled = bDisplay;
|
2020-04-26 14:30:52 +00:00
|
|
|
|
FPSDisplay.Instance.updateFPS = bDisplay;
|
2020-04-25 19:15:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 22:27:02 +00:00
|
|
|
|
void OnPlayerStart(Player player)
|
|
|
|
|
{
|
|
|
|
|
if (player == Player.Local)
|
|
|
|
|
ApplyPlayerName(s_playerName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ApplyPlayerName(string newPlayerName)
|
|
|
|
|
{
|
|
|
|
|
s_playerName = newPlayerName;
|
|
|
|
|
|
|
|
|
|
if (Player.Local != null)
|
|
|
|
|
Player.Local.RequestNameChange(newPlayerName);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|