fr.jeanf.questsystem 0.0.65 → 0.0.67

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,6 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 7b22fa752a8ac804aa1053eac644fb47
3
- folderAsset: yes
2
+ guid: bd20a8962b0dd7047b383ce038428904
4
3
  DefaultImporter:
5
4
  externalObjects: {}
6
5
  userData:
package/README.md CHANGED
@@ -19,4 +19,8 @@ Credits:
19
19
  - I simply implemented this code in my package registry and tweaked it to my liking. Overtime I will add quite a lot of functionalities but for now I focus on making it work with my custom Event System.
20
20
 
21
21
  Contributors:
22
- [Code] Felix Cotes-Charlebois <a href="https://github.com/Percevent13">
22
+ [Code] Felix Cotes-Charlebois <a href="https://github.com/Percevent13">
23
+
24
+ LICENCE:
25
+
26
+ <img src="https://licensebuttons.net/l/by-nc-sa/3.0/88x31.png"></img>
@@ -1,7 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
3
  using System.Collections.Generic;
4
- using GraphProcessor;
5
4
  using jeanf.EventSystem;
6
5
  using jeanf.propertyDrawer;
7
6
  using UnityEngine;
@@ -1,6 +1,5 @@
1
1
  using System.Collections;
2
2
  using System.Collections.Generic;
3
- using GraphProcessor;
4
3
  using UnityEngine;
5
4
 
6
5
  namespace jeanf.questsystem
@@ -20,16 +19,5 @@ namespace jeanf.questsystem
20
19
  this.questStepIndex = questStepIndex;
21
20
  this.questStepStates = questStepStates;
22
21
  }
23
-
24
-
25
- // new constructor (tree structure)
26
- public BaseGraph QuestTree;
27
- public Dictionary<string, QuestStep> QuestStepDictionary;
28
-
29
- public QuestData(BaseGraph QuestTree, Dictionary<string, QuestStep> QuestStepDictionary)
30
- {
31
- this.QuestTree = QuestTree;
32
- this.QuestStepDictionary = QuestStepDictionary;
33
- }
34
22
  }
35
23
  }
@@ -25,21 +25,26 @@ namespace jeanf.questsystem
25
25
  #endregion
26
26
 
27
27
  #region Step Dictionaries
28
- [Tooltip("Visual feedback for the quest state")] [Header("Quest")]
29
- [SerializeField] [Validation("A reference to a questSO is required")] private QuestSO questSO;
28
+ [Tooltip("Visual feedback for the quest state")]
29
+ [Header("Quest")]
30
+ [SerializeField][Validation("A reference to a questSO is required")] private QuestSO questSO;
30
31
  private Dictionary<string, QuestStep> stepMap = new Dictionary<string, QuestStep>();
31
32
  private Dictionary<string, QuestStep> activeSteps = new Dictionary<string, QuestStep>();
32
33
  private Dictionary<string, QuestStep> completedSteps = new Dictionary<string, QuestStep>();
34
+ private Dictionary<string, QuestStep> stepsInScene = new Dictionary<string, QuestStep>();
33
35
  private List<QuestStep> rootSteps = new List<QuestStep>();
34
36
  #endregion
35
37
 
36
38
 
37
39
  #region main data
38
- [SerializeField] [ReadOnly]
40
+ [SerializeField]
41
+ [ReadOnly]
39
42
  private bool clearToStart = false;
40
43
  private string questId;
41
44
  private QuestState currentQuestState;
42
- [ReadOnly][Range(0, 1)][SerializeField]
45
+ [ReadOnly]
46
+ [Range(0, 1)]
47
+ [SerializeField]
43
48
  private float progress = 0.0f;
44
49
  #endregion
45
50
 
@@ -48,15 +53,19 @@ namespace jeanf.questsystem
48
53
  public static ValidateStep ValidateStepEvent;
49
54
  // these events are Located in Assets/Resources/Quests/Channels - it is searched for at Awake time.
50
55
  // if they do not exist simply right click in the hierarchy and find >InitializeQuestSystem<
51
- [Header("Listening on:")]
52
- [SerializeField] [Validation("A reference to the QuestProgress SO is required")] private StringFloatEventChannelSO QuestProgress;
53
- [SerializeField] [Validation("A reference to the QuestInitialCheck SO is required")] private StringEventChannelSO QuestInitialCheck;
56
+ [Header("Listening on:")]
57
+ [SerializeField][Validation("A reference to the QuestProgress SO is required")] private StringFloatEventChannelSO QuestProgress;
58
+ [SerializeField][Validation("A reference to the QuestInitialCheck SO is required")] private StringEventChannelSO QuestInitialCheck;
54
59
  [SerializeField] private VoidEventChannelSO resetChannel;
55
60
 
56
- [Header("Broadcasting on:")] [SerializeField] [Validation("A reference to the QuestRequirementCheck SO is required")]
61
+ [Header("Broadcasting on:")]
62
+ [SerializeField]
63
+ [Validation("A reference to the QuestRequirementCheck SO is required")]
57
64
  private StringEventChannelSO requirementCheck;
58
- [SerializeField][Validation("A reference to the LoadRequiredScenesEventChannel SO is required")] StringListEventChannelSO loadRequiredScenesEventChannel;
65
+ [SerializeField][Validation("A reference to the LoadRequiredScenesEventChannel SO is required")] StringListEventChannelSO loadRequiredScenesEventChannel;
59
66
  [SerializeField] IntEventChannelSO unlockDoorsEventChannel;
67
+ [SerializeField] StringEventChannelSO startStepChannel;
68
+ [SerializeField] StringEventChannelSO endStepChannel;
60
69
  #endregion
61
70
 
62
71
 
@@ -66,7 +75,7 @@ namespace jeanf.questsystem
66
75
  questId = questSO.id;
67
76
  for (int i = 0; i < questSO.rootSteps.Length; i++)
68
77
  {
69
- if(isDebug) Debug.Log($"id on awake {questSO.rootSteps[i].StepId}, added to {this.name}'s dictionary", this);
78
+ if (isDebug) Debug.Log($"id on awake {questSO.rootSteps[i].StepId}, added to {this.name}'s dictionary", this);
70
79
  AddStepToStepMap(questSO.rootSteps[i]);
71
80
  rootSteps.Add(questSO.rootSteps[i]);
72
81
  }
@@ -93,6 +102,8 @@ namespace jeanf.questsystem
93
102
  QuestStep.sendNextStepId += InstantiateQuestStep;
94
103
  QuestStep.stepActive += UpdateStepStatus;
95
104
  QuestStep.childStep += AddStepToStepMap;
105
+ if (startStepChannel != null) startStepChannel.OnEventRaised += InstantiateQuestStep;
106
+ if (endStepChannel != null) endStepChannel.OnEventRaised += UnloadQuestStep;
96
107
  }
97
108
  private void Unsubscribe()
98
109
  {
@@ -104,7 +115,8 @@ namespace jeanf.questsystem
104
115
  QuestStep.sendNextStepId -= InstantiateQuestStep;
105
116
  QuestStep.stepActive -= UpdateStepStatus;
106
117
  QuestStep.childStep -= AddStepToStepMap;
107
-
118
+ if (startStepChannel != null) startStepChannel.OnEventRaised -= InstantiateQuestStep;
119
+ if (endStepChannel != null) endStepChannel.OnEventRaised -= UnloadQuestStep;
108
120
 
109
121
  }
110
122
  #endregion
@@ -116,9 +128,21 @@ namespace jeanf.questsystem
116
128
  if (stepMap[id].stepStatus != QuestStepStatus.Inactive) return;
117
129
  if (activeSteps.ContainsKey(id)) return;
118
130
 
131
+
132
+ QuestStep instantiatedStep = Instantiate(stepMap[id], this.transform, true);
133
+ stepsInScene.Add(id, instantiatedStep);
134
+ }
119
135
 
120
- Instantiate(stepMap[id], this.transform, true);
136
+ public void UnloadQuestStep(string id)
137
+ {
138
+ if (!stepMap.ContainsKey(id)) return;
139
+ if (stepMap[id].stepStatus != QuestStepStatus.Inactive) return;
140
+ if (!activeSteps.ContainsKey(id)) return;
121
141
 
142
+ activeSteps.Remove(id);
143
+ stepMap[id].stepStatus = QuestStepStatus.Inactive;
144
+ Destroy(stepsInScene[id].gameObject);
145
+ stepsInScene.Remove(id);
122
146
  }
123
147
  private void LoadDependencies()
124
148
  {
@@ -161,7 +185,7 @@ namespace jeanf.questsystem
161
185
  completedSteps.Clear();
162
186
  completedSteps.TrimExcess();
163
187
 
164
- if(isDebug) Debug.Log($"Quest [{id}]: _startQuestOnEnable value is: [{_startQuestOnEnable}]");
188
+ if (isDebug) Debug.Log($"Quest [{id}]: _startQuestOnEnable value is: [{_startQuestOnEnable}]");
165
189
  if (!_startQuestOnEnable || id != questId) return;
166
190
  clearToStart = true;
167
191
  currentQuestState = QuestState.CAN_START;
@@ -204,21 +228,21 @@ namespace jeanf.questsystem
204
228
  switch (currentQuestState)
205
229
  {
206
230
  case QuestState.CAN_START:
207
- {
208
- if (isDebug) Debug.Log($"Starting quest: {questId}");
209
- GameEventsManager.instance.questEvents.StartQuest(questId);
210
- break;
211
- }
231
+ {
232
+ if (isDebug) Debug.Log($"Starting quest: {questId}");
233
+ GameEventsManager.instance.questEvents.StartQuest(questId);
234
+ break;
235
+ }
212
236
  case QuestState.CAN_FINISH:
213
- {
214
- if (isDebug) Debug.Log($"Finishing quest: {questId}");
215
- GameEventsManager.instance.questEvents.FinishQuest(questId);
216
- break;
217
- }
237
+ {
238
+ if (isDebug) Debug.Log($"Finishing quest: {questId}");
239
+ GameEventsManager.instance.questEvents.FinishQuest(questId);
240
+ break;
241
+ }
218
242
  case QuestState.REQUIREMENTS_NOT_MET:
219
- if(_startQuestOnEnable)
243
+ if (_startQuestOnEnable)
220
244
  {
221
- if(isDebug) Debug.Log($"forcing start of quest: {questId}");
245
+ if (isDebug) Debug.Log($"forcing start of quest: {questId}");
222
246
  GameEventsManager.instance.questEvents.StartQuest(questId);
223
247
  }
224
248
  break;
@@ -256,7 +280,7 @@ namespace jeanf.questsystem
256
280
  {
257
281
  var activeStep = activeSteps.ElementAt(i);
258
282
  var stepKey = activeStep.Key;
259
- if(activeSteps.ContainsKey(stepKey)) ValidateStepEvent.Invoke(stepKey);
283
+ if (activeSteps.ContainsKey(stepKey)) ValidateStepEvent.Invoke(stepKey);
260
284
  }
261
285
  }
262
286
  #endregion
@@ -276,7 +300,7 @@ namespace jeanf.questsystem
276
300
  Debug.Log($"active step: {step}");
277
301
  }
278
302
  }
279
- #endif
303
+ #endif
280
304
  private void ValidityCheck()
281
305
  {
282
306
  const string searching = "attempting to find";
@@ -302,7 +326,7 @@ namespace jeanf.questsystem
302
326
  }
303
327
 
304
328
  }
305
-
329
+
306
330
  if (questSO == null)
307
331
  {
308
332
  if (isDebug) Debug.Log($"There is no questSO in the questItem");
@@ -1,7 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
3
  using System.Collections.Generic;
4
- using GraphProcessor;
5
4
  using jeanf.EventSystem;
6
5
  using jeanf.validationTools;
7
6
  using UnityEngine;
@@ -1,5 +1,4 @@
1
1
  using System;
2
- using GraphProcessor;
3
2
  using jeanf.EventSystem;
4
3
  using UnityEngine;
5
4
  using jeanf.propertyDrawer;
@@ -4,13 +4,12 @@ using jeanf.propertyDrawer;
4
4
  using UnityEngine;
5
5
  using UnityEngine.Playables;
6
6
  using System.Collections.Generic;
7
- using GraphProcessor;
8
7
  using jeanf.validationTools;
9
8
  using UnityEditor;
10
9
 
11
10
  namespace jeanf.questsystem
12
11
  {
13
- [System.Serializable, NodeMenuItem("questSystem/QuestStep"), DefaultExecutionOrder(1)]
12
+ [System.Serializable, DefaultExecutionOrder(1)]
14
13
  public class QuestStep : MonoBehaviour, IDebugBehaviour
15
14
  {
16
15
  #region Ids and status
@@ -117,6 +116,10 @@ namespace jeanf.questsystem
117
116
  FinishQuestStep();
118
117
  }
119
118
 
119
+ public void AbortStep()
120
+ {
121
+ Destroy(this.gameObject);
122
+ }
120
123
  public void FinishQuestStep()
121
124
  {
122
125
  if(isDebug) Debug.Log($" ---- Step with id: {stepId} finished. Changing status to completed", this);
@@ -5,11 +5,7 @@
5
5
  "GUID:75469ad4d38634e559750d17036d5f7c",
6
6
  "GUID:e134609276952144282613c65d798616",
7
7
  "GUID:e8958e6939af7314a97769de4be4ce25",
8
- "GUID:db1b0a3157155ad47996061dbcc07bbb",
9
- "GUID:ca937d03ee5dd4d699091438dc0f3ae6",
10
- "GUID:a432eb0a70c5c4a37ab50d59671586f8",
11
- "GUID:b8e24fd1eb19b4226afebb2810e3c19b",
12
- "GUID:002c1bbed08fa44d282ef34fd5edb138"
8
+ "GUID:db1b0a3157155ad47996061dbcc07bbb"
13
9
  ],
14
10
  "includePlatforms": [],
15
11
  "excludePlatforms": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fr.jeanf.questsystem",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
4
4
  "displayName": "Quest system",
5
5
  "description": "This package uses Scriptable Objects to define quests.",
6
6
  "unity": "2021.3",
@@ -1,30 +0,0 @@
1
- #if UNITY_EDITOR
2
- using UnityEngine;
3
- using UnityEditor;
4
- using GraphProcessor;
5
-
6
- public class QuestGraphWindow : BaseGraphWindow
7
- {
8
- [MenuItem("QuestGraph/01_DefaultGraph")]
9
- public static BaseGraphWindow Open()
10
- {
11
- var graphWindow = GetWindow<QuestGraphWindow>();
12
-
13
- graphWindow.Show();
14
-
15
- return graphWindow;
16
- }
17
-
18
- protected override void InitializeWindow(BaseGraph graph)
19
- {
20
- // Set the window title
21
- titleContent = new GUIContent("Default Graph");
22
-
23
- // Here you can use the default BaseGraphView or a custom one (see section below)
24
- var graphView = new BaseGraphView(this);
25
-
26
- rootView.Add(graphView);
27
- }
28
-
29
- }
30
- #endif
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 4783b98f3c3c6da49b8d8a1dc5b2bd52
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
@@ -1,11 +0,0 @@
1
- using UnityEngine;
2
- using GraphProcessor;
3
- using jeanf.questsystem;
4
-
5
- public class QuestStepNode : BaseNode
6
- {
7
- [Input(name = "A")]
8
- private QuestStep StepsRequiredForCompletion;
9
- [Output(name = "Out")]
10
- private QuestStep StepsTriggeredOnCompletion;
11
- }
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: feb5db492d0ac36459e73370531d6f8c
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant: