net.dreditor.twopointfived 0.0.0-stage → 0.1.6

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.
Files changed (38) hide show
  1. package/CameraArrow.cs +128 -0
  2. package/CameraArrow.cs.meta +17 -0
  3. package/CameraArrowManager.cs +244 -0
  4. package/CameraArrowManager.cs.meta +11 -0
  5. package/CameraArrowVisibility.cs +119 -0
  6. package/CameraArrowVisibility.cs.meta +2 -0
  7. package/DREditor.TwoPointFiveD.asmdef +18 -0
  8. package/DREditor.TwoPointFiveD.asmdef.meta +7 -0
  9. package/DialogueEventOnDestroy.cs +38 -0
  10. package/DialogueEventOnDestroy.cs.meta +11 -0
  11. package/ITPFDListener.cs +21 -0
  12. package/ITPFDListener.cs.meta +11 -0
  13. package/PrepareTPFDCameras.cs +72 -0
  14. package/PrepareTPFDCameras.cs.meta +11 -0
  15. package/Samples/Arrow_Canvas_Template.prefab +939 -0
  16. package/Samples/Arrow_Canvas_Template.prefab.meta +7 -0
  17. package/Samples/Camera_Arrow.prefab +218 -0
  18. package/Samples/Camera_Arrow.prefab.meta +7 -0
  19. package/Samples/PrepareTPFD.asset +14 -0
  20. package/Samples/PrepareTPFD.asset.meta +8 -0
  21. package/Samples/Prepare_TPFD_Cameras.prefab +137 -0
  22. package/Samples/Prepare_TPFD_Cameras.prefab.meta +7 -0
  23. package/Samples/Prepare_TPFD_Listener.prefab +51 -0
  24. package/Samples/Prepare_TPFD_Listener.prefab.meta +7 -0
  25. package/Samples/TPFD_Manager.prefab +63 -0
  26. package/Samples/TPFD_Manager.prefab.meta +7 -0
  27. package/Samples/TPFD_Move_In_Dialogue_Handler.prefab +56 -0
  28. package/Samples/TPFD_Move_In_Dialogue_Handler.prefab.meta +7 -0
  29. package/Samples.meta +8 -0
  30. package/TPFDManager.cs +150 -0
  31. package/TPFDManager.cs.meta +11 -0
  32. package/TPFDManagerBase.cs +187 -0
  33. package/TPFDManagerBase.cs.meta +11 -0
  34. package/TPFDMoveInDialogueHandler.cs +186 -0
  35. package/TPFDMoveInDialogueHandler.cs.meta +11 -0
  36. package/package.json +36 -6
  37. package/package.json.meta +7 -0
  38. package/README.md +0 -3
package/CameraArrow.cs ADDED
@@ -0,0 +1,128 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if DOTWEEN
3
+ using DG.Tweening;
4
+ #endif
5
+ using DREditor.EventObjects;
6
+ using DREditor.UIHandling;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.TwoPointFiveD
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(ITPFDListener) +
15
+ "\n\n")]
16
+ public class CameraArrow : MonoBehaviour, ITPFDListener
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ enum Direction
22
+ {
23
+ Up, Down, Left, Right
24
+ }
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected BoolWithEvent inTPFD = null;
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Tooltip("")]
36
+ [SerializeField] protected UIVisibilityComponent arrow = null;
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ [Tooltip("")]
42
+ [SerializeField] protected UIVisibilityComponent cancel = null;
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ [Tooltip("")]
48
+ [SerializeField] private Direction direction;
49
+
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected bool inCancel = false;
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ protected bool canChange = false;
60
+
61
+ /// <summary>
62
+ ///
63
+ /// </summary>
64
+ protected UIVisibilityComponent current;
65
+
66
+
67
+ protected virtual void Start()
68
+ {
69
+ current = arrow;
70
+
71
+ current.Show();
72
+ }
73
+
74
+
75
+ /// <inheritdoc/>
76
+ public virtual void OnEnteredBoundary(int directionIndex)
77
+ {
78
+ if (!inCancel && directionIndex == (int)direction)
79
+ {
80
+ inCancel = true;
81
+
82
+ if (!inTPFD.Value)
83
+ SetCanChange(false);
84
+ else
85
+ ChangeArrowVisual(cancel, arrow);
86
+ }
87
+ }
88
+
89
+ /// <inheritdoc/>
90
+ public virtual void OnExitedBoundary(int directionIndex)
91
+ {
92
+ if (inCancel && directionIndex == (int)direction)
93
+ {
94
+ inCancel = false;
95
+
96
+ if (!inTPFD.Value)
97
+ SetCanChange(false);
98
+ else
99
+ ChangeArrowVisual(arrow, cancel);
100
+ }
101
+ }
102
+
103
+ /// <summary>
104
+ ///
105
+ /// </summary>
106
+ /// <param name="to"></param>
107
+ /// <param name="from"></param>
108
+ protected virtual void ChangeArrowVisual(UIVisibilityComponent to, UIVisibilityComponent from)
109
+ {
110
+ if (!canChange)
111
+ return;
112
+ #if DOTWEEN
113
+ to.DOKill();
114
+ from.DOKill();
115
+ #endif
116
+ to.Show();
117
+ from.Hide();
118
+
119
+ current = to;
120
+ }
121
+
122
+ /// <summary>
123
+ ///
124
+ /// </summary>
125
+ /// <param name="canChange"></param>
126
+ public virtual void SetCanChange(bool canChange) => this.canChange = canChange;
127
+ }
128
+ }
@@ -0,0 +1,17 @@
1
+ fileFormatVersion: 2
2
+ guid: 8ec8900f2a5e2374b9c482048a5ee1ac
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences:
7
+ - arrow: {instanceID: 0}
8
+ - cancel: {instanceID: 0}
9
+ - inDialogue: {fileID: 11400000, guid: b2839fc222ba4bc4eb8bcfee73b0c53d, type: 2}
10
+ - inLeaveProcess: {fileID: 11400000, guid: 787d287b8159b5049bbd73ee10c03b1b, type: 2}
11
+ - inTPFD: {fileID: 11400000, guid: 7f90df5202cae904292188e37c9076d3, type: 2}
12
+ - isLoadingFile: {fileID: 11400000, guid: 1d94fdc8796dc9f43b2a3bedb0f5d4dd, type: 2}
13
+ executionOrder: 0
14
+ icon: {instanceID: 0}
15
+ userData:
16
+ assetBundleName:
17
+ assetBundleVariant:
@@ -0,0 +1,244 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using DREditor.Dialogues.Finishing;
4
+ using DREditor.Dialogues.Starting;
5
+ using DREditor.EventObjects;
6
+ using DREditor.UIHandling;
7
+ using System;
8
+ using System.Collections;
9
+ using System.Collections.Generic;
10
+ using System.Linq;
11
+ using UnityEngine;
12
+
13
+ namespace DREditor.TwoPointFiveD
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ /// <remarks></remarks>
19
+ [ClassHeader(nameof(UIVisibilityHandler) +
20
+ "\n\n")]
21
+ public class CameraArrowManager : UIVisibilityHandler
22
+ {
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Header("")]
27
+ [Divider]
28
+ [Tooltip("")]
29
+ [SerializeField] protected BoolWithEvent inTPFD = null;
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ [Tooltip("")]
35
+ [SerializeField] protected BoolWithEvent inDialogue = null;
36
+
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ [Header("")]
42
+ [Divider]
43
+ [Tooltip("")]
44
+ [SerializeField] protected List<SceneEventListener> showListeners = new();
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ [Tooltip("")]
50
+ [SerializeField] protected List<SceneEventListener> hideListeners = new();
51
+
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ [Header("")]
57
+ [Divider]
58
+ [Tooltip("")]
59
+ [SerializeField] protected List<string> showEvents = new() { "SubAreaOnDidntLeave" };
60
+
61
+ /// <summary>
62
+ ///
63
+ /// </summary>
64
+ [Tooltip("")]
65
+ [SerializeField] protected List<string> hideEvents = new() { "OnLeaveAsk" };
66
+
67
+
68
+ /// <summary>
69
+ ///
70
+ /// </summary>
71
+ protected bool listening = false;
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ protected bool dialogueIsEnding = false;
77
+
78
+ /// <summary>
79
+ ///
80
+ /// </summary>
81
+ protected IEnumerable<IDialoguePrepareEvent> dialoguePrepareEvents;
82
+
83
+ /// <summary>
84
+ ///
85
+ /// </summary>
86
+ protected IEnumerable<IEndDialogueEvent> dialogueEndEvents;
87
+
88
+
89
+
90
+ /// <summary>
91
+ ///
92
+ /// </summary>
93
+ protected override void Awake()
94
+ {
95
+ base.Awake();
96
+
97
+ dialoguePrepareEvents = FindObjectsByType<MonoBehaviour>().OfType<IDialoguePrepareEvent>();
98
+
99
+ dialogueEndEvents = FindObjectsByType<MonoBehaviour>().OfType<IEndDialogueEvent>();
100
+
101
+ OnTPFDModeChanged(inTPFD.Value);
102
+ }
103
+
104
+ /// <summary>
105
+ ///
106
+ /// </summary>
107
+ /// <param name="inTPFD"></param>
108
+ protected virtual void OnTPFDModeChanged(bool inTPFD)
109
+ {
110
+ if (inTPFD && listening)
111
+ return;
112
+
113
+ if (inTPFD)
114
+ StartListeningToEvents();
115
+ else
116
+ StopListeningToEvents();
117
+
118
+ listening = inTPFD;
119
+ }
120
+
121
+ /// <summary>
122
+ ///
123
+ /// </summary>
124
+ protected virtual void StartListeningToEvents()
125
+ {
126
+ if (dialogueIsEnding || !inDialogue.Value)
127
+ visibleUI.Show();
128
+
129
+ foreach (var sceneEvent in showListeners)
130
+ sceneEvent.AddListener(visibleUI.Show);
131
+
132
+ foreach (var sceneEvent in hideListeners)
133
+ sceneEvent.AddListener(visibleUI.Hide);
134
+
135
+ DialogueEventSystem.StartListening(showEvents, ShowEvent);
136
+
137
+ DialogueEventSystem.StartListening(hideEvents, HideEvent);
138
+
139
+ SubscribeToDialogueEnding(true, visibleUI.Show);
140
+
141
+ foreach (var preparable in dialoguePrepareEvents)
142
+ preparable.OnDialoguePrepare += visibleUI.Hide;
143
+ }
144
+
145
+ /// <summary>
146
+ ///
147
+ /// </summary>
148
+ protected virtual void StopListeningToEvents()
149
+ {
150
+ if (gameObject.activeSelf)
151
+ visibleUI.Hide();
152
+
153
+ foreach (var sceneEvent in showListeners)
154
+ sceneEvent.RemoveListener(visibleUI.Show);
155
+
156
+ foreach (var sceneEvent in hideListeners)
157
+ sceneEvent.RemoveListener(visibleUI.Hide);
158
+
159
+ DialogueEventSystem.StopListening(showEvents, ShowEvent);
160
+
161
+ DialogueEventSystem.StopListening(hideEvents, HideEvent);
162
+
163
+ SubscribeToDialogueEnding(false, visibleUI.Show);
164
+
165
+ foreach (var preparable in dialoguePrepareEvents)
166
+ preparable.OnDialoguePrepare -= visibleUI.Hide;
167
+ }
168
+
169
+ /// <summary>
170
+ ///
171
+ /// </summary>
172
+ /// <param name="o"></param>
173
+ protected virtual void ShowEvent(object o = null) => visibleUI.Show();
174
+
175
+ /// <summary>
176
+ ///
177
+ /// </summary>
178
+ /// <param name="o"></param>
179
+ protected virtual void HideEvent(object o = null) => visibleUI.Hide();
180
+
181
+
182
+ /// <summary>
183
+ ///
184
+ /// </summary>
185
+ protected virtual void OnEnable()
186
+ {
187
+ inTPFD.AddListener(OnTPFDModeChanged);
188
+
189
+ SubscribeToDialogueEnding(true, NoticedDialogueEnding);
190
+ }
191
+
192
+ /// <summary>
193
+ ///
194
+ /// </summary>
195
+ protected virtual void OnDisable()
196
+ {
197
+ inTPFD.RemoveListener(OnTPFDModeChanged);
198
+
199
+ SubscribeToDialogueEnding(false, NoticedDialogueEnding);
200
+ }
201
+
202
+ /// <summary>
203
+ ///
204
+ /// </summary>
205
+ /// <param name="subscribe"></param>
206
+ /// <param name="response"></param>
207
+ protected virtual void SubscribeToDialogueEnding(bool subscribe, Action response)
208
+ {
209
+ foreach (var endable in dialogueEndEvents)
210
+ if (subscribe)
211
+ endable.OnDialogueEnd += response;
212
+ else
213
+ endable.OnDialogueEnd -= response;
214
+ }
215
+
216
+ /// <summary>
217
+ ///
218
+ /// </summary>
219
+ protected virtual void NoticedDialogueEnding()
220
+ {
221
+ if (inDialogue.Value)
222
+ {
223
+ dialogueIsEnding = true;
224
+
225
+ StartCoroutine(WaitForDialogueOff());
226
+ }
227
+ }
228
+
229
+ /// <summary>
230
+ ///
231
+ /// </summary>
232
+ protected virtual IEnumerator WaitForDialogueOff()
233
+ {
234
+ yield return new WaitUntil(() => !inDialogue.Value);
235
+
236
+ SubscribeToDialogueEnding(false, NoticedDialogueEnding);
237
+
238
+ dialogueIsEnding = false;
239
+ }
240
+
241
+
242
+ protected virtual void OnDestroy() => StopListeningToEvents();
243
+ }
244
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b78b464ad02c179439e34f374cc387b5
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,119 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+ using DREditor.UIHandling;
4
+ using System.Collections;
5
+ using System.Collections.Generic;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.TwoPointFiveD
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [ClassHeader(nameof(UIVisibilityComponent) + ", " + nameof(IUIVisibility) +
14
+ "\n\n")]
15
+ public class CameraArrowVisibility : UIVisibilityComponent
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected BoolWithEvent inLeaveProcess = null;
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Tooltip("")]
33
+ [SerializeField] protected UIVisibilityComponent allArrowVisibility = null;
34
+
35
+ /// <summary>
36
+ ///
37
+ /// </summary>
38
+ [Tooltip("")]
39
+ [SerializeField] protected List<CameraArrow> arrows = new();
40
+
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ protected bool canChange = false;
46
+
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ protected override void ShowUI() => StartCoroutine(Appear());
52
+
53
+ /// <summary>
54
+ ///
55
+ /// </summary>
56
+ /// <remarks>
57
+ ///
58
+ /// </remarks>
59
+ protected virtual IEnumerator Appear()
60
+ {
61
+ if (isLoadingFile.Value)
62
+ yield break;
63
+
64
+ if (inLeaveProcess.Value)
65
+ {
66
+ UpdateArrowStates();
67
+
68
+ yield break;
69
+ }
70
+
71
+ canChange = true;
72
+
73
+ allArrowVisibility.Show();
74
+
75
+ yield return allArrowVisibility.WaitForChangeToComplete();
76
+
77
+ UpdateArrowStates();
78
+ }
79
+
80
+
81
+ /// <summary>
82
+ ///
83
+ /// </summary>
84
+ protected override void HideUI() => StartCoroutine(Disappear());
85
+
86
+ /// <summary>
87
+ ///
88
+ /// </summary>
89
+ /// <returns></returns>
90
+ protected virtual IEnumerator Disappear()
91
+ {
92
+ StopCoroutine(Appear());
93
+
94
+ canChange = false;
95
+
96
+ allArrowVisibility.Hide();
97
+
98
+ yield return allArrowVisibility.WaitForChangeToComplete();
99
+
100
+ UpdateArrowStates();
101
+ }
102
+
103
+ /// <summary>
104
+ ///
105
+ /// </summary>
106
+ protected virtual void UpdateArrowStates()
107
+ {
108
+ foreach (CameraArrow arrow in arrows)
109
+ arrow.SetCanChange(canChange);
110
+ }
111
+
112
+
113
+ /// <inheritdoc/>
114
+ protected override IEnumerator WaitForUIToComplete()
115
+ {
116
+ yield return allArrowVisibility.WaitForChangeToComplete();
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 31e31801b5b1a5c4a8d55d6a8efcfe15
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "DREditor.TwoPointFiveD",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "DREditor",
6
+ "DREditor.UIHandling",
7
+ "DREditor.DialogueEventHandling"
8
+ ],
9
+ "includePlatforms": [],
10
+ "excludePlatforms": [],
11
+ "allowUnsafeCode": false,
12
+ "overrideReferences": false,
13
+ "precompiledReferences": [],
14
+ "autoReferenced": true,
15
+ "defineConstraints": [],
16
+ "versionDefines": [],
17
+ "noEngineReferences": false
18
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 991d12d32bf3fe7419036bb62965408b
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,38 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Dialogues.Events;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.TwoPointFiveD
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ /// <remarks></remarks>
12
+ [ClassHeader("")]
13
+ public class DialogueEventOnDestroy : MonoBehaviour
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ [Tooltip("")]
19
+ [SerializeField] protected List<string> dialogueOnDestroyEvents = new() { "ResetProtagCamera" };
20
+
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ protected virtual void OnDestroy()
26
+ {
27
+ foreach (string dialogueEvent in dialogueOnDestroyEvents)
28
+ DialogueEventSystem.TriggerEvent(dialogueEvent);
29
+ }
30
+
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [ContextMenu("Populate Default Protag Event")]
36
+ public virtual void DebugPopulateDefaultProtagEvent() => dialogueOnDestroyEvents.Add("ResetProtagCamera");
37
+ }
38
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: edf9da330f7e117418a11da765d6c47b
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,21 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ namespace DREditor.TwoPointFiveD
3
+ {
4
+ /// <summary>
5
+ ///
6
+ /// </summary>
7
+ public interface ITPFDListener
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ /// <param name="directionIndex"></param>
13
+ void OnEnteredBoundary(int directionIndex);
14
+
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ /// <param name="directionIndex"></param>
19
+ void OnExitedBoundary(int directionIndex);
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: db70bc4a8901ba14890a370635f750a0
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: