using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
public enum FileIcon
{
Truck,
FloppyDisk,
File,
Mail,
MailOpen,
Trash,
TrashOpen,
Gear,
GearTurned,
FileSlanted,
TruckBumped,
Clipboard,
ClipboardSlanted,
Bird,
BirdPeck,
Camera
}
namespace HelloUI
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "HelloUI";
public const string PLUGIN_NAME = "HelloUI";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace EasyDeliveryAPI.ExampleMods
{
public class WeatherHUD : MonoBehaviour
{
public enum WeatherType
{
Clear,
LightSnow,
Snow,
Blizzard
}
private static FieldInfo RField = typeof(sHUD).GetField("R", BindingFlags.Instance | BindingFlags.NonPublic);
private static FieldInfo WeatherTargetField = typeof(sDayNightCycle).GetField("weatherTarget", BindingFlags.Instance | BindingFlags.NonPublic);
private DateTime TimeLastFrame = DateTime.Now;
private float WarningBlinkOnSpeed = 1f;
private float WarningBlinkOffSpeed = 0.5f;
private double WarningBlinkTimer;
private int MessageX = 68;
private int MessageY = 12;
private const int CharWidth = 8;
private int SpriteX = 98;
private int SpriteY = 19;
private int SpriteWidth = 32;
private int SpriteHeight = 32;
private int SpriteScaledWidth = 32;
private int SpriteScaledHeight = 32;
private bool FlipSpriteHorizontally;
public void FrameUpdate(sHUD hud)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Object.FindFirstObjectByType<CarLessMode>() != (Object)null)
{
return;
}
object? value = RField.GetValue(hud);
MiniRenderer val = (MiniRenderer)((value is MiniRenderer) ? value : null);
sWeatherSystem val2 = Object.FindFirstObjectByType<sWeatherSystem>();
if ((Object)(object)val2 == (Object)null)
{
return;
}
WeatherType weatherType = (WeatherType)Mathf.Min(val2.intensity * 4f, 3.999f);
bool num = (int)Mathf.Min((float)WeatherTargetField.GetValue(hud.dayNightCycle) * 4f, 3.999f) == 3 && weatherType != WeatherType.Blizzard;
Scene activeScene = SceneManager.GetActiveScene();
bool flag = ((Scene)(ref activeScene)).name != "MountainTown";
if (num && flag)
{
DateTime now = DateTime.Now;
WarningBlinkTimer += (now - TimeLastFrame).TotalSeconds;
TimeLastFrame = now;
WarningBlinkTimer %= WarningBlinkOnSpeed + WarningBlinkOffSpeed;
if (WarningBlinkTimer < (double)WarningBlinkOnSpeed)
{
string text = "STORM WARNING";
val.put(text, (float)(val.width - (MessageX + text.Length * 8)), (float)MessageY);
}
}
else
{
string text2 = weatherType.ToString().Replace("LightSnow", "Light Snow").ToLower();
val.put(text2, (float)(val.width - (MessageX + text2.Length * 8)), (float)MessageY);
}
int num2 = (int)(weatherType + 1);
Texture spriteSheet = val.spriteSheet;
val.spr(spriteSheet, (float)(num2 * SpriteWidth), 0f, (float)(val.width - SpriteX), (float)SpriteY, (float)SpriteWidth, (float)SpriteHeight, FlipSpriteHorizontally, (float)SpriteScaledWidth, (float)SpriteScaledHeight);
}
}
public class WeatherGame : ScreenProgram
{
private GamepadNavigation nav;
private AudioSource audioSource;
public AudioClip hoverSound;
private int SetupFuncCalls;
private int ResumeFuncCalls;
public override void Setup()
{
SetupFuncCalls++;
}
public override void Resume()
{
ResumeFuncCalls++;
UIExamplePlugin.Logger.LogInfo((object)("Resume func called. Total: " + ResumeFuncCalls));
}
public override void Draw()
{
}
}
public class WeatherApp : MonoBehaviour
{
private static FieldInfo WeatherTargetField = typeof(sDayNightCycle).GetField("weatherTarget", BindingFlags.Instance | BindingFlags.NonPublic);
private UIUtil Util = new UIUtil();
private Rect P;
private Vector2 DesiredWindowSize = new Vector2(13f, 9f);
private float ForecastTimeIntervalHours = 1f;
private int HeaderOffsetY = 2;
private int SpriteSize = 32;
private string CurrentLabel = "Now";
private int CurrentLabelX = 10;
private int CurrentSpriteX = 10;
private int CurrentTemperatureLabelX = 10;
private string FutureLabel = "Next";
private int XOffset = 50;
private int LabelY = 16;
private int SpriteY = 24;
private int TemperatureLabelY = 56;
private bool FlipSpriteHorizontally;
private int TopBarThickness = 8;
private int TopBarYOffset = -6;
private bool BeingDragged;
private Vector2 DragOffset;
public void FrameUpdate(WindowView window)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
Util.M = (ScreenProgram)(object)window.M;
Util.R = window.R;
Util.nav = window.M.nav;
window.size = DesiredWindowSize;
DoWindowDrag(window);
P = new Rect(window.position * 8f, window.size * 8f);
ref Rect p = ref P;
((Rect)(ref p)).position = ((Rect)(ref p)).position + new Vector2(8f, 8f);
DrawWeatherForecast(window);
}
private float PredictTemperature(sDayNightCycle dayNightCycle, float hoursInFuture, float intensity)
{
return Mathf.Lerp(dayNightCycle.lowTemp, dayNightCycle.highTemp, dayNightCycle.tempOverTime.Evaluate((dayNightCycle.time + hoursInFuture / 24f) % 1f)) + dayNightCycle.windChill * intensity + (Mathf.PerlinNoise1D(Time.time * dayNightCycle.noiseSpeed) * dayNightCycle.tempFluctuation - dayNightCycle.tempFluctuation / 2f);
}
private void DrawWeatherForecast(WindowView window)
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
sDayNightCycle val = Object.FindFirstObjectByType<sDayNightCycle>();
sWeatherSystem component = ((Component)val).gameObject.GetComponent<sWeatherSystem>();
int num;
float num2;
if ((Object)(object)val != (Object)null)
{
num = (((Object)(object)Object.FindFirstObjectByType<CarLessMode>() == (Object)null) ? 1 : 0);
if (num != 0)
{
num2 = (float)WeatherTargetField.GetValue(val);
goto IL_0043;
}
}
else
{
num = 0;
}
num2 = 1f;
goto IL_0043;
IL_0043:
float num3 = num2;
WeatherHUD.WeatherType weatherType = (WeatherHUD.WeatherType)Mathf.Min(num3 * 4f, 3.999f);
float num4 = ((num != 0) ? PredictTemperature(val, ForecastTimeIntervalHours, num3) : (-99f));
WeatherHUD.WeatherType weatherType2 = (WeatherHUD.WeatherType)Mathf.Min(((num != 0) ? component.intensity : 1f) * 4f, 3.999f);
float num5 = ((num != 0) ? val.Temperature() : (-99f));
string text = ((num != 0) ? "Forecast" : "NO SIGNAL");
Util.R.fontOptions.alignment = (Alignment)1;
Util.R.fontOptions.mono = false;
Util.R.fput(text, ((Rect)(ref P)).center.x, ((Rect)(ref P)).yMin + (float)HeaderOffsetY, 0f, 13f, 0f, -1);
Texture altSpriteSheet = window.M.altSpriteSheet;
int num6 = (int)(weatherType2 + 1);
int num7 = (int)(weatherType + 1);
Util.R.put(CurrentLabel, (float)CurrentLabelX + ((Rect)(ref P)).x, (float)LabelY + ((Rect)(ref P)).y);
Util.R.put(FutureLabel, (float)(CurrentLabelX + XOffset) + ((Rect)(ref P)).x, (float)LabelY + ((Rect)(ref P)).y);
Util.R.spr(altSpriteSheet, (float)(num6 * SpriteSize), 0f, (float)CurrentSpriteX + ((Rect)(ref P)).x, (float)SpriteY + ((Rect)(ref P)).y, (float)SpriteSize, (float)SpriteSize, FlipSpriteHorizontally, (float)SpriteSize, (float)SpriteSize);
Util.R.spr(altSpriteSheet, (float)(num7 * SpriteSize), 0f, (float)(CurrentSpriteX + XOffset) + ((Rect)(ref P)).x, (float)SpriteY + ((Rect)(ref P)).y, (float)SpriteSize, (float)SpriteSize, FlipSpriteHorizontally, (float)SpriteSize, (float)SpriteSize);
Util.R.put((int)num5, (float)CurrentTemperatureLabelX + ((Rect)(ref P)).x, (float)TemperatureLabelY + ((Rect)(ref P)).y);
Util.R.put((int)num4, (float)(CurrentTemperatureLabelX + XOffset) + ((Rect)(ref P)).x, (float)TemperatureLabelY + ((Rect)(ref P)).y);
}
private void DoWindowDrag(WindowView window)
{
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (!BeingDragged)
{
if (Util.MouseOver(((Rect)(ref P)).xMin, ((Rect)(ref P)).yMin + (float)TopBarYOffset, ((Rect)(ref P)).width, (float)TopBarThickness))
{
if (Util.M.mouseButton)
{
BeingDragged = true;
DragOffset = new Vector2(((Rect)(ref P)).x - Util.M.mouse.x - 8f, ((Rect)(ref P)).y - Util.M.mouse.y - 8f);
Util.M.mouseIcon = 160;
}
else
{
Util.M.mouseIcon = 144;
}
}
else
{
Util.M.mouseIcon = 112;
}
}
else
{
Util.M.mouseIcon = 160;
if (!Util.M.mouseButton)
{
BeingDragged = false;
}
else
{
window.targetPosition = (Util.M.mouse + DragOffset) / 8f;
}
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("ExampleMod.UIExample", "Hello UI", "1.0.0")]
public class UIExamplePlugin : BaseUnityPlugin
{
private const string modID = "ExampleMod.UIExample";
internal static ManualLogSource Logger;
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
EasyAPI.AddsHUDListener<WeatherHUD>("ExampleMod.UIExample_WeatherHUD");
File val = EasyAPI.InstantiateFile();
val.type = (FileType)1;
val.name = "Weather";
val.icon = 2;
val.iconHover = 9;
val.data = "listener_" + val.name;
EasyAPI.AddListener<WeatherApp>(val.name);
EasyAPI.AddFile((DesktopLocation)0, val);
}
}
}