net.dreditor.talkables 0.1.6 → 0.1.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,171 +1,171 @@
1
- //Completely Reworked Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- //Original Author: Redberd36
3
- //Sorry Red I ended up completely reworking this.
4
- using DREditor.Dialogues;
5
- using DREditor.EventObjects;
6
- using DREditor.Services;
7
- using UnityEngine;
8
-
9
- namespace DREditor.Talkables
10
- {
11
- /// <summary>
12
- ///
13
- /// </summary>
14
- [ClassHeader("")]
15
- public class SpriteLookAtTarget : MonoBehaviour
16
- {
17
- /// <summary>
18
- ///
19
- /// </summary>
20
- [Tooltip("")]
21
- [SerializeField] protected BoolWithEvent inDialogue = null;
22
-
23
- /// <summary>
24
- ///
25
- /// </summary>
26
- [Tooltip("")]
27
- [SerializeField] protected BoolWithEvent isLoadingFile = null;
28
-
29
- /// <summary>
30
- ///
31
- /// </summary>
32
- [Tooltip("")]
33
- [SerializeField] protected BoolWithEvent inTPFD = null;
34
-
35
- /// <summary>
36
- ///
37
- /// </summary>
38
- [Tooltip("")]
39
- [SerializeField] protected BoolWithEvent inThreeDMode = null;
40
-
41
-
42
- /// <summary>
43
- ///
44
- /// </summary>
45
- [Header("")]
46
- [Divider]
47
- [Tooltip("")]
48
- [SerializeField] protected bool mimicOG = false;
49
-
50
- /// <summary>
51
- ///
52
- /// </summary>
53
- [Tooltip("")]
54
- [SerializeField] protected bool ignoreReaderCheck = false;
55
-
56
- /// <summary>
57
- ///
58
- /// </summary>
59
- [Tooltip("")]
60
- [SerializeField] protected string mainCameraTag = "MainCamera";
61
-
62
-
63
- /// <summary>
64
- ///
65
- /// </summary>
66
- protected bool shouldLookAtTarget;
67
-
68
- /// <summary>
69
- ///
70
- /// </summary>
71
- protected Transform target;
72
-
73
- /// <summary>
74
- ///
75
- /// </summary>
76
- protected IDialogueManager dialogueManager;
77
-
78
-
79
- /// <summary>
80
- ///
81
- /// </summary>
82
- protected virtual void OnEnable() => inTPFD.AddListener(UpdateLookingStatus);
83
-
84
- /// <summary>
85
- ///
86
- /// </summary>
87
- protected virtual void OnDisable() => inTPFD.RemoveListener(UpdateLookingStatus);
88
-
89
- /// <summary>
90
- ///
91
- /// </summary>
92
- /// <param name="inTPFD"></param>
93
- protected virtual void UpdateLookingStatus(bool inTPFD) => shouldLookAtTarget = !inTPFD;
94
-
95
- /// <summary>
96
- ///
97
- /// </summary>
98
- protected virtual void Start()
99
- {
100
- target = GameObject.FindWithTag(mainCameraTag).GetComponent<Transform>();
101
-
102
- if (inThreeDMode.Value)
103
- shouldLookAtTarget = true;
104
-
105
- if (!ignoreReaderCheck)
106
- dialogueManager = ServiceLocator.GetService<IDialogueManager>();
107
- }
108
-
109
- /// <summary>
110
- ///
111
- /// </summary>
112
- protected virtual void FixedUpdate() => BillboardCheck();
113
-
114
- /// <summary>
115
- ///
116
- /// </summary>
117
- protected virtual void BillboardCheck()
118
- {
119
- if (shouldLookAtTarget && !isLoadingFile.Value && !DialogueIsPlaying())
120
- Billboard();
121
- }
122
-
123
- /// <summary>
124
- ///
125
- /// </summary>
126
- protected virtual void Billboard()
127
- {
128
- if (mimicOG)
129
- MimicBillboard();
130
- else
131
- LookAtBillboard();
132
- }
133
-
134
- /// <summary>
135
- ///
136
- /// </summary>
137
- /// <returns></returns>
138
- protected virtual bool DialogueIsPlaying() => ignoreReaderCheck || dialogueManager == null || inDialogue.Value;
139
-
140
- /// <summary>
141
- ///
142
- /// </summary>
143
- protected virtual void MimicBillboard()
144
- {
145
- Vector3 direction = target.transform.forward * -1;
146
-
147
- SetRotation(direction);
148
- }
149
-
150
- /// <summary>
151
- ///
152
- /// </summary>
153
- protected virtual void LookAtBillboard()
154
- {
155
- Vector3 direction = target.transform.position - transform.position;
156
-
157
- SetRotation(direction);
158
- }
159
-
160
- /// <summary>
161
- ///
162
- /// </summary>
163
- /// <param name="direction"></param>
164
- protected virtual void SetRotation(Vector3 direction)
165
- {
166
- transform.rotation = Quaternion.LookRotation(direction);
167
-
168
- transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
169
- }
170
- }
1
+ //Completely Reworked Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ //Original Author: Redberd36
3
+ //Sorry Red I ended up completely reworking this.
4
+ using DREditor.Dialogues;
5
+ using DREditor.EventObjects;
6
+ using DREditor.Services;
7
+ using UnityEngine;
8
+
9
+ namespace DREditor.Talkables
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader("")]
15
+ public class SpriteLookAtTarget : MonoBehaviour
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected BoolWithEvent inDialogue = null;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected BoolWithEvent isLoadingFile = null;
28
+
29
+ /// <summary>
30
+ ///
31
+ /// </summary>
32
+ [Tooltip("")]
33
+ [SerializeField] protected BoolWithEvent inTPFD = null;
34
+
35
+ /// <summary>
36
+ ///
37
+ /// </summary>
38
+ [Tooltip("")]
39
+ [SerializeField] protected BoolWithEvent inThreeDMode = null;
40
+
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ [Header("")]
46
+ [Divider]
47
+ [Tooltip("")]
48
+ [SerializeField] protected bool mimicOG = false;
49
+
50
+ /// <summary>
51
+ ///
52
+ /// </summary>
53
+ [Tooltip("")]
54
+ [SerializeField] protected bool ignoreReaderCheck = false;
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ [Tooltip("")]
60
+ [SerializeField] protected string mainCameraTag = "MainCamera";
61
+
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ protected bool shouldLookAtTarget;
67
+
68
+ /// <summary>
69
+ ///
70
+ /// </summary>
71
+ protected Transform target;
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ protected IDialogueManager dialogueManager;
77
+
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ protected virtual void OnEnable() => inTPFD.AddListener(UpdateLookingStatus);
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ protected virtual void OnDisable() => inTPFD.RemoveListener(UpdateLookingStatus);
88
+
89
+ /// <summary>
90
+ ///
91
+ /// </summary>
92
+ /// <param name="inTPFD"></param>
93
+ protected virtual void UpdateLookingStatus(bool inTPFD) => shouldLookAtTarget = !inTPFD;
94
+
95
+ /// <summary>
96
+ ///
97
+ /// </summary>
98
+ protected virtual void Start()
99
+ {
100
+ target = GameObject.FindWithTag(mainCameraTag).GetComponent<Transform>();
101
+
102
+ if (inThreeDMode.Value)
103
+ shouldLookAtTarget = true;
104
+
105
+ if (!ignoreReaderCheck)
106
+ dialogueManager = ServiceLocator.GetService<IDialogueManager>();
107
+ }
108
+
109
+ /// <summary>
110
+ ///
111
+ /// </summary>
112
+ protected virtual void FixedUpdate() => BillboardCheck();
113
+
114
+ /// <summary>
115
+ ///
116
+ /// </summary>
117
+ protected virtual void BillboardCheck()
118
+ {
119
+ if (shouldLookAtTarget && !isLoadingFile.Value && !DialogueIsPlaying())
120
+ Billboard();
121
+ }
122
+
123
+ /// <summary>
124
+ ///
125
+ /// </summary>
126
+ protected virtual void Billboard()
127
+ {
128
+ if (mimicOG)
129
+ MimicBillboard();
130
+ else
131
+ LookAtBillboard();
132
+ }
133
+
134
+ /// <summary>
135
+ ///
136
+ /// </summary>
137
+ /// <returns></returns>
138
+ protected virtual bool DialogueIsPlaying() => ignoreReaderCheck || dialogueManager == null || inDialogue.Value;
139
+
140
+ /// <summary>
141
+ ///
142
+ /// </summary>
143
+ protected virtual void MimicBillboard()
144
+ {
145
+ Vector3 direction = target.transform.forward * -1;
146
+
147
+ SetRotation(direction);
148
+ }
149
+
150
+ /// <summary>
151
+ ///
152
+ /// </summary>
153
+ protected virtual void LookAtBillboard()
154
+ {
155
+ Vector3 direction = target.transform.position - transform.position;
156
+
157
+ SetRotation(direction);
158
+ }
159
+
160
+ /// <summary>
161
+ ///
162
+ /// </summary>
163
+ /// <param name="direction"></param>
164
+ protected virtual void SetRotation(Vector3 direction)
165
+ {
166
+ transform.rotation = Quaternion.LookRotation(direction);
167
+
168
+ transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
169
+ }
170
+ }
171
171
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: f3a18c748e3417542ad31346fcd48c27
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: f3a18c748e3417542ad31346fcd48c27
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: