using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Notiffy.API;
using Notiffy.Utils;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ActivateNocturnalOS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c7d506d6da14246bc9fe5449e0b9a2c78ddcc2e6")]
[assembly: AssemblyProduct("ActivateNocturnalOS")]
[assembly: AssemblyTitle("ActivateNocturnalOS")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ActivateNocturnalOS
{
public class ConfigManager
{
public static PluginConfigurator config;
public static BoolField activated;
public static StringField nagTitle;
public static StringField nagBodyText;
public static FloatField nagOpacity;
public static BoolField sendNotifications;
public static IntField notificationInterval;
public static StringField lastVersion;
public static void Initialize()
{
}
static ConfigManager()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Expected O, but got Unknown
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Expected O, but got Unknown
config = PluginConfigurator.Create("Nocturnal OS License", "com.github.end-4.activateNocturnalOS");
string text = Path.Combine(Core.workingDir, "icon.png");
if (File.Exists(text))
{
config.SetIconWithURL(text);
}
new ConfigHeader(config.rootPanel, "", 10);
new ConfigHeader(config.rootPanel, "-- ACTIVATION SETTINGS --", 24);
activated = new BoolField(config.rootPanel, "Activate Nocturnal OS", "activatedNocturnal", false);
nagTitle = new StringField(config.rootPanel, "Title text", "titleText", "Activate Nocturnal OS");
nagBodyText = new StringField(config.rootPanel, "Body text", "bodyText", "Go to Settings to activate Nocturnal OS");
nagOpacity = new FloatField(config.rootPanel, "Opacity", "nagOpacity", 0.35f, 0f, 1f);
activated.postValueChangeEvent += (PostBoolValueChangeEvent)delegate
{
Core.UpdateNagText();
};
nagTitle.postValueChangeEvent += (PostStringValueChangeEvent)delegate
{
Core.UpdateNagText();
};
nagBodyText.postValueChangeEvent += (PostStringValueChangeEvent)delegate
{
Core.UpdateNagText();
};
nagOpacity.postValueChangeEvent += (PostFloatValueChangeEvent)delegate
{
Core.UpdateNagText();
};
new ConfigHeader(config.rootPanel, "-- NOTIFICATIONS --", 24);
sendNotifications = new BoolField(config.rootPanel, "Send notifications", "sendNotifications", false);
notificationInterval = new IntField(config.rootPanel, "Notification interval (seconds)", "notificationInterval", 2700);
lastVersion = new StringField(config.rootPanel, "Last version", "lastVersion", "1.0.0");
((ConfigField)lastVersion).hidden = true;
}
}
[BepInPlugin("com.github.end-4.activateNocturnalOS", "ActivateNocturnalOS", "1.1.0")]
public class Core : BaseUnityPlugin
{
internal static ManualLogSource? Log;
public static string workingPath = Assembly.GetExecutingAssembly().Location;
public static string workingDir = Path.GetDirectoryName(workingPath);
public const string PluginGUID = "com.github.end-4.activateNocturnalOS";
public const string PluginName = "ActivateNocturnalOS";
public const string PluginVersion = "1.1.0";
private float? lastNotification;
private static Notification[] notifs = (Notification[])(object)new Notification[3]
{
new Notification
{
Summary = "Backup to FourDrive",
Body = "Keep your files safe from attacks",
NotificationIcon = Img2Sprite.LoadNewSprite(Path.Combine(workingDir, "assets/fourdrive.png"), 100f, (SpriteMeshType)1),
Actions = new List<string>(4) { "yes", "Set up", "no", "Maybe later" }
},
new Notification
{
Summary = "Get a genuine NocturnalOS license",
Body = "You may be a Fraud",
NotificationIcon = Img2Sprite.LoadNewSprite(Path.Combine(workingDir, "icon.png"), 100f, (SpriteMeshType)1)
},
new Notification
{
Summary = "Try Smilesoft365",
Body = "Give your productivity a boost",
NotificationIcon = Img2Sprite.LoadNewSprite(Path.Combine(workingDir, "assets/smilesoft365.png"), 100f, (SpriteMeshType)1),
Actions = new List<string>(4) { "yes", "30 days free", "no", "I'll pass" }
}
};
private static GameObject? nagCanvas;
private static TMP_FontAsset? ukFont;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
ConfigManager.Initialize();
SceneManager.sceneLoaded += OnSceneLoaded;
UserHints.Initialize();
Log.LogInfo((object)"ActivateNocturnalOS loaded!");
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if ((Object)(object)ukFont == (Object)null)
{
ukFont = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name.Contains("VCR")));
}
CreateLicenseNag();
}
private static void CreateLicenseNag()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)nagCanvas != (Object)null))
{
nagCanvas = new GameObject("NocturnalOS_NagCanvas");
Object.DontDestroyOnLoad((Object)(object)nagCanvas);
Canvas obj = nagCanvas.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 999;
CanvasScaler obj2 = nagCanvas.AddComponent<CanvasScaler>();
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2((float)Screen.width, (float)Screen.height);
obj2.screenMatchMode = (ScreenMatchMode)0;
obj2.matchWidthOrHeight = 0.5f;
GameObject val = new GameObject("NagContainer");
val.transform.SetParent(nagCanvas.transform);
RectTransform obj3 = val.AddComponent<RectTransform>();
obj3.anchorMin = new Vector2(1f, 0f);
obj3.anchorMax = new Vector2(1f, 0f);
obj3.pivot = new Vector2(1f, 0f);
obj3.anchoredPosition = new Vector2(-45f, 45f);
obj3.sizeDelta = new Vector2(410f, 150f);
VerticalLayoutGroup obj4 = val.AddComponent<VerticalLayoutGroup>();
((LayoutGroup)obj4).childAlignment = (TextAnchor)6;
((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)obj4).spacing = 5f;
CreateText(val.transform, "Activate Nocturnal OS", 28f, (FontStyles)0, new Color(1f, 1f, 1f, 0.35f));
CreateText(val.transform, "Go to Settings to activate Nocturnal OS", 18f, (FontStyles)0, new Color(1f, 1f, 1f, 0.5f));
UpdateNagText();
}
}
internal static void UpdateNagText()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)nagCanvas == (Object)null) && ConfigManager.activated != null && ConfigManager.nagTitle != null && ConfigManager.nagBodyText != null && ConfigManager.nagOpacity != null)
{
nagCanvas.SetActive(!ConfigManager.activated.value);
TextMeshProUGUI[] componentsInChildren = nagCanvas.GetComponentsInChildren<TextMeshProUGUI>(true);
if (componentsInChildren.Length >= 2)
{
((TMP_Text)componentsInChildren[0]).text = ConfigManager.nagTitle.value;
((TMP_Text)componentsInChildren[1]).text = ConfigManager.nagBodyText.value;
}
TextMeshProUGUI[] array = componentsInChildren;
foreach (TextMeshProUGUI obj in array)
{
Color color = ((Graphic)obj).color;
color.a = ConfigManager.nagOpacity.value;
((Graphic)obj).color = color;
}
}
}
private static void CreateText(Transform parent, string content, float fontSize, FontStyles style, Color color)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("NagText_" + ((content.Length >= 5) ? content.Substring(0, 5) : content));
val.transform.SetParent(parent);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = content;
((TMP_Text)val2).fontSize = fontSize;
((TMP_Text)val2).fontStyle = style;
((Graphic)val2).color = color;
((TMP_Text)val2).alignment = (TextAlignmentOptions)513;
if ((Object)(object)ukFont != (Object)null)
{
((TMP_Text)val2).font = ukFont;
}
}
private void Update()
{
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
if (!lastNotification.HasValue)
{
lastNotification = Time.time;
return;
}
BoolField sendNotifications = ConfigManager.sendNotifications;
if (sendNotifications != null && sendNotifications.value)
{
float? num = Time.time - lastNotification;
IntField notificationInterval = ConfigManager.notificationInterval;
if (num >= (float?)((notificationInterval != null) ? new int?(notificationInterval.value) : null))
{
lastNotification = Time.time;
NotificationSystem.Notify(notifs[Random.Range(0, notifs.Length)]);
}
}
}
}
public static class UserHints
{
public static void IssueUpdateNoticeIfNecessary()
{
Version value = new Version(ConfigManager.lastVersion.value);
if (new Version("1.1.0").CompareTo(value) == 1)
{
ConfigManager.lastVersion.value = "1.1.0";
NotificationSystem.NotifySend("<color=#3a93e9>Activate Nocturnal OS</color> updated", "<b>1.1.0:</b> Introduced random funny ads. This is off by default and you can enable it manually in Plugin Config", (Sprite)null, Path.Combine(Core.workingDir, "icon.png"), (Urgency)1, "NotifySend", 0u, (Dictionary<string, string>)null, 10000);
}
}
public static void Initialize()
{
}
static UserHints()
{
NotificationSystem.ReadyForScene += IssueUpdateNoticeIfNecessary;
}
}
}