-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicMod.cs
138 lines (105 loc) · 3.88 KB
/
BasicMod.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using BepInEx;
using UnityEngine;
using HarmonyLib;
using BasicMod.GameHooks;
using BasicMod.SaltUI;
using BasicMod.SaltUI.WindowElements;
using ScrollWindowHint;
using TutorialSystem;
using BasicMod.Factories;
using BasicMod.JSON;
using BepInEx.Configuration;
namespace BasicMod
{
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
public class BasicMod : BaseUnityPlugin
{
public static ConfigEntry<bool> clearQuestConfig;
public const string pluginGuid = "potioncraft.basicmod";
public const string pluginName = "Basic Mod";
public const string pluginVersion = "0.0.2";
public void Awake()
{
DoPatching();
Debug.Log("Loaded BasicMod!");
JSONModLoader.Awake();
//JSONQuestLoader.Awake();
JSONRecipeLoader.Awake();
JSONSaltLoader.Awake();
DuplicateRecipes.Awake();
SaltFactory.Awake();
LegendaryRecipeFactory.Awake();
GoalFactory.Awake();
TalentFactory.Awake();
RequestFactory.Awake();
clearQuestConfig = Config.Bind("BasicMod Settings", "clearVanillaQuests", false, "Clears Vanilla Groundhog day potion requests. Useful when developing a requests pack.");
RequestFactory.doClearQuests = clearQuestConfig.Value;
NewGameEvent.OnNewGame += (_, e) =>
{
// Mark the event handled so the game's own code doesnt run.
e.Handled = true;
//Do the StartNewGame stuff minus the tutorial
Managers.Menu.CloseMenu();
Managers.SaveLoad.LoadNewGameState();
Managers.SaveLoad.SelectedProgressState = null;
//Basic Mod welcome message start
ModHintParameters param = new ModHintParameters();
param.darkScreen = true; //Locks out the rest of the screen
//Set window anchor position
param.anchorPosition = new Vector2(0, 5);
//Scroll windows want keys, so we use LocalDict
LocalDict.AddKeyToDictionary($"{pluginGuid}:welcometitle", "Basic Mod");
param.titleKey = $"{pluginGuid}:welcometitle";
//Create a text window element to display body text
var text1 = new TextWindowElement();
LocalDict.AddKeyToDictionary($"{pluginGuid}:welcometext", $"Welcome to Basic Mod version {pluginVersion}.\nWould you like to play the base game tutorial?");
text1.text = $"{pluginGuid}:welcometext";
LocalDict.AddKeyToDictionary($"{pluginGuid}:tutorialyes", "Yes, please.");
LocalDict.AddKeyToDictionary($"{pluginGuid}:tutorialno", "No, I'm a master alchemist.\nWhy would you even ask me that?");
//OptionWithButtonWindowElement displays text with a button to the right of it. If necessary, you can change the elements offsets to line things up how you like.
var button1 = new OptionWithButtonWindowElement();
button1.text = $"{pluginGuid}:tutorialyes";
var button2 = new OptionWithButtonWindowElement();
button2.textOffset += new Vector2(0, 0.2f);
button2.text = $"{pluginGuid}:tutorialno";
param.scrollWindowElements.Add(text1);
param.scrollWindowElements.Add(button1);
param.scrollWindowElements.Add(button2);
//See start tutorial button class
param.buttonPressedAction = new StartTutorialButtonAction(Managers.Game.scrollWindow);
ScrollWindow.Open(new ModScrollWindowContentController(param));
};
SaltFactory.onPreRegisterSaltEvent += (_, e) =>
{
ModSalt dsalt = SaltFactory.CreateSalt("Default Salt");
};
}
//HarmonyPatching
private void DoPatching()
{
var harmony = new HarmonyLib.Harmony("hxp.basicmod");
harmony.PatchAll();
}
public static void LogSalts()
{
Debug.Log("Called LogSalts");
foreach (InventoryItem allSalt in Salt.allSalts)
{
Debug.Log(allSalt.name);
}
}
public static void LogEffects()
{
foreach (PotionEffect effect in PotionEffect.allPotionEffects)
{
Debug.Log(effect.name);
}
}
public static void ForceTutorialStart(TutorialSet tutorial)
{
Managers.Tutorial.DisableTutorial();
tutorial.SetStart();
Managers.Tutorial.tutorialActiveIsChanged.Invoke();
}
}
}