82 lines
3.6 KiB
C#
82 lines
3.6 KiB
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace Harmony.QuestClassPatches
|
|
{
|
|
[HarmonyPatch(typeof(QuestClass))]
|
|
[HarmonyPatch("Init")]
|
|
public class InitPatch
|
|
{
|
|
public static void Postfix(QuestClass __instance)
|
|
{
|
|
if (__instance.ID.ToLower().Contains("_infested"))
|
|
{
|
|
string option = RebirthVariables.customInfested;
|
|
|
|
if (option.ToLower().Contains("hide"))
|
|
{
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropStatementKey))
|
|
{
|
|
__instance.StatementText = Localization.Get("quest_clear_statement");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropResponseKey))
|
|
{
|
|
__instance.ResponseText = Localization.Get("quest_clear_response");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropSubtitleKey))
|
|
{
|
|
__instance.SubTitle = Localization.Get("quest_clear_subtitle");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropDescriptionKey))
|
|
{
|
|
__instance.Description = Localization.Get("quest_clear_description");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropGroupNameKey))
|
|
{
|
|
__instance.GroupName = Localization.Get("quest_tier2_clear");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropOfferKey))
|
|
{
|
|
__instance.Offer = Localization.Get("quest_tier2_clear_offer");
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropNameKey))
|
|
{
|
|
string NameKey = __instance.Properties.Values[QuestClass.PropNameKey].Replace("_infested", "");
|
|
|
|
//Log.Out("QuestClassPatches-Init BEFORE NameKey: " + NameKey);
|
|
|
|
string resultString = Regex.Match(__instance.Name, @"\d+").Value;
|
|
|
|
//Log.Out("QuestClassPatches-Init resultString: " + resultString);
|
|
|
|
if (!NameKey.ToLower().Contains("test") && resultString != null)
|
|
{
|
|
int num = Int32.Parse(resultString) - 1;
|
|
|
|
//Log.Out("QuestClassPatches-Init num: " + num);
|
|
|
|
NameKey = NameKey.Replace(resultString, num.ToString());
|
|
//Log.Out("QuestClassPatches-Init AFTER NameKey: " + NameKey);
|
|
}
|
|
|
|
__instance.Name = Localization.Get(NameKey);
|
|
//Log.Out("QuestClassPatches-Init __instance.Name: " + __instance.Name);
|
|
}
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropOffer))
|
|
{
|
|
__instance.Offer = __instance.Properties.Values[QuestClass.PropOffer].Replace("_infested", "");
|
|
}
|
|
}
|
|
|
|
if (option == "hidesurprise")
|
|
{
|
|
if (__instance.Properties.Values.ContainsKey(QuestClass.PropDifficultyTier))
|
|
{
|
|
int difficulty = int.Parse(__instance.Properties.Values[QuestClass.PropDifficultyTier]);
|
|
__instance.DifficultyTier = Convert.ToByte(difficulty - 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|