fr.jeanf.questsystem 0.0.60 → 0.0.61
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.
- package/Runtime/Scripts/Core/Editor/QuestItem_Editor.cs +32 -0
- package/Runtime/Scripts/Core/Editor/QuestItem_Editor.cs.meta +11 -0
- package/Runtime/Scripts/Core/Editor/QuestStep_Editor.cs +8 -0
- package/Runtime/Scripts/Core/QuestItem.cs +17 -19
- package/Runtime/Scripts/Core/QuestStep.cs +25 -3
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace jeanf.questsystem
|
|
6
|
+
{
|
|
7
|
+
[CustomEditor(typeof(QuestItem), true)]
|
|
8
|
+
public class QuestItem_Editor : Editor
|
|
9
|
+
{
|
|
10
|
+
public override void OnInspectorGUI()
|
|
11
|
+
{
|
|
12
|
+
GUILayout.Space(10);
|
|
13
|
+
var eventToSend = (QuestItem)target;
|
|
14
|
+
GUILayout.BeginHorizontal();
|
|
15
|
+
if(GUILayout.Button("Log active steps", GUILayout.Height(20))) {
|
|
16
|
+
eventToSend.LogActiveSteps(); // how do i call this?
|
|
17
|
+
}
|
|
18
|
+
var originalColor = GUI.backgroundColor;
|
|
19
|
+
GUI.backgroundColor = Color.green;
|
|
20
|
+
if (GUILayout.Button("Validate Currently Active Steps", GUILayout.Height(20)))
|
|
21
|
+
{
|
|
22
|
+
eventToSend.ValidateCurrentlyActiveSteps(); // how do i call this?
|
|
23
|
+
}
|
|
24
|
+
GUI.backgroundColor = originalColor;
|
|
25
|
+
GUILayout.EndHorizontal();
|
|
26
|
+
GUILayout.Space(10);
|
|
27
|
+
|
|
28
|
+
DrawDefaultInspector();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
#endif
|
|
@@ -11,10 +11,18 @@ namespace jeanf.questsystem
|
|
|
11
11
|
{
|
|
12
12
|
GUILayout.Space(10);
|
|
13
13
|
var eventToSend = (QuestStep)target;
|
|
14
|
+
GUILayout.BeginHorizontal();
|
|
14
15
|
if (GUILayout.Button("Regenerate questStep id", GUILayout.Height(20)))
|
|
15
16
|
{
|
|
16
17
|
eventToSend.GenerateId(); // how do i call this?
|
|
17
18
|
}
|
|
19
|
+
var originalColor = GUI.backgroundColor;
|
|
20
|
+
GUI.backgroundColor = Color.green;
|
|
21
|
+
if(GUILayout.Button("Validate step", GUILayout.Height(20))) {
|
|
22
|
+
eventToSend.FinishQuestStep(); // how do i call this?
|
|
23
|
+
}
|
|
24
|
+
GUI.backgroundColor = originalColor;
|
|
25
|
+
GUILayout.EndHorizontal();
|
|
18
26
|
GUILayout.Space(10);
|
|
19
27
|
|
|
20
28
|
DrawDefaultInspector();
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
3
4
|
using jeanf.EventSystem;
|
|
4
5
|
using UnityEngine;
|
|
5
6
|
using jeanf.propertyDrawer;
|
|
6
7
|
using jeanf.validationTools;
|
|
7
8
|
using UnityEditor;
|
|
8
|
-
using System.Linq;
|
|
9
|
-
using Object = UnityEngine.Object;
|
|
10
|
-
|
|
11
9
|
|
|
12
10
|
namespace jeanf.questsystem
|
|
13
11
|
{
|
|
@@ -30,6 +28,10 @@ namespace jeanf.questsystem
|
|
|
30
28
|
private Dictionary<string, QuestStep> completedSteps = new Dictionary<string, QuestStep>();
|
|
31
29
|
private List<QuestStep> rootSteps = new List<QuestStep>();
|
|
32
30
|
|
|
31
|
+
public delegate void ValidateStep(string stepId);
|
|
32
|
+
|
|
33
|
+
public static ValidateStep ValidateStepEvent;
|
|
34
|
+
|
|
33
35
|
|
|
34
36
|
[ReadOnly] [Range(0, 1)] [SerializeField]
|
|
35
37
|
private float progress = 0.0f;
|
|
@@ -249,6 +251,18 @@ namespace jeanf.questsystem
|
|
|
249
251
|
}
|
|
250
252
|
#endregion
|
|
251
253
|
|
|
254
|
+
public void ValidateCurrentlyActiveSteps()
|
|
255
|
+
{
|
|
256
|
+
var currentlyActiveSteps = activeSteps.Keys;
|
|
257
|
+
|
|
258
|
+
for (var i = 0; i < currentlyActiveSteps.Count; i++)
|
|
259
|
+
{
|
|
260
|
+
var activeStep = activeSteps.ElementAt(i);
|
|
261
|
+
var stepKey = activeStep.Key;
|
|
262
|
+
if(activeSteps.ContainsKey(stepKey)) ValidateStepEvent.Invoke(stepKey);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
252
266
|
#region validation tools
|
|
253
267
|
|
|
254
268
|
#if UNITY_EDITOR
|
|
@@ -354,20 +368,4 @@ namespace jeanf.questsystem
|
|
|
354
368
|
}
|
|
355
369
|
#endregion
|
|
356
370
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
#if UNITY_EDITOR
|
|
360
|
-
[CustomEditor(typeof(QuestItem))]
|
|
361
|
-
public class BoolEventOnClickEditor : Editor {
|
|
362
|
-
override public void OnInspectorGUI () {
|
|
363
|
-
DrawDefaultInspector();
|
|
364
|
-
GUILayout.Space(10);
|
|
365
|
-
var eventToSend = (QuestItem) target;
|
|
366
|
-
if(GUILayout.Button("Log active steps", GUILayout.Height(30))) {
|
|
367
|
-
eventToSend.LogActiveSteps(); // how do i call this?
|
|
368
|
-
}
|
|
369
|
-
GUILayout.Space(10);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
#endif
|
|
373
371
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
using System;
|
|
1
2
|
using jeanf.EventSystem;
|
|
2
3
|
using jeanf.propertyDrawer;
|
|
3
4
|
using UnityEngine;
|
|
@@ -5,6 +6,7 @@ using UnityEngine.Playables;
|
|
|
5
6
|
using System.Collections.Generic;
|
|
6
7
|
using GraphProcessor;
|
|
7
8
|
using jeanf.validationTools;
|
|
9
|
+
using UnityEditor;
|
|
8
10
|
|
|
9
11
|
namespace jeanf.questsystem
|
|
10
12
|
{
|
|
@@ -45,13 +47,28 @@ namespace jeanf.questsystem
|
|
|
45
47
|
|
|
46
48
|
[Header("Event Channels")]
|
|
47
49
|
[SerializeField] private StringEventChannelSO sendQuestStepTooltip;
|
|
50
|
+
[SerializeField] private StringEventChannelSO stepValidationOverride;
|
|
51
|
+
|
|
52
|
+
public void OnEnable()
|
|
53
|
+
{
|
|
54
|
+
Subscribe();
|
|
55
|
+
InitializeQuestStep();
|
|
56
|
+
}
|
|
48
57
|
|
|
58
|
+
public void OnDisable() => Unsubscribe();
|
|
49
59
|
|
|
60
|
+
public void OnDestroy() => Unsubscribe();
|
|
50
61
|
|
|
62
|
+
private void Subscribe()
|
|
63
|
+
{
|
|
64
|
+
QuestItem.ValidateStepEvent += ValidateCurrentStep;
|
|
65
|
+
if(stepValidationOverride) stepValidationOverride.OnEventRaised += ValidateCurrentStep;
|
|
66
|
+
}
|
|
51
67
|
|
|
52
|
-
|
|
68
|
+
private void Unsubscribe()
|
|
53
69
|
{
|
|
54
|
-
|
|
70
|
+
QuestItem.ValidateStepEvent -= ValidateCurrentStep;
|
|
71
|
+
if(stepValidationOverride) stepValidationOverride.OnEventRaised -= ValidateCurrentStep;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
|
|
@@ -84,9 +101,14 @@ namespace jeanf.questsystem
|
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
103
|
|
|
104
|
+
public void ValidateCurrentStep(string stepId)
|
|
105
|
+
{
|
|
106
|
+
if(stepId != this.stepId)return;
|
|
107
|
+
FinishQuestStep();
|
|
108
|
+
}
|
|
87
109
|
|
|
88
110
|
|
|
89
|
-
|
|
111
|
+
public void FinishQuestStep()
|
|
90
112
|
{
|
|
91
113
|
if(isDebug) Debug.Log($" ---- Step with id: {stepId} finished. Changing status to completed", this);
|
|
92
114
|
stepStatus = QuestStepStatus.Completed;
|