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.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LovePotionPhraseCustomizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LovePotionPhraseCustomizer")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c317df6d-e527-4a5a-bca4-61dc2e2fcda0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Arkanoidvfx.LovePotion_PhraseCustomizer", "LovePotion_PhraseCustomizer", "1.0.1")]
public class LovePotionPhraseCustomizer : BaseUnityPlugin
{
[HarmonyPatch]
private class LovePotionPatch
{
private static MethodBase TargetMethod()
{
return AccessTools.Method(AccessTools.TypeByName("ValuableLovePotion"), "GenerateAffectionateSentence", (Type[])null, (Type[])null);
}
[HarmonyPrefix]
private static bool Prefix(object __instance, ref string __result)
{
if (phrases.Count == 0)
{
return true;
}
if (Random.Range(0, 100) >= Instance.replacementChance.Value)
{
return true;
}
string input = "";
FieldInfo fieldInfo = AccessTools.Field(__instance.GetType(), "playerName");
if (fieldInfo != null)
{
input = (fieldInfo.GetValue(__instance) as string) ?? "";
}
input = Regex.Replace(input, "[^a-zA-Zа-яА-Я0-9 _-]", "").Trim();
string text = phrases[Random.Range(0, phrases.Count)];
__result = text.Replace("[player]", input);
return false;
}
}
private static Harmony _harmony;
private static List<ConfigEntry<string>> phraseEntries = new List<ConfigEntry<string>>();
private static List<string> phrases = new List<string>();
private ConfigEntry<int> replacementChance;
private string cfgPath => Path.Combine(Paths.ConfigPath, "Arkanoidvfx.LovePotion_PhraseCustomizer.cfg");
internal static LovePotionPhraseCustomizer Instance { get; private set; }
private void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Instance = this;
_harmony = new Harmony("Arkanoidvfx.LovePotion_PhraseCustomizer");
_harmony.PatchAll();
replacementChance = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "ReplacementChance", 100, "Chance (0–100) to replace the default love potion sentence with a custom one.\nExample: 100 = always use custom phrases, 0 = never.");
RegisterPhrases();
((BaseUnityPlugin)this).Logger.LogInfo((object)"LovePotion_PhraseCustomizer loaded");
}
private void RegisterPhrases()
{
for (int i = 0; i < 10; i++)
{
string text = $"Phrase{i + 1}";
if (1 == 0)
{
}
string text2 = i switch
{
0 => "Hey [player], hey [player], hey [player], hey [player] look at me, I love you",
1 => "You are my heart, [player], every moment with you is a dream come true.",
2 => "I feel complete when I'm with you, [player]. You make everything better.",
3 => "Every time I see you, my heart skips a beat, [player]. You mean the world to me.",
4 => "Being with you, [player], is like a beautiful dream I never want to end.",
5 => "You make me feel alive, [player]. I can’t imagine life without you by my side.",
6 => "You are the only buff I need, [player]. You make me feel unstoppable.",
7 => "If I could, I’d choose to meet you again and again, [player]. You are my destiny.",
8 => "Let me be yours forever, [player]. You’re the one I’ve always been waiting for.",
9 => "You are my main quest now, [player]. Nothing else matters as long as we're together.",
_ => "",
};
if (1 == 0)
{
}
string text3 = text2;
ConfigEntry<string> item = ((BaseUnityPlugin)this).Config.Bind<string>("Phrases", text, text3, (ConfigDescription)null);
phraseEntries.Add(item);
}
LoadRealPhrasesFromCfg();
}
private void LoadRealPhrasesFromCfg()
{
if (!File.Exists(cfgPath))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Config file not found when trying to filter phrases.");
return;
}
string text = "";
string[] array = File.ReadAllLines(cfgPath);
foreach (string text2 in array)
{
string text3 = text2.Trim();
if (string.IsNullOrEmpty(text3) || text3.StartsWith("#") || text3.StartsWith("##"))
{
continue;
}
if (text3.StartsWith("[") && text3.EndsWith("]"))
{
text = text3.Trim('[', ']');
}
else if (text == "Phrases" && Enumerable.Contains(text3, '='))
{
string[] array2 = text3.Split(new char[1] { '=' }, 2);
string text4 = array2[1].Trim();
if (!string.IsNullOrWhiteSpace(text4))
{
phrases.Add(text4);
}
}
}
}
}