Skip to content

Commit 9cd4b33

Browse files
Cleaned up code for new project structure
1 parent bc0edb2 commit 9cd4b33

9 files changed

Lines changed: 41 additions & 95 deletions

InscryptionAPI/AscensionScreens/AscensionRunSetupScreenBase.cs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using DiskCardGame;
22
using HarmonyLib;
3-
using System;
43
using UnityEngine;
5-
using System.Linq;
6-
using APIPlugin;
7-
using System.Collections.Generic;
84
using GBC;
95

106
namespace InscryptionAPI.AscensionScreens
@@ -56,20 +52,20 @@ public virtual void InitializeScreen(GameObject partialScreen)
5652
public static AscensionRunSetupScreenBase BuildScreen(Type screenType, AscensionMenuScreens.Screen previousScreen, AscensionMenuScreens.Screen nextScreen)
5753
{
5854
// Create the new screen
59-
Plugin.Log.LogInfo($"Creating screen for {screenType.Name}");
55+
InscryptionAPIPlugin.Log.LogInfo($"Creating screen for {screenType.Name}");
6056

6157
GameObject pseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen;
6258
GameObject screenObject = GameObject.Instantiate(pseudoPrefab, pseudoPrefab.transform.parent);
6359
screenObject.name = screenType.Name;
6460

65-
Plugin.Log.LogInfo($"Getting old logic");
61+
InscryptionAPIPlugin.Log.LogInfo($"Getting old logic");
6662
AscensionCardsSummaryScreen oldController = screenObject.GetComponent<AscensionCardsSummaryScreen>();
6763

68-
Plugin.Log.LogInfo($"Adding new logic");
64+
InscryptionAPIPlugin.Log.LogInfo($"Adding new logic");
6965
AscensionRunSetupScreenBase controller = screenObject.AddComponent(screenType) as AscensionRunSetupScreenBase;
7066

7167
// Update the title of the screen
72-
Plugin.Log.LogInfo($"Updating screen title");
68+
InscryptionAPIPlugin.Log.LogInfo($"Updating screen title");
7369
GameObject textHeader = screenObject.transform.Find("Header/Mid").gameObject;
7470
textHeader.transform.localPosition = new Vector3(0f, -0.575f, 0f);
7571
controller.screenTitle = textHeader.GetComponent<PixelText>();
@@ -83,7 +79,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
8379
GameObject footerLowline = screenObject.transform.Find("Footer/PixelTextLine_DIV").gameObject;
8480
if (controller.showCardDisplayer)
8581
{
86-
Plugin.Log.LogInfo($"Resetting card information displayer");
82+
InscryptionAPIPlugin.Log.LogInfo($"Resetting card information displayer");
8783

8884
// Move the stuff
8985
cardTextDisplayer.transform.localPosition = new Vector3(2.38f, 0.27f, 0f);
@@ -101,12 +97,12 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
10197
}
10298
else
10399
{
104-
Plugin.Log.LogInfo($"Destroying unwanted card information displayer");
100+
InscryptionAPIPlugin.Log.LogInfo($"Destroying unwanted card information displayer");
105101
// Destroy the card text displayer and footer low line
106102
GameObject.Destroy(cardTextDisplayer);
107103
GameObject.Destroy(footerLowline);
108104

109-
Plugin.Log.LogInfo($"Creating new information displayer");
105+
InscryptionAPIPlugin.Log.LogInfo($"Creating new information displayer");
110106
GameObject newInfoDisplayer = GameObject.Instantiate(textHeader);
111107
controller.secondaryInfoDisplayer = newInfoDisplayer.GetComponent<PixelText>();
112108
controller.secondaryInfoDisplayer.SetColor(GameColors.Instance.nearWhite);
@@ -115,24 +111,24 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
115111

116112
if (controller.showCardPanel)
117113
{
118-
Plugin.Log.LogInfo($"Transferring ownership of cards");
114+
InscryptionAPIPlugin.Log.LogInfo($"Transferring ownership of cards");
119115
controller.cards = oldController.cards;
120116
}
121117

122118
// Destroy the old game logic
123-
Plugin.Log.LogInfo($"Destroying old game logic");
119+
InscryptionAPIPlugin.Log.LogInfo($"Destroying old game logic");
124120
Component.Destroy(oldController);
125121

126122
// Sort out the unlocks block
127-
Plugin.Log.LogInfo($"Handling card panel");
123+
InscryptionAPIPlugin.Log.LogInfo($"Handling card panel");
128124
controller.cardPanel = screenObject.transform.Find("Unlocks").gameObject;
129125
if (controller.showCardDisplayer)
130126
controller.cardPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f);
131127
else
132128
GameObject.Destroy(controller.cardPanel);
133129

134130
// Clone the challenge information from a challenge screen
135-
Plugin.Log.LogInfo($"Creating challenge text header");
131+
InscryptionAPIPlugin.Log.LogInfo($"Creating challenge text header");
136132
GameObject header = screenObject.transform.Find("Header").gameObject;
137133
SequentialPixelTextLines headerLines = header.AddComponent<SequentialPixelTextLines>();
138134

@@ -145,19 +141,19 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
145141

146142
// Set the old header lines to the lines of the sequential pixel text lines
147143
// Fundamentally, the old header now controls these new challenge level lines
148-
Plugin.Log.LogInfo($"Assigning new lines of text to header");
144+
InscryptionAPIPlugin.Log.LogInfo($"Assigning new lines of text to header");
149145
headerLines.lines = new List<PixelText>() {
150146
challengeLevel.GetComponent<PixelText>(),
151147
challengePoints.GetComponent<PixelText>()
152148
};
153149

154150
// And add those lines to the new challenge level controller
155-
Plugin.Log.LogInfo($"Giving controller access to header");
151+
InscryptionAPIPlugin.Log.LogInfo($"Giving controller access to header");
156152
ChallengeLevelText challengeLevelController = screenObject.AddComponent<ChallengeLevelText>();
157153
challengeLevelController.headerPointsLines = headerLines;
158154
controller.challengeHeaderDisplay = challengeLevelController;
159155

160-
Plugin.Log.LogInfo($"Creating challenge footer text");
156+
InscryptionAPIPlugin.Log.LogInfo($"Creating challenge footer text");
161157

162158
List<Transform> footerLinePseudos = new List<Transform>();
163159
GameObject challengeFooter = challengeScreen.transform.Find("Footer").gameObject;
@@ -166,7 +162,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
166162
footerLinePseudos.Add(child);
167163
footerLinePseudos.Sort((a, b) => a.localPosition.y < b.localPosition.y ? -1 : 1);
168164

169-
Plugin.Log.LogInfo($"Building footer text controller");
165+
InscryptionAPIPlugin.Log.LogInfo($"Building footer text controller");
170166
List<GameObject> newFooterLines = footerLinePseudos.Select(t => GameObject.Instantiate(t.gameObject, footer.transform)).ToList();
171167
SequentialPixelTextLines footerLines = footer.AddComponent<SequentialPixelTextLines>();
172168
footerLines.lines = newFooterLines.Select(o => o.GetComponent<PixelText>()).ToList();
@@ -178,14 +174,14 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
178174
controller.rightButton = screenObject.transform.Find("Unlocks/ScreenAnchor/PageRightButton").gameObject.GetComponent<MainInputInteractable>();
179175
if (controller.showCardPanel)
180176
{
181-
Plugin.Log.LogInfo($"Reassigning left/right scroll buttons");
177+
InscryptionAPIPlugin.Log.LogInfo($"Reassigning left/right scroll buttons");
182178
controller.leftButton.CursorSelectStarted = controller.LeftButtonClicked;
183179
controller.rightButton.CursorSelectStarted = controller.RightButtonClicked;
184180
controller.leftButton.gameObject.transform.localPosition = controller.leftButton.gameObject.transform.localPosition - (Vector3)BETWEEN_CARD_OFFSET * 1.5f;
185181
controller.rightButton.gameObject.transform.localPosition = controller.rightButton.gameObject.transform.localPosition + (Vector3)BETWEEN_CARD_OFFSET * 1.5f;
186182

187183
// Let's add three more cards to the panel
188-
Plugin.Log.LogInfo($"Expanding card panel");
184+
InscryptionAPIPlugin.Log.LogInfo($"Expanding card panel");
189185
GameObject cardPrefab = Resources.Load<GameObject>("prefabs/gbccardbattle/pixelselectablecard");
190186
Transform cardsParent = screenObject.transform.Find("Unlocks/ScreenAnchor/Cards");
191187
for (int i = 0; i < 3; i++)
@@ -200,7 +196,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
200196
Traverse.Create(newPixelComponent).Field("pixelBorder").SetValue(pixelBorder);
201197
}
202198

203-
Plugin.Log.LogInfo($"Assigning click action to cards in card panel");
199+
InscryptionAPIPlugin.Log.LogInfo($"Assigning click action to cards in card panel");
204200
foreach (PixelSelectableCard card in controller.cards)
205201
{
206202
card.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(card.CursorSelectStarted, new Action<MainInputInteractable>(delegate(MainInputInteractable i)
@@ -219,7 +215,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
219215
}
220216
else
221217
{
222-
Plugin.Log.LogInfo($"Destroying scroll buttons");
218+
InscryptionAPIPlugin.Log.LogInfo($"Destroying scroll buttons");
223219
GameObject.Destroy(controller.leftButton.gameObject);
224220
GameObject.Destroy(controller.rightButton.gameObject);
225221

@@ -229,13 +225,13 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
229225

230226

231227
// Reroute the back button
232-
Plugin.Log.LogInfo($"Rerouting back button");
228+
InscryptionAPIPlugin.Log.LogInfo($"Rerouting back button");
233229
GameObject backButton = screenObject.transform.Find("BackButton").gameObject;
234230
controller.backButton = backButton.GetComponent<AscensionMenuBackButton>();
235231
controller.backButton.screenToReturnTo = previousScreen;
236232

237233
// Add a continue button
238-
Plugin.Log.LogInfo($"Adding continue button");
234+
InscryptionAPIPlugin.Log.LogInfo($"Adding continue button");
239235
GameObject continuePrefab = Resources.Load<GameObject>("prefabs/ui/ascension/ascensionmenucontinuebutton");
240236
GameObject continueButton = GameObject.Instantiate(continuePrefab, screenObject.transform);
241237
continueButton.transform.localPosition = new Vector3(2.08f, 1.15f, 0f);
@@ -252,24 +248,24 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
252248
controller.continueButton.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(controller.continueButton.CursorSelectStarted, clickAction);
253249

254250
// Let the base class do its magic
255-
Plugin.Log.LogInfo($"Calling screen implementation to finish creating screen UI elements");
251+
InscryptionAPIPlugin.Log.LogInfo($"Calling screen implementation to finish creating screen UI elements");
256252
controller.InitializeScreen(screenObject);
257253

258254
// And we're done
259-
Plugin.Log.LogInfo($"Done building screen");
255+
InscryptionAPIPlugin.Log.LogInfo($"Done building screen");
260256
return controller;
261257
}
262258

263259
private static void TransitionToGame()
264260
{
265261
if (!AscensionSaveData.Data.ChallengeLevelIsMet() && AscensionSaveData.Data.challengeLevel <= 12)
266262
{
267-
Plugin.Log.LogInfo("Sending the player to the confirmation screen");
263+
InscryptionAPIPlugin.Log.LogInfo("Sending the player to the confirmation screen");
268264
AscensionMenuScreens.Instance.SwitchToScreen(AscensionMenuScreens.Screen.SelectChallengesConfirm);
269265
}
270266
else
271267
{
272-
Plugin.Log.LogInfo("Starting a new run");
268+
InscryptionAPIPlugin.Log.LogInfo("Starting a new run");
273269
AscensionMenuScreens.Instance.TransitionToGame(true);
274270
}
275271
}

InscryptionAPI/AscensionScreens/AscensionScreenManager.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using DiskCardGame;
22
using HarmonyLib;
3-
using System;
43
using UnityEngine;
5-
using System.Linq;
6-
using APIPlugin;
7-
using System.Collections.Generic;
8-
using GBC;
94
using System.Collections;
105

116
namespace InscryptionAPI.AscensionScreens
@@ -72,7 +67,7 @@ public static void InitializeAllScreens()
7267
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
7368
} catch (Exception ex)
7469
{
75-
Plugin.Log.LogError(ex);
70+
InscryptionAPIPlugin.Log.LogError(ex);
7671
}
7772
}
7873

InscryptionAPI/Challenges/AscensionChallengePaginator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using DiskCardGame;
2-
using System.Linq;
32
using UnityEngine;
4-
using System.Collections.Generic;
53

64
namespace InscryptionAPI.Challenges
75
{

InscryptionAPI/Challenges/AscensionChallengeScreen.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
using DiskCardGame;
2-
using System;
3-
using System.Linq;
42
using HarmonyLib;
5-
using Mono.Collections.Generic;
6-
using Sirenix.Serialization.Utilities;
73
using UnityEngine;
8-
using System.Diagnostics.CodeAnalysis;
9-
using System.Collections.Generic;
10-
using APIPlugin;
114

125
namespace InscryptionAPI.Challenges
136
{
@@ -45,25 +38,25 @@ public static void AddPaginationToChallengeScreen()
4538
{
4639
if (ChallengeManager.newInfos.Count > 0)
4740
{
48-
Plugin.Log.LogInfo($"Creating Paginator");
41+
InscryptionAPIPlugin.Log.LogInfo($"Creating Paginator");
4942

5043
AscensionChallengePaginator paginator = AscensionMenuScreens.Instance.selectChallengesScreen.GetComponent<AscensionChallengePaginator>();
5144
if (paginator == null)
5245
paginator = AscensionMenuScreens.Instance.selectChallengesScreen.AddComponent<AscensionChallengePaginator>();
5346

54-
Plugin.Log.LogInfo($"Getting pseudo prefabs");
47+
InscryptionAPIPlugin.Log.LogInfo($"Getting pseudo prefabs");
5548

5649
GameObject leftPseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageLeftButton").gameObject;
5750
GameObject rightPseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageRightButton").gameObject;
5851

59-
Plugin.Log.LogInfo($"Getting icon grid");
52+
InscryptionAPIPlugin.Log.LogInfo($"Getting icon grid");
6053

6154
GameObject challengeIconGrid = AscensionMenuScreens.Instance.selectChallengesScreen.transform.Find("Icons/ChallengeIconGrid").gameObject;
6255

6356
GameObject topRow = challengeIconGrid.transform.Find("TopRow").gameObject;
6457
GameObject bottomRow = challengeIconGrid.transform.Find("BottomRow").gameObject;
6558

66-
Plugin.Log.LogInfo($"Initializing data");
59+
InscryptionAPIPlugin.Log.LogInfo($"Initializing data");
6760

6861
paginator.topRow = new List<AscensionIconInteractable>();
6962
paginator.bottomRow = new List<AscensionIconInteractable>();
@@ -73,15 +66,15 @@ public static void AddPaginationToChallengeScreen()
7366
paginator.bottomRow.Add(bottomRow.transform.Find($"Icon_{i+7}").gameObject.GetComponent<AscensionIconInteractable>());
7467
}
7568

76-
Plugin.Log.LogInfo($"Original challenge info");
69+
InscryptionAPIPlugin.Log.LogInfo($"Original challenge info");
7770
paginator.availableChallenges = new List<AscensionChallengeInfo>();
7871
for (int i = 0; i < 7; i++)
7972
{
8073
paginator.availableChallenges.Add(paginator.topRow[i].challengeInfo);
8174
paginator.availableChallenges.Add(paginator.bottomRow[i].challengeInfo);
8275
}
8376

84-
Plugin.Log.LogInfo($"Custom challenge info");
77+
InscryptionAPIPlugin.Log.LogInfo($"Custom challenge info");
8578
foreach (AscensionChallengeInfo info in ChallengeManager.newInfos.Where(i => ChallengeManager.IsStackable(i.challengeType)))
8679
{
8780
paginator.availableChallenges.Add(info); // Add stackables twice
@@ -95,22 +88,22 @@ public static void AddPaginationToChallengeScreen()
9588

9689
paginator.GeneratePages();
9790

98-
Plugin.Log.LogInfo($"Creating page turners");
91+
InscryptionAPIPlugin.Log.LogInfo($"Creating page turners");
9992
GameObject leftIcon = GameObject.Instantiate(leftPseudoPrefab, challengeIconGrid.transform);
10093
GameObject rightIcon = GameObject.Instantiate(rightPseudoPrefab, challengeIconGrid.transform);
10194

102-
Plugin.Log.LogInfo($"Positioning page turners");
95+
InscryptionAPIPlugin.Log.LogInfo($"Positioning page turners");
10396
leftIcon.transform.localPosition = leftIcon.transform.localPosition + (Vector3)(new Vector2(-0.75f, 0.25f));
10497
rightIcon.transform.localPosition = rightIcon.transform.localPosition + (Vector3)(new Vector2(0.75f, 0.25f));;
10598

106-
Plugin.Log.LogInfo($"Getting pagination controllers");
99+
InscryptionAPIPlugin.Log.LogInfo($"Getting pagination controllers");
107100
AscensionMenuInteractable leftController = leftIcon.GetComponent<AscensionMenuInteractable>();
108101
AscensionMenuInteractable rightController = rightIcon.GetComponent<AscensionMenuInteractable>();
109102

110103
Action<MainInputInteractable> leftClickAction = (MainInputInteractable i) => paginator.ChallengePageLeft(i);
111104
Action<MainInputInteractable> rightClickAction = (MainInputInteractable i) => paginator.ChallengePageRight(i);
112105

113-
Plugin.Log.LogInfo($"Setting click actions");
106+
InscryptionAPIPlugin.Log.LogInfo($"Setting click actions");
114107
leftController.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(leftController.CursorSelectStarted, leftClickAction);
115108
rightController.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(rightController.CursorSelectStarted, rightClickAction);
116109

InscryptionAPI/Challenges/ChallengeManager.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
using DiskCardGame;
2-
using System;
3-
using System.Linq;
42
using HarmonyLib;
53
using Mono.Collections.Generic;
6-
using Sirenix.Serialization.Utilities;
74
using UnityEngine;
8-
using System.Diagnostics.CodeAnalysis;
9-
using System.Collections.Generic;
105
using InscryptionAPI.Guid;
116

127
namespace InscryptionAPI.Challenges

InscryptionAPI/Guid/GuidManager.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
using DiskCardGame;
2-
using System;
3-
using System.Linq;
4-
using HarmonyLib;
5-
using Mono.Collections.Generic;
6-
using Sirenix.Serialization.Utilities;
7-
using UnityEngine;
8-
using System.Diagnostics.CodeAnalysis;
9-
using System.Collections.Generic;
10-
using System.Reflection;
11-
using System.IO;
12-
using APIPlugin;
131
using InscryptionAPI.Saves;
142

153
namespace InscryptionAPI.Guid
@@ -28,7 +16,7 @@ public static string GetFullyQualifiedName(string guid, string value)
2816
public static int GetEnumValue<T>(string guid, string value) where T : System.Enum
2917
{
3018
string saveKey = GetFullyQualifiedName(guid, value);
31-
string saveGuid = GetFullyQualifiedName("cyantist.inscryption.api", typeof(T).Name);
19+
string saveGuid = GetFullyQualifiedName(InscryptionAPIPlugin.ModGUID, typeof(T).Name);
3220

3321
int enumValue = ModdedSaveManager.SaveData.GetValueAsInt(saveGuid, saveKey);
3422

InscryptionAPI/InscryptionAPIPlugin.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
global using UnityObject = UnityEngine.Object;
22

33
using BepInEx;
4+
using BepInEx.Logging;
45
using HarmonyLib;
56

67
namespace InscryptionAPI;
@@ -13,9 +14,12 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
1314
public const string ModVer = "2.0.0";
1415

1516
private readonly Harmony HarmonyInstance = new(ModGUID);
17+
18+
internal static ManualLogSource Log;
1619

1720
public void OnEnable()
1821
{
22+
Log = this.Logger;
1923
HarmonyInstance.PatchAll(typeof(InscryptionAPIPlugin).Assembly);
2024
}
2125

0 commit comments

Comments
 (0)