net.dreditor.purchasing 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.
Files changed (52) hide show
  1. package/.attestation.p7m +0 -0
  2. package/BufferedSelectedUICacher.cs +73 -73
  3. package/BufferedSelectedUICacher.cs.meta +1 -1
  4. package/DREditor.Purchasing.asmdef +18 -18
  5. package/DREditor.Purchasing.asmdef.meta +7 -7
  6. package/DigitArrow.cs +143 -143
  7. package/DigitArrow.cs.meta +11 -11
  8. package/DisplayCurrencyDigits.cs +122 -122
  9. package/DisplayCurrencyDigits.cs.meta +1 -1
  10. package/DisplayDigit.cs +83 -83
  11. package/DisplayDigit.cs.meta +1 -1
  12. package/DisplayDigits.cs +147 -147
  13. package/DisplayDigits.cs.meta +1 -1
  14. package/EnableInputOnPurchaseComplete.cs +11 -11
  15. package/EnableInputOnPurchaseComplete.cs.meta +1 -1
  16. package/FollowSelectedObject.cs +19 -19
  17. package/FollowSelectedObject.cs.meta +1 -1
  18. package/IDigitPlace.cs +27 -27
  19. package/IDigitPlace.cs.meta +1 -1
  20. package/IntPurchaseInputHandler.cs +77 -77
  21. package/IntPurchaseInputHandler.cs.meta +1 -1
  22. package/PurchaseInputHandlerBase.cs +132 -132
  23. package/PurchaseInputHandlerBase.cs.meta +1 -1
  24. package/{Samples → Samples~}/Buffered_Selected_UI_Cacher.prefab +48 -48
  25. package/{Samples → Samples~}/Buffered_Selected_UI_Cacher.prefab.meta +7 -7
  26. package/{Samples → Samples~}/Enable_Input_On_Purchase_Complete.prefab +55 -55
  27. package/{Samples → Samples~}/Enable_Input_On_Purchase_Complete.prefab.meta +7 -7
  28. package/{Samples → Samples~}/FTE_Currency_Arrows_ETemplate.prefab +248 -248
  29. package/{Samples → Samples~}/FTE_Currency_Arrows_ETemplate.prefab.meta +7 -7
  30. package/{Samples → Samples~}/FTE_Currency_Canvas_ETemplate.prefab +736 -736
  31. package/{Samples → Samples~}/FTE_Currency_Canvas_ETemplate.prefab.meta +7 -7
  32. package/{Samples → Samples~}/FTE_Input_Amount_Display_ETemplate.prefab +646 -646
  33. package/{Samples → Samples~}/FTE_Input_Amount_Display_ETemplate.prefab.meta +7 -7
  34. package/{Samples → Samples~}/FTE_Owned_Amount_Display_ETemplate.prefab +263 -263
  35. package/{Samples → Samples~}/FTE_Owned_Amount_Display_ETemplate.prefab.meta +7 -7
  36. package/{Samples → Samples~}/FTE_Purchase_Complete_Handler.prefab +57 -57
  37. package/{Samples → Samples~}/FTE_Purchase_Complete_Handler.prefab.meta +7 -7
  38. package/{Samples → Samples~}/Hundreds_Digit.prefab +201 -201
  39. package/{Samples → Samples~}/Hundreds_Digit.prefab.meta +7 -7
  40. package/{Samples → Samples~}/On_Cant_Purchase_Listener.prefab +52 -52
  41. package/{Samples → Samples~}/On_Cant_Purchase_Listener.prefab.meta +7 -7
  42. package/{Samples → Samples~}/On_Purchase_Listener.prefab +52 -52
  43. package/{Samples → Samples~}/On_Purchase_Listener.prefab.meta +7 -7
  44. package/{Samples → Samples~}/Ones_Digit.prefab +220 -220
  45. package/{Samples → Samples~}/Ones_Digit.prefab.meta +7 -7
  46. package/{Samples → Samples~}/Tens_Digit.prefab +201 -201
  47. package/{Samples → Samples~}/Tens_Digit.prefab.meta +7 -7
  48. package/SelectedUICacher.cs +75 -75
  49. package/SelectedUICacher.cs.meta +1 -1
  50. package/package.json +42 -37
  51. package/package.json.meta +7 -7
  52. package/Samples.meta +0 -8
package/DisplayDigits.cs CHANGED
@@ -1,148 +1,148 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor.EventObjects;
3
- using UnityEngine;
4
- using UnityEngine.InputSystem;
5
- using static UnityEngine.InputSystem.InputAction;
6
-
7
- namespace DREditor.Purchasing
8
- {
9
- /// <summary>
10
- ///
11
- /// </summary>
12
- public abstract class DisplayDigits : ControlledComponent
13
- {
14
- /// <summary>
15
- ///
16
- /// </summary>
17
- [Header("")]
18
- [Divider]
19
- [Tooltip("")]
20
- [SerializeField] protected InputActionReference move = null;
21
-
22
- /// <summary>
23
- ///
24
- /// </summary>
25
- [Tooltip("")]
26
- [SerializeField] protected bool useHorizontalInput = false;
27
-
28
- /// <summary>
29
- ///
30
- /// </summary>
31
- [Tooltip("")]
32
- [SerializeField] protected int inputDirectionalRate = 1;
33
-
34
- /// <summary>
35
- ///
36
- /// </summary>
37
- [Tooltip("")]
38
- [SerializeField] protected float deadThreshold = 0;
39
-
40
-
41
- /// <summary>
42
- ///
43
- /// </summary>
44
- protected int directionalRate = 0;
45
-
46
- /// <summary>
47
- ///
48
- /// </summary>
49
- protected CallbackContext context;
50
-
51
- /// <summary>
52
- ///
53
- /// </summary>
54
- protected readonly int Zero = 0;
55
-
56
-
57
- /// <inheritdoc/>
58
- public override void ActivateControls() => move.action.started += UpdateDisplayedCurrency;
59
-
60
- /// <inheritdoc/>
61
- public override void DeactivateControls() => move.action.started -= UpdateDisplayedCurrency;
62
-
63
- /// <summary>
64
- ///
65
- /// </summary>
66
- /// <param name="context"></param>
67
- protected virtual void UpdateDisplayedCurrency(CallbackContext context)
68
- {
69
- InitializeOnInput(context);
70
-
71
- ProcessInputAmount();
72
- }
73
-
74
- /// <summary>
75
- ///
76
- /// </summary>
77
- protected abstract void ProcessInputAmount();
78
-
79
-
80
- /// <summary>
81
- ///
82
- /// </summary>
83
- /// <param name="context"></param>
84
- protected virtual void InitializeOnInput(CallbackContext context)
85
- {
86
- InitializeInputContext(context);
87
-
88
- InitializeDirectionalRate();
89
-
90
- InitializeSelectedDigit();
91
- }
92
-
93
- /// <summary>
94
- ///
95
- /// </summary>
96
- /// <param name="context"></param>
97
- protected virtual void InitializeInputContext(CallbackContext context) => this.context = context;
98
-
99
- /// <summary>
100
- ///
101
- /// </summary>
102
- protected virtual void InitializeDirectionalRate() => directionalRate = inputDirectionalRate * (int)CalculateDirection();
103
-
104
- /// <summary>
105
- ///
106
- /// </summary>
107
- /// <returns></returns>
108
- protected virtual float CalculateDirection() => DirectionIsValid() ? Mathf.Sign(GetAxis()) : Zero;
109
-
110
- /// <summary>
111
- ///
112
- /// </summary>
113
- /// <returns></returns>
114
- protected virtual bool DirectionIsValid() => InputPastDeadZone() && !MovingAlongSelectionAxis();
115
-
116
- /// <summary>
117
- ///
118
- /// </summary>
119
- /// <returns></returns>
120
- protected virtual bool InputPastDeadZone() => Mathf.Abs(GetAxis()) > deadThreshold;
121
-
122
- /// <summary>
123
- ///
124
- /// </summary>
125
- /// <returns></returns>
126
- protected virtual bool MovingAlongSelectionAxis() => Mathf.Abs(GetOppositeAxis()) > Mathf.Abs(GetAxis());
127
-
128
- /// <summary>
129
- ///
130
- /// </summary>
131
- /// <returns></returns>
132
- protected virtual float GetAxis() =>
133
- useHorizontalInput ? context.ReadValue<Vector2>().x : context.ReadValue<Vector2>().y;
134
-
135
- /// <summary>
136
- ///
137
- /// </summary>
138
- /// <returns></returns>
139
- protected virtual float GetOppositeAxis() =>
140
- GetAxis() == context.ReadValue<Vector2>().x ? context.ReadValue<Vector2>().y : context.ReadValue<Vector2>().x;
141
-
142
-
143
- /// <summary>
144
- ///
145
- /// </summary>
146
- protected abstract void InitializeSelectedDigit();
147
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+ using UnityEngine;
4
+ using UnityEngine.InputSystem;
5
+ using static UnityEngine.InputSystem.InputAction;
6
+
7
+ namespace DREditor.Purchasing
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ public abstract class DisplayDigits : ControlledComponent
13
+ {
14
+ /// <summary>
15
+ ///
16
+ /// </summary>
17
+ [Header("")]
18
+ [Divider]
19
+ [Tooltip("")]
20
+ [SerializeField] protected InputActionReference move = null;
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ [Tooltip("")]
26
+ [SerializeField] protected bool useHorizontalInput = false;
27
+
28
+ /// <summary>
29
+ ///
30
+ /// </summary>
31
+ [Tooltip("")]
32
+ [SerializeField] protected int inputDirectionalRate = 1;
33
+
34
+ /// <summary>
35
+ ///
36
+ /// </summary>
37
+ [Tooltip("")]
38
+ [SerializeField] protected float deadThreshold = 0;
39
+
40
+
41
+ /// <summary>
42
+ ///
43
+ /// </summary>
44
+ protected int directionalRate = 0;
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ protected CallbackContext context;
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected readonly int Zero = 0;
55
+
56
+
57
+ /// <inheritdoc/>
58
+ public override void ActivateControls() => move.action.started += UpdateDisplayedCurrency;
59
+
60
+ /// <inheritdoc/>
61
+ public override void DeactivateControls() => move.action.started -= UpdateDisplayedCurrency;
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ /// <param name="context"></param>
67
+ protected virtual void UpdateDisplayedCurrency(CallbackContext context)
68
+ {
69
+ InitializeOnInput(context);
70
+
71
+ ProcessInputAmount();
72
+ }
73
+
74
+ /// <summary>
75
+ ///
76
+ /// </summary>
77
+ protected abstract void ProcessInputAmount();
78
+
79
+
80
+ /// <summary>
81
+ ///
82
+ /// </summary>
83
+ /// <param name="context"></param>
84
+ protected virtual void InitializeOnInput(CallbackContext context)
85
+ {
86
+ InitializeInputContext(context);
87
+
88
+ InitializeDirectionalRate();
89
+
90
+ InitializeSelectedDigit();
91
+ }
92
+
93
+ /// <summary>
94
+ ///
95
+ /// </summary>
96
+ /// <param name="context"></param>
97
+ protected virtual void InitializeInputContext(CallbackContext context) => this.context = context;
98
+
99
+ /// <summary>
100
+ ///
101
+ /// </summary>
102
+ protected virtual void InitializeDirectionalRate() => directionalRate = inputDirectionalRate * (int)CalculateDirection();
103
+
104
+ /// <summary>
105
+ ///
106
+ /// </summary>
107
+ /// <returns></returns>
108
+ protected virtual float CalculateDirection() => DirectionIsValid() ? Mathf.Sign(GetAxis()) : Zero;
109
+
110
+ /// <summary>
111
+ ///
112
+ /// </summary>
113
+ /// <returns></returns>
114
+ protected virtual bool DirectionIsValid() => InputPastDeadZone() && !MovingAlongSelectionAxis();
115
+
116
+ /// <summary>
117
+ ///
118
+ /// </summary>
119
+ /// <returns></returns>
120
+ protected virtual bool InputPastDeadZone() => Mathf.Abs(GetAxis()) > deadThreshold;
121
+
122
+ /// <summary>
123
+ ///
124
+ /// </summary>
125
+ /// <returns></returns>
126
+ protected virtual bool MovingAlongSelectionAxis() => Mathf.Abs(GetOppositeAxis()) > Mathf.Abs(GetAxis());
127
+
128
+ /// <summary>
129
+ ///
130
+ /// </summary>
131
+ /// <returns></returns>
132
+ protected virtual float GetAxis() =>
133
+ useHorizontalInput ? context.ReadValue<Vector2>().x : context.ReadValue<Vector2>().y;
134
+
135
+ /// <summary>
136
+ ///
137
+ /// </summary>
138
+ /// <returns></returns>
139
+ protected virtual float GetOppositeAxis() =>
140
+ GetAxis() == context.ReadValue<Vector2>().x ? context.ReadValue<Vector2>().y : context.ReadValue<Vector2>().x;
141
+
142
+
143
+ /// <summary>
144
+ ///
145
+ /// </summary>
146
+ protected abstract void InitializeSelectedDigit();
147
+ }
148
148
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: 9234dde306def9d4a9be10fdc843a49b
@@ -1,12 +1,12 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor.EventObjects;
3
-
4
- namespace DREditor.Purchasing
5
- {
6
- /// <summary>
7
- ///
8
- /// </summary>
9
- [ClassHeader(nameof(SetInputOnSceneEvent) + ", " + nameof(SceneEventListener) +
10
- "\n\n")]
11
- public class EnableInputOnPurchaseComplete : SetInputOnSceneEvent { }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+
4
+ namespace DREditor.Purchasing
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ [ClassHeader(nameof(SetInputOnSceneEvent) + ", " + nameof(SceneEventListener) +
10
+ "\n\n")]
11
+ public class EnableInputOnPurchaseComplete : SetInputOnSceneEvent { }
12
12
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: c71f903717d06a049b53f31985e8129e
@@ -1,20 +1,20 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor;
3
- using UnityEngine;
4
- using UnityEngine.EventSystems;
5
-
6
- namespace DREditor.Purchasing
7
- {
8
- /// <summary>
9
- ///
10
- /// </summary>
11
- [ClassHeader("")]
12
- public class FollowSelectedObject : MonoBehaviour
13
- {
14
- protected virtual void LateUpdate()
15
- {
16
- if (EventSystem.current.currentSelectedGameObject != null)
17
- transform.position = EventSystem.current.currentSelectedGameObject.transform.position;
18
- }
19
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor;
3
+ using UnityEngine;
4
+ using UnityEngine.EventSystems;
5
+
6
+ namespace DREditor.Purchasing
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [ClassHeader("")]
12
+ public class FollowSelectedObject : MonoBehaviour
13
+ {
14
+ protected virtual void LateUpdate()
15
+ {
16
+ if (EventSystem.current.currentSelectedGameObject != null)
17
+ transform.position = EventSystem.current.currentSelectedGameObject.transform.position;
18
+ }
19
+ }
20
20
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: 540e4f04f2e75084a94b62d051864e74
package/IDigitPlace.cs CHANGED
@@ -1,28 +1,28 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
-
3
- namespace DREditor.Purchasing
4
- {
5
- /// <summary>
6
- ///
7
- /// </summary>
8
- public interface IDigitPlace
9
- {
10
- /// <summary>
11
- ///
12
- /// </summary>
13
- /// <returns></returns>
14
- int GetDigitPlace();
15
-
16
- /// <summary>
17
- ///
18
- /// </summary>
19
- /// <returns></returns>
20
- string GetDisplayedDigit();
21
-
22
- /// <summary>
23
- ///
24
- /// </summary>
25
- /// <returns></returns>
26
- bool DisplayingMaxDigit();
27
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+
3
+ namespace DREditor.Purchasing
4
+ {
5
+ /// <summary>
6
+ ///
7
+ /// </summary>
8
+ public interface IDigitPlace
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ /// <returns></returns>
14
+ int GetDigitPlace();
15
+
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ /// <returns></returns>
20
+ string GetDisplayedDigit();
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ /// <returns></returns>
26
+ bool DisplayingMaxDigit();
27
+ }
28
28
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: fdf1f43f8559634429d1cffdb642ec08
@@ -1,78 +1,78 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor.EventObjects;
3
- using DREditor.Saving.Handlers;
4
- using System;
5
- using UnityEngine;
6
- using UnityEngine.InputSystem;
7
- using static UnityEngine.InputSystem.InputAction;
8
-
9
- namespace DREditor.Purchasing
10
- {
11
- /// <summary>
12
- ///
13
- /// </summary>
14
- [ClassHeader(nameof(PurchaseInputHandlerBase) + ", " + nameof(ControlledComponent) +
15
- "\n\n")]
16
- public class IntPurchaseInputHandler : PurchaseInputHandlerBase
17
- {
18
- /// <summary>
19
- ///
20
- /// </summary>
21
- [Header("")]
22
- [Divider]
23
- [Tooltip("")]
24
- [SerializeField] protected InputActionReference submit = null;
25
-
26
- /// <summary>
27
- ///
28
- /// </summary>
29
- [Tooltip("")]
30
- [SerializeField] protected IntWithEvent paidAmount = null;
31
-
32
- /// <summary>
33
- ///
34
- /// </summary>
35
- [Tooltip("")]
36
- [SerializeField] protected CurrencyHandler<int> currencyHandler = null;
37
-
38
-
39
- /// <inheritdoc/>
40
- protected override void SubscribePurchase(Action<CallbackContext> purchase) =>
41
- submit.action.started += purchase;
42
-
43
- /// <inheritdoc/>
44
- protected override void UnsubscribePurchase(Action<CallbackContext> purchase) =>
45
- submit.action.started -= purchase;
46
-
47
-
48
- /// <inheritdoc/>
49
- protected override void Awake()
50
- {
51
- base.Awake();
52
-
53
- if (paidAmount == null)
54
- UnityEngine.Debug.LogError($"ALERT: Field: {nameof(paidAmount)} MUST be assigned to use this functionality.");
55
-
56
- if (currencyHandler == null)
57
- UnityEngine.Debug.LogError($"ALERT: Field: {nameof(currencyHandler)} MUST be assigned to use this functionality.");
58
- }
59
-
60
- /// <inheritdoc/>
61
- protected override void Start()
62
- {
63
- base.Start();
64
-
65
- DisplayAvailableCurrency();
66
- }
67
-
68
- /// <inheritdoc/>
69
- protected override void DisplayAvailableCurrency() => paidAmount.Invoke();
70
-
71
- /// <inheritdoc/>
72
- protected override bool PaymentCanBeMade() => paidAmount.Value != 0 &&
73
- currencyHandler != null && currencyHandler.CanPay(paidAmount.Value) && !currencyHandler.IsBroke();
74
-
75
- /// <inheritdoc/>
76
- protected override void MakePayment() => currencyHandler.RemoveCurrency(paidAmount.Value);
77
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+ using DREditor.Saving.Handlers;
4
+ using System;
5
+ using UnityEngine;
6
+ using UnityEngine.InputSystem;
7
+ using static UnityEngine.InputSystem.InputAction;
8
+
9
+ namespace DREditor.Purchasing
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ [ClassHeader(nameof(PurchaseInputHandlerBase) + ", " + nameof(ControlledComponent) +
15
+ "\n\n")]
16
+ public class IntPurchaseInputHandler : PurchaseInputHandlerBase
17
+ {
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Header("")]
22
+ [Divider]
23
+ [Tooltip("")]
24
+ [SerializeField] protected InputActionReference submit = null;
25
+
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ [Tooltip("")]
30
+ [SerializeField] protected IntWithEvent paidAmount = null;
31
+
32
+ /// <summary>
33
+ ///
34
+ /// </summary>
35
+ [Tooltip("")]
36
+ [SerializeField] protected CurrencyHandler<int> currencyHandler = null;
37
+
38
+
39
+ /// <inheritdoc/>
40
+ protected override void SubscribePurchase(Action<CallbackContext> purchase) =>
41
+ submit.action.started += purchase;
42
+
43
+ /// <inheritdoc/>
44
+ protected override void UnsubscribePurchase(Action<CallbackContext> purchase) =>
45
+ submit.action.started -= purchase;
46
+
47
+
48
+ /// <inheritdoc/>
49
+ protected override void Awake()
50
+ {
51
+ base.Awake();
52
+
53
+ if (paidAmount == null)
54
+ UnityEngine.Debug.LogError($"ALERT: Field: {nameof(paidAmount)} MUST be assigned to use this functionality.");
55
+
56
+ if (currencyHandler == null)
57
+ UnityEngine.Debug.LogError($"ALERT: Field: {nameof(currencyHandler)} MUST be assigned to use this functionality.");
58
+ }
59
+
60
+ /// <inheritdoc/>
61
+ protected override void Start()
62
+ {
63
+ base.Start();
64
+
65
+ DisplayAvailableCurrency();
66
+ }
67
+
68
+ /// <inheritdoc/>
69
+ protected override void DisplayAvailableCurrency() => paidAmount.Invoke();
70
+
71
+ /// <inheritdoc/>
72
+ protected override bool PaymentCanBeMade() => paidAmount.Value != 0 &&
73
+ currencyHandler != null && currencyHandler.CanPay(paidAmount.Value) && !currencyHandler.IsBroke();
74
+
75
+ /// <inheritdoc/>
76
+ protected override void MakePayment() => currencyHandler.RemoveCurrency(paidAmount.Value);
77
+ }
78
78
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: fddcd188ac060ab49bf7ed16f87fa13c