Compare commits

...

3 Commits
2.2.0 ... main

5 changed files with 507 additions and 544 deletions

View File

@ -51,6 +51,9 @@
<Reference Include="BepInEx">
<HintPath>References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="bsg.console.core">
<HintPath>References\bsg.console.core.dll</HintPath>
</Reference>
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Comfort.dll</HintPath>
@ -72,11 +75,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="TimeWeatherController.cs" />
<Compile Include="TimeWeatherPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\CursorSettings.cs" />
<Compile Include="Utils\GameConsole.cs" />
<Compile Include="Utils\Notifier.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -1,498 +0,0 @@
using Comfort.Common;
using EFT;
using EFT.Communications;
using EFT.UI;
using EFT.Weather;
using SamSWAT.TimeWeatherChanger.Utils;
using System;
using UnityEngine;
using GameDateTime = GClass1246;
using Random = UnityEngine.Random;
namespace SamSWAT.TimeWeatherChanger
{
public class TimeWeatherController : MonoBehaviour
{
private static GameObject input;
private static WeatherController weatherController;
private static GameWorld gameWorld;
private static GameDateTime gameDateTime;
private static DateTime modifiedDateTime;
private static DateTime currentDateTime;
private static Rect windowRect = new Rect(50, 50, 460, 365);
private static bool GUIStatus = false;
private static bool weatherdebug = false;
private static float _clouddensity;
private static float _fog;
private static float _rain;
private static float _lightningthunderprobability;
private static float _temperature;
private static float _windmagnitude;
private static int _direction = 2;
private static int topwinddirection = 2;
private static WeatherDebug.Direction _winddirection;
private static Vector2 _topwinddirection;
private static string weatherdebugtex;
private static int targetTimeHours;
private static int targetTimeMinutes;
void Start()
{
//Duplicate functionality of toggle key
GameConsole.AddCommand("twc", match =>
{
gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
string log = "In order to change the weather, you have to go in a raid first.";
Notifier.DisplayWarningNotification(log, ENotificationDurationType.Long);
PreloaderUI.Instance.Console.AddLog(" " + log, "[TWChanger]:");
}
else
{
if (GameObject.Find("Weather") == null)
{
string log = "An error occurred when executing command, seems like you are either in the hideout or factory.";
Notifier.DisplayWarningNotification(log);
PreloaderUI.Instance.Console.AddLog(" " + log, "[TWChanger]:");
}
else
{
if (input == null)
{
input = GameObject.Find("___Input");
}
gameDateTime = gameWorld.GameDateTime;
GUIStatus = !GUIStatus;
Cursor.visible = GUIStatus;
if (GUIStatus)
{
CursorSettings.SetCursor(ECursorType.Idle);
Cursor.lockState = CursorLockMode.None;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu);
}
else
{
CursorSettings.SetCursor(ECursorType.Invisible);
Cursor.lockState = CursorLockMode.Locked;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuDropdown);
}
input.SetActive(!GUIStatus);
PreloaderUI.Instance.Console.AddLog(" Switching control panel...", "[TWChanger]:");
}
}
});
}
public void Update()
{
if (Input.GetKeyDown(TimeWeatherPlugin.TogglePanel.Value.MainKey))
{
//Obtaining current GameWorld for later time change
gameWorld = Singleton<GameWorld>.Instance;
//If GameWorld is null, it means that player currently is not in the raid. We notify the player with an error screen that he first needs to go in a raid
if (gameWorld == null)
{
if (GameObject.Find("ErrorScreen"))
PreloaderUI.Instance.CloseErrorScreen();
PreloaderUI.Instance.ShowErrorScreen("Time & Weather Changer Error", "In order to change the weather, you have to go in a raid first.");
}
else
{
//Looking for the weather GameObject to which the WeatherController script is attached. If it's null, means that the player is either in a hideout or factory where dynamic weather and time are not available
if (GameObject.Find("Weather") == null)
{
//Notify player with bottom-right error popup
Notifier.DisplayWarningNotification("An error occurred when opening weather panel, seems like you are either in the hideout or factory.");
}
else
{
//Caching input manager GameObject which script is responsible for reading the player inputs
if (input == null)
{
input = GameObject.Find("___Input");
}
//Getting class responsible for time in the current world for later use
gameDateTime = gameWorld.GameDateTime;
GUIStatus = !GUIStatus;
Cursor.visible = GUIStatus;
if (GUIStatus)
{
//Changing the default windows cursor to an EFT-style one and playing a sound when the menu appears
CursorSettings.SetCursor(ECursorType.Idle);
Cursor.lockState = CursorLockMode.None;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu);
}
else
{
//Hiding cursor and playing a sound when the menu disappears
CursorSettings.SetCursor(ECursorType.Invisible);
Cursor.lockState = CursorLockMode.Locked;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuDropdown);
}
//Disabling the input manager so the player won't move
input.SetActive(!GUIStatus);
}
}
}
}
public void OnGUI()
{
if (GUIStatus)
windowRect = GUI.Window(0, windowRect, WindowFunction, "Time & Weather Changer by SamSWAT v2.2");
}
void WindowFunction(int TWCWindowID)
{
if (weatherdebug)
weatherdebugtex = "ON";
else
weatherdebugtex = "OFF";
//Caching WeatherController script for the first time
if (weatherController == null)
{
weatherController = GameObject.Find("Weather").GetComponent<WeatherController>();
}
//Shit ton of different sliders and buttons
GUI.DragWindow(new Rect(0, 0, 10000, 20));
//---------------------------------------------\\
GUI.Box(new Rect(15, 23, 140, 60), "");
weatherdebug = GUI.Toggle(new Rect(33, 37, 110, 25), weatherdebug, "Weather debug");
GUI.Label(new Rect(74, 52, 110, 25), weatherdebugtex);
currentDateTime = gameDateTime.Calculate();
GUI.Box(new Rect(160, 23, 285, 60), "Current time: " + currentDateTime.ToString("HH:mm:ss"));
GUI.Label(new Rect(190, 42, 40, 20), "Hours");
targetTimeHours = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(165, 60, 80, 15), targetTimeHours, 0, 23));
GUI.TextField(new Rect(248, 50, 20, 20), targetTimeHours.ToString());
GUI.Label(new Rect(295, 42, 50, 20), "Minutes");
targetTimeMinutes = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(272, 60, 90, 15), targetTimeMinutes, 0, 59));
GUI.TextField(new Rect(365, 50, 20, 20), targetTimeMinutes.ToString());
if (GUI.Button(new Rect(390, 40, 50, 30), "Set"))
{
modifiedDateTime = currentDateTime.AddHours((double)targetTimeHours - currentDateTime.Hour);
modifiedDateTime = modifiedDateTime.AddMinutes((double)targetTimeMinutes - currentDateTime.Minute);
gameDateTime.Reset(modifiedDateTime);
Notifier.DisplayMessageNotification("Time was set to: " + modifiedDateTime.ToString("HH:mm"));
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuInspectorWindowClose);
}
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(15, 100, 140, 250));
GUILayout.BeginVertical();
GUILayout.Box("Cloud Density: " + Math.Round(_clouddensity * 1000) / 1000);
_clouddensity = GUILayout.HorizontalSlider(_clouddensity, -1f, 1f);
GUILayout.Box("Wind Magnitude: " + Math.Round(_windmagnitude * 100) / 100);
_windmagnitude = GUILayout.HorizontalSlider(_windmagnitude, 0f, 1f);
GUILayout.Box("Wind Direction: " + _winddirection.ToString());
_direction = Mathf.RoundToInt(GUILayout.HorizontalSlider(_direction, 1, 8));
_winddirection = (WeatherDebug.Direction)_direction;
if (GUILayout.Button("Clear"))
{
_clouddensity = -0.7f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Clear Wind"))
{
_clouddensity = -0.7f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0.4f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Clear Fog"))
{
_clouddensity = -0.4f;
_fog = 0.02f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Partly Cloud"))
{
_clouddensity = -0.2f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Mostly Cloud"))
{
_clouddensity = 0f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(160, 100, 140, 160));
GUILayout.BeginVertical();
GUILayout.Box("Fog: " + Math.Round(_fog * 1000) / 1000);
_fog = GUILayout.HorizontalSlider(_fog, 0f, 0.35f);
GUILayout.Box("Thunder prob: " + Math.Round(_lightningthunderprobability * 1000) / 1000);
_lightningthunderprobability = GUILayout.HorizontalSlider(_lightningthunderprobability, 0f, 1f);
if (GUILayout.Button("Randomize"))
{
float num = Random.Range(-1f, 1f);
int num3;
_rain = 0f;
_clouddensity = num;
if (num > 0.5f)
{
num3 = Random.Range(0, 5);
_rain = Random.Range(0f, 1f);
_fog = 0.004f;
switch (num3)
{
case 0:
break;
case 1:
_fog = 0.008f;
goto IL_C5;
case 2:
_fog = 0.012f;
goto IL_C5;
case 3:
_fog = 0.02f;
goto IL_C5;
case 4:
_fog = 0.03f;
goto IL_C5;
default:
goto IL_C5;
}
}
_fog = Random.Range(0.003f, 0.006f);
IL_C5:
_direction = Random.Range(1, 8);
topwinddirection = Random.Range(0, 5);
_windmagnitude = Random.Range(0f, 1f);
_lightningthunderprobability = Random.Range(0f, 1f);
_temperature = Random.Range(-50f, 50f);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(160, 229, 140, 160));
GUILayout.BeginVertical();
if (GUILayout.Button("Full Cloud"))
{
_clouddensity = 1f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Wind"))
{
_clouddensity = 0.2f;
_fog = 0.003f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0.66f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Fog"))
{
_clouddensity = 0.2f;
_fog = 0.02f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Thunder Cloud"))
{
_clouddensity = 1f;
_fog = 0.004f;
_lightningthunderprobability = 0.8f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0.4f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Wind Rain"))
{
_clouddensity = 1f;
_fog = 0.004f;
_lightningthunderprobability = 0.5f;
_rain = 0.8f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0.6f;
topwinddirection = Random.Range(0, 5);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(305, 100, 140, 250));
GUILayout.BeginVertical();
GUILayout.Box("Rain: " + Math.Round(_rain * 1000) / 1000);
_rain = GUILayout.HorizontalSlider(_rain, 0f, 1f);
GUILayout.Box("Temperature: " + Math.Round(_temperature * 10) / 10);
_temperature = GUILayout.HorizontalSlider(_temperature, -50f, 50f);
GUILayout.Box("TopWind dir " + _topwinddirection.ToString());
topwinddirection = Mathf.RoundToInt(GUILayout.HorizontalSlider(topwinddirection, 1, 6));
switch (topwinddirection)
{
case 1:
_topwinddirection = Vector2.down;
break;
case 2:
_topwinddirection = Vector2.left;
break;
case 3:
_topwinddirection = Vector2.one;
break;
case 4:
_topwinddirection = Vector2.right;
break;
case 5:
_topwinddirection = Vector2.up;
break;
case 6:
_topwinddirection = Vector2.zero;
break;
}
if (GUILayout.Button("Light Rain"))
{
_clouddensity = -0.1f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0.5f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Rain"))
{
_clouddensity = 0.05f;
_fog = 0.004f;
_lightningthunderprobability = 0.3f;
_rain = 1f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0.15f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Fog"))
{
_clouddensity = -0.4f;
_fog = 0.1f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 22f;
_direction = Random.Range(1, 8);
_windmagnitude = 0f;
topwinddirection = Random.Range(0, 5);
}
if (GUILayout.Button("Default"))
{
_clouddensity = -0.3f;
_fog = 0.004f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 20f;
_direction = 7;
_windmagnitude = 0.75f;
topwinddirection = 2;
}
if (GUILayout.Button("BSG Preset"))
{
_clouddensity = -0.371f;
_fog = 0.009f;
_lightningthunderprobability = 0f;
_rain = 0f;
_temperature = 0f;
_direction = 8;
_windmagnitude = 0.125f;
topwinddirection = 2;
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
if (!weatherdebug)
GUI.Box(new Rect(10, 95, 440, 260), "");
//Writing all the parameters selected by the player to the WeatherDebug script
weatherController.WeatherDebug.Enabled = weatherdebug;
weatherController.WeatherDebug.CloudDensity = _clouddensity;
weatherController.WeatherDebug.Fog = _fog;
weatherController.WeatherDebug.LightningThunderProbability = _lightningthunderprobability;
weatherController.WeatherDebug.Rain = _rain;
weatherController.WeatherDebug.Temperature = _temperature;
weatherController.WeatherDebug.TopWindDirection = _topwinddirection;
weatherController.WeatherDebug.WindDirection = _winddirection;
weatherController.WeatherDebug.WindMagnitude = _windmagnitude;
}
}
}

View File

@ -1,29 +1,522 @@
using UnityEngine;
using Aki.Reflection.Utils;
using BepInEx;
using BepInEx.Configuration;
using Comfort.Common;
using EFT;
using EFT.Communications;
using EFT.Console.Core;
using EFT.UI;
using EFT.Weather;
using SamSWAT.TimeWeatherChanger.Utils;
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using Random = UnityEngine.Random;
namespace SamSWAT.TimeWeatherChanger
{
[BepInPlugin("com.samswat.timeweatherchanger", "SamSWAT.TimeWeatherChanger", "2.2.0")]
[BepInPlugin("com.samswat.timeweatherchanger", "SamSWAT.TimeWeatherChanger", "2.3.0")]
public class TimeWeatherPlugin : BaseUnityPlugin
{
public static GameObject Hook;
private const string SectionName = "Main";
internal static ConfigEntry<KeyboardShortcut> TogglePanel;
private void Awake()
private static GameObject input;
private static WeatherController weatherController;
private static GameWorld gameWorld;
private static Type gameDateTime;
private static MethodInfo calculateTime;
private static MethodInfo resetTime;
private static DateTime modifiedDateTime;
private static DateTime currentDateTime;
private static Rect windowRect = new Rect(50, 50, 460, 365);
private static bool guiStatus = false;
private static bool weatherDebug = false;
private static float cloudDensity;
private static float fog;
private static float rain;
private static float lightningThunderProb;
private static float temperature;
private static float windMagnitude;
private static int windDir = 2;
private static WeatherDebug.Direction windDirection;
private static int topWindDir = 2;
private static Vector2 topWindDirection;
private static string weatherDebugTex;
private static int targetTimeHours;
private static int targetTimeMinutes;
public void Awake()
{
Logger.LogInfo("Loading: SamSWAT-TimeWeatherChanger 2.2.0");
Hook = new GameObject("Time Weather Controller");
Hook.AddComponent<TimeWeatherController>();
DontDestroyOnLoad(Hook);
//Getting type responsible for time in the current world for later use
gameDateTime = PatchConstants.EftTypes.Single(x => x.GetMethod("CalculateTaxonomyDate") != null);
calculateTime = gameDateTime.GetMethod("Calculate", BindingFlags.Public | BindingFlags.Instance);
resetTime = gameDateTime.GetMethods(BindingFlags.Public | BindingFlags.Instance).Single(x => x.Name == "Reset" && x.GetParameters().Length == 1);
ConsoleScreen.Processor.RegisterCommand("twc", new Action(OpenPanel));
TogglePanel = Config.Bind(
SectionName,
"Main Settings",
"Time Weather Panel Toggle Key",
new KeyboardShortcut(KeyCode.Home),
"The keyboard shortcut that toggles control panel");
}
[ConsoleCommand("Open Time&Weather panel")]
public static void OpenPanel()
{
gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
string log = "In order to change the weather, you have to go in a raid first.";
Notifier.DisplayWarningNotification(log, ENotificationDurationType.Long);
ConsoleScreen.Log($"[TWChanger]: {log}");
}
else
{
if (GameObject.Find("Weather") == null)
{
string log = "An error occurred when executing command, seems like you are either in the hideout or factory.";
Notifier.DisplayWarningNotification(log);
ConsoleScreen.Log($"[TWChanger]: {log}");
}
else
{
if (input == null)
{
input = GameObject.Find("___Input");
}
guiStatus = !guiStatus;
Cursor.visible = guiStatus;
if (guiStatus)
{
CursorSettings.SetCursor(ECursorType.Idle);
Cursor.lockState = CursorLockMode.None;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu);
}
else
{
CursorSettings.SetCursor(ECursorType.Invisible);
Cursor.lockState = CursorLockMode.Locked;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuDropdown);
}
input.SetActive(!guiStatus);
ConsoleScreen.Log("[TWChanger]: Switching control panel...");
}
}
}
public void Update()
{
if (Input.GetKeyDown(TogglePanel.Value.MainKey))
{
//Obtaining current GameWorld for later time change
gameWorld = Singleton<GameWorld>.Instance;
//If GameWorld is null, it means that player currently is not in the raid. We notify the player with an error screen that he first needs to go in a raid
if (gameWorld == null)
{
if (GameObject.Find("ErrorScreen"))
PreloaderUI.Instance.CloseErrorScreen();
PreloaderUI.Instance.ShowErrorScreen("Time & Weather Changer Error", "In order to change the weather, you have to go in a raid first.");
}
else
{
//Looking for the weather GameObject to which the WeatherController script is attached. If it's null, means that the player is either in a hideout or factory where dynamic weather and time are not available
if (GameObject.Find("Weather") == null)
{
//Notify player with bottom-right error popup
Notifier.DisplayWarningNotification("An error occurred when opening weather panel, seems like you are either in the hideout or factory.");
}
else
{
//Caching input manager GameObject which script is responsible for reading the player inputs
if (input == null)
{
input = GameObject.Find("___Input");
}
guiStatus = !guiStatus;
Cursor.visible = guiStatus;
if (guiStatus)
{
//Changing the default windows cursor to an EFT-style one and playing a sound when the menu appears
CursorSettings.SetCursor(ECursorType.Idle);
Cursor.lockState = CursorLockMode.None;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu);
}
else
{
//Hiding cursor and playing a sound when the menu disappears
CursorSettings.SetCursor(ECursorType.Invisible);
Cursor.lockState = CursorLockMode.Locked;
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuDropdown);
}
//Disabling the input manager so the player won't move
input.SetActive(!guiStatus);
}
}
}
}
public void OnGUI()
{
if (guiStatus)
windowRect = GUI.Window(0, windowRect, WindowFunction, "Time & Weather Changer by SamSWAT v2.3");
}
void WindowFunction(int TWCWindowID)
{
if (weatherDebug)
weatherDebugTex = "ON";
else
weatherDebugTex = "OFF";
//Caching WeatherController script for the first time
if (weatherController == null)
{
weatherController = GameObject.Find("Weather").GetComponent<WeatherController>();
}
//Shit ton of different sliders and buttons
GUI.DragWindow(new Rect(0, 0, 10000, 20));
//---------------------------------------------\\
GUI.Box(new Rect(15, 23, 140, 60), "");
weatherDebug = GUI.Toggle(new Rect(33, 37, 110, 25), weatherDebug, "Weather debug");
GUI.Label(new Rect(74, 52, 110, 25), weatherDebugTex);
currentDateTime = (DateTime)calculateTime.Invoke(typeof(GameWorld).GetField("GameDateTime").GetValue(gameWorld), null);
GUI.Box(new Rect(160, 23, 285, 60), "Current time: " + currentDateTime.ToString("HH:mm:ss"));
GUI.Label(new Rect(190, 42, 40, 20), "Hours");
targetTimeHours = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(165, 60, 80, 15), targetTimeHours, 0, 23));
GUI.TextField(new Rect(248, 50, 20, 20), targetTimeHours.ToString());
GUI.Label(new Rect(295, 42, 50, 20), "Minutes");
targetTimeMinutes = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(272, 60, 90, 15), targetTimeMinutes, 0, 59));
GUI.TextField(new Rect(365, 50, 20, 20), targetTimeMinutes.ToString());
if (GUI.Button(new Rect(390, 40, 50, 30), "Set"))
{
modifiedDateTime = currentDateTime.AddHours((double)targetTimeHours - currentDateTime.Hour);
modifiedDateTime = modifiedDateTime.AddMinutes((double)targetTimeMinutes - currentDateTime.Minute);
resetTime.Invoke(typeof(GameWorld).GetField("GameDateTime").GetValue(gameWorld), new object[] { modifiedDateTime });
Notifier.DisplayMessageNotification("Time was set to: " + modifiedDateTime.ToString("HH:mm"));
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuInspectorWindowClose);
}
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(15, 100, 140, 250));
GUILayout.BeginVertical();
GUILayout.Box("Cloud Density: " + Math.Round(cloudDensity * 1000) / 1000);
cloudDensity = GUILayout.HorizontalSlider(cloudDensity, -1f, 1f);
GUILayout.Box("Wind Magnitude: " + Math.Round(windMagnitude * 100) / 100);
windMagnitude = GUILayout.HorizontalSlider(windMagnitude, 0f, 1f);
GUILayout.Box("Wind Direction: " + windDirection.ToString());
windDir = Mathf.RoundToInt(GUILayout.HorizontalSlider(windDir, 1, 8));
windDirection = (WeatherDebug.Direction)windDir;
if (GUILayout.Button("Clear"))
{
cloudDensity = -0.7f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Clear Wind"))
{
cloudDensity = -0.7f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0.4f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Clear Fog"))
{
cloudDensity = -0.4f;
fog = 0.02f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Partly Cloud"))
{
cloudDensity = -0.2f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Mostly Cloud"))
{
cloudDensity = 0f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(160, 100, 140, 160));
GUILayout.BeginVertical();
GUILayout.Box("Fog: " + Math.Round(fog * 1000) / 1000);
fog = GUILayout.HorizontalSlider(fog, 0f, 0.35f);
GUILayout.Box("Thunder prob: " + Math.Round(lightningThunderProb * 1000) / 1000);
lightningThunderProb = GUILayout.HorizontalSlider(lightningThunderProb, 0f, 1f);
if (GUILayout.Button("Randomize"))
{
float num = Random.Range(-1f, 1f);
int num3;
rain = 0f;
cloudDensity = num;
if (num > 0.5f)
{
num3 = Random.Range(0, 5);
rain = Random.Range(0f, 1f);
fog = 0.004f;
switch (num3)
{
case 0:
break;
case 1:
fog = 0.008f;
goto IL_C5;
case 2:
fog = 0.012f;
goto IL_C5;
case 3:
fog = 0.02f;
goto IL_C5;
case 4:
fog = 0.03f;
goto IL_C5;
default:
goto IL_C5;
}
}
fog = Random.Range(0.003f, 0.006f);
IL_C5:
windDir = Random.Range(1, 8);
topWindDir = Random.Range(0, 5);
windMagnitude = Random.Range(0f, 1f);
lightningThunderProb = Random.Range(0f, 1f);
temperature = Random.Range(-50f, 50f);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(160, 229, 140, 160));
GUILayout.BeginVertical();
if (GUILayout.Button("Full Cloud"))
{
cloudDensity = 1f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Wind"))
{
cloudDensity = 0.2f;
fog = 0.003f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0.66f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Fog"))
{
cloudDensity = 0.2f;
fog = 0.02f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Thunder Cloud"))
{
cloudDensity = 1f;
fog = 0.004f;
lightningThunderProb = 0.8f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0.4f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Cloud Wind Rain"))
{
cloudDensity = 1f;
fog = 0.004f;
lightningThunderProb = 0.5f;
rain = 0.8f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0.6f;
topWindDir = Random.Range(0, 5);
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
//---------------------------------------------\\
GUILayout.BeginArea(new Rect(305, 100, 140, 250));
GUILayout.BeginVertical();
GUILayout.Box("Rain: " + Math.Round(rain * 1000) / 1000);
rain = GUILayout.HorizontalSlider(rain, 0f, 1f);
GUILayout.Box("Temperature: " + Math.Round(temperature * 10) / 10);
temperature = GUILayout.HorizontalSlider(temperature, -50f, 50f);
GUILayout.Box("TopWind dir " + topWindDirection.ToString());
topWindDir = Mathf.RoundToInt(GUILayout.HorizontalSlider(topWindDir, 1, 6));
switch (topWindDir)
{
case 1:
topWindDirection = Vector2.down;
break;
case 2:
topWindDirection = Vector2.left;
break;
case 3:
topWindDirection = Vector2.one;
break;
case 4:
topWindDirection = Vector2.right;
break;
case 5:
topWindDirection = Vector2.up;
break;
case 6:
topWindDirection = Vector2.zero;
break;
}
if (GUILayout.Button("Light Rain"))
{
cloudDensity = -0.1f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0.5f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Rain"))
{
cloudDensity = 0.05f;
fog = 0.004f;
lightningThunderProb = 0.3f;
rain = 1f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0.15f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Fog"))
{
cloudDensity = -0.4f;
fog = 0.1f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 22f;
windDir = Random.Range(1, 8);
windMagnitude = 0f;
topWindDir = Random.Range(0, 5);
}
if (GUILayout.Button("Default"))
{
cloudDensity = -0.3f;
fog = 0.004f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 20f;
windDir = 7;
windMagnitude = 0.75f;
topWindDir = 2;
}
if (GUILayout.Button("BSG Preset"))
{
cloudDensity = -0.371f;
fog = 0.009f;
lightningThunderProb = 0f;
rain = 0f;
temperature = 0f;
windDir = 8;
windMagnitude = 0.125f;
topWindDir = 2;
}
GUILayout.EndVertical();
GUILayout.EndArea();
//---------------------------------------------\\
if (!weatherDebug)
GUI.Box(new Rect(10, 95, 440, 260), "");
//Writing all the parameters selected by the player to the WeatherDebug script
weatherController.WeatherDebug.Enabled = weatherDebug;
weatherController.WeatherDebug.CloudDensity = cloudDensity;
weatherController.WeatherDebug.Fog = fog;
weatherController.WeatherDebug.LightningThunderProbability = lightningThunderProb;
weatherController.WeatherDebug.Rain = rain;
weatherController.WeatherDebug.Temperature = temperature;
weatherController.WeatherDebug.TopWindDirection = topWindDirection;
weatherController.WeatherDebug.WindDirection = windDirection;
weatherController.WeatherDebug.WindMagnitude = windMagnitude;
}
}
}

View File

@ -1,33 +0,0 @@
using Aki.Reflection.Utils;
using EFT.UI;
using HarmonyLib;
using System;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace SamSWAT.TimeWeatherChanger.Utils
{
static class GameConsole
{
private static readonly Type consoleCommandType;
private static readonly ConstructorInfo consoleCommandConstructor;
private static readonly MethodInfo consoleCommandsAddMethod;
private static readonly FieldInfo commandsField;
static GameConsole()
{
consoleCommandType = PatchConstants.EftTypes.Single(x => x.GetProperty("Regex") != null && x.GetMethod("TryExecute") != null);
consoleCommandConstructor = consoleCommandType.GetConstructor(new[] { typeof(string), typeof(Action<Match>) });
consoleCommandsAddMethod = AccessTools.Field(typeof(ConsoleScreen), nameof(ConsoleScreen.Commands)).FieldType.GetMethod("Add", new[] { consoleCommandType });
commandsField = AccessTools.Field(typeof(ConsoleScreen), nameof(ConsoleScreen.Commands));
}
public static void AddCommand(string regular, Action<Match> onExecute)
{
var commands = commandsField.GetValue(null);
var command = consoleCommandConstructor.Invoke(new object[] { regular, onExecute });
consoleCommandsAddMethod.Invoke(commands, new[] { command });
}
}
}