fr.jeanf.questsystem 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
using System;
|
|
1
2
|
using jeanf.EventSystem;
|
|
2
3
|
using UnityEngine;
|
|
3
4
|
using UnityEngine.Serialization;
|
|
@@ -14,6 +15,7 @@ namespace jeanf.questsystem
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
[SerializeField] private bool _isDebug = false;
|
|
18
|
+
[SerializeField] private bool _startQuestOnEnable = false;
|
|
17
19
|
|
|
18
20
|
[Tooltip("Visual feedback for the quest state")] [Header("Quest")] [SerializeField]
|
|
19
21
|
private QuestInfoSO questInfoForPoint;
|
|
@@ -21,7 +23,7 @@ namespace jeanf.questsystem
|
|
|
21
23
|
[ReadOnly] [Range(0, 1)] [SerializeField]
|
|
22
24
|
private float progress = 0.0f;
|
|
23
25
|
|
|
24
|
-
[
|
|
26
|
+
[SerializeField] [ReadOnly]
|
|
25
27
|
private bool clearToStart = false;
|
|
26
28
|
|
|
27
29
|
private string questId;
|
|
@@ -58,7 +60,11 @@ namespace jeanf.questsystem
|
|
|
58
60
|
questId = questInfoForPoint.id;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
private void OnEnable()
|
|
63
|
+
private void OnEnable() => Subscribe();
|
|
64
|
+
private void OnDisable() => Unsubscribe();
|
|
65
|
+
private void OnDestroy() => Unsubscribe();
|
|
66
|
+
|
|
67
|
+
private void Subscribe()
|
|
62
68
|
{
|
|
63
69
|
StartQuestEventChannel.OnEventRaised += RequestQuestStart;
|
|
64
70
|
QuestProgress.OnEventRaised += UpdateProgress;
|
|
@@ -66,9 +72,6 @@ namespace jeanf.questsystem
|
|
|
66
72
|
GameEventsManager.instance.inputEvents.onSubmitPressed += UpdateState;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
private void OnDisable() => Unsubscribe();
|
|
70
|
-
private void OnDestroy() => Unsubscribe();
|
|
71
|
-
|
|
72
75
|
private void Unsubscribe()
|
|
73
76
|
{
|
|
74
77
|
StartQuestEventChannel.OnEventRaised -= RequestQuestStart;
|
|
@@ -115,6 +118,9 @@ namespace jeanf.questsystem
|
|
|
115
118
|
if (quest.info.id.Equals(questId))
|
|
116
119
|
{
|
|
117
120
|
currentQuestState = quest.state;
|
|
121
|
+
|
|
122
|
+
// start on enable option
|
|
123
|
+
if (_startQuestOnEnable && quest.state == QuestState.CAN_START) RequestQuestStart(quest.info.id);
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
|
|
@@ -128,6 +134,7 @@ namespace jeanf.questsystem
|
|
|
128
134
|
{
|
|
129
135
|
if(id!= questId) return;
|
|
130
136
|
AllClear(true);
|
|
137
|
+
if(isDebug) Debug.Log($"Quest start was requested for quest {id}.", this);
|
|
131
138
|
}
|
|
132
139
|
}
|
|
133
140
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using jeanf.EventSystem;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEngine;
|
|
2
5
|
|
|
3
6
|
namespace jeanf.questsystem
|
|
4
7
|
{
|
|
@@ -10,6 +13,7 @@ namespace jeanf.questsystem
|
|
|
10
13
|
{
|
|
11
14
|
if (onStartQuest != null)
|
|
12
15
|
{
|
|
16
|
+
Debug.Log($"starting quest: {id}");
|
|
13
17
|
onStartQuest(id);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
@@ -20,6 +24,7 @@ namespace jeanf.questsystem
|
|
|
20
24
|
{
|
|
21
25
|
if (onAdvanceQuest != null)
|
|
22
26
|
{
|
|
27
|
+
Debug.Log($"advancing quest: {id}");
|
|
23
28
|
onAdvanceQuest(id);
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -30,6 +35,7 @@ namespace jeanf.questsystem
|
|
|
30
35
|
{
|
|
31
36
|
if (onFinishQuest != null)
|
|
32
37
|
{
|
|
38
|
+
Debug.Log($"finishing quest: {id}");
|
|
33
39
|
onFinishQuest(id);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -40,6 +46,7 @@ namespace jeanf.questsystem
|
|
|
40
46
|
{
|
|
41
47
|
if (onQuestStateChange != null)
|
|
42
48
|
{
|
|
49
|
+
Debug.Log($"quest state change: {quest.info.id} -- state: {quest.state}");
|
|
43
50
|
onQuestStateChange(quest);
|
|
44
51
|
}
|
|
45
52
|
}
|
|
@@ -50,8 +57,10 @@ namespace jeanf.questsystem
|
|
|
50
57
|
{
|
|
51
58
|
if (onQuestStepStateChange != null)
|
|
52
59
|
{
|
|
60
|
+
Debug.Log($"quest step state change: {id} -- stepstate: {questStepState}");
|
|
53
61
|
onQuestStepStateChange(id, stepIndex, questStepState);
|
|
54
62
|
}
|
|
55
63
|
}
|
|
64
|
+
|
|
56
65
|
}
|
|
57
66
|
}
|