Skip to content

Commit a00c4f0

Browse files
authored
Merge pull request #26 from KaBooMa/bleeding-edge
Bleeding edge
2 parents 0f4b72c + d3c8de9 commit a00c4f0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

S1API/Quests/Quest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ public Quest()
145145
poi.UIPrefab = uiPrefabObject;
146146
#endif
147147
S1Quest.PoIPrefab = poiPrefabObject;
148+
149+
S1Quest.onQuestEnd.AddListener((UnityAction<S1Quests.EQuestState>)OnQuestEnded);
148150
}
149151

150152
/// <summary>
@@ -156,7 +158,7 @@ internal override void CreateInternal()
156158

157159
base.CreateInternal();
158160

159-
// Initialize the quest
161+
// Initialize the quest
160162
S1Quest.InitializeQuest(Title, Description, Array.Empty<S1Data.QuestEntryData>(), S1Quest?.StaticGUID);
161163

162164
if (AutoBegin)
@@ -172,6 +174,17 @@ internal override void SaveInternal(string folderPath, ref List<string> extraSav
172174
base.SaveInternal(questDataPath, ref extraSaveables);
173175
}
174176

177+
/// <summary>
178+
/// INTERNAL: Called when the quest ends
179+
/// </summary>
180+
/// <param name="questState">The state it ended in.</param>
181+
internal void OnQuestEnded(S1Quests.EQuestState questState)
182+
{
183+
// Cleanup our quest in the API manager as well as game quests list
184+
S1Quests.Quest.Quests.Remove(S1Quest);
185+
QuestManager.Quests.Remove(this);
186+
}
187+
175188
/// <summary>
176189
/// Adds a new quest entry to the quest.
177190
/// </summary>

0 commit comments

Comments
 (0)