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
@@ -1,123 +1,123 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor.EventObjects;
3
- using DREditor.EventObjectServices;
4
- using DREditor.Saving.Handlers;
5
- using DREditor.Utility;
6
- using System.Collections.Generic;
7
- using System.Linq;
8
- using UnityEngine;
9
-
10
- namespace DREditor.Purchasing
11
- {
12
- /// <summary>
13
- ///
14
- /// </summary>
15
- [ClassHeader(nameof(ControlledComponent) + ", " + nameof(DisplayDigits) +
16
- "\n\n")]
17
- public class DisplayCurrencyDigits : DisplayDigits
18
- {
19
- /// <summary>
20
- ///
21
- /// </summary>
22
- [Header("")]
23
- [Divider]
24
- [Tooltip("")]
25
- [SerializeField] protected List<IntWithEventListener> digits = new();
26
-
27
- /// <summary>
28
- ///
29
- /// </summary>
30
- [Tooltip("")]
31
- [SerializeField] protected CurrencyHandler<int> currencyHandler = null;
32
-
33
- /// <summary>
34
- ///
35
- /// </summary>
36
- [Tooltip("")]
37
- [SerializeField] protected IntWithEvent paidAmount = null;
38
-
39
-
40
- /// <summary>
41
- ///
42
- /// </summary>
43
- protected IDigitPlace selectedDigit;
44
-
45
-
46
- /// <inheritdoc/>
47
- protected override void Awake()
48
- {
49
- base.Awake();
50
-
51
- paidAmount.SetValue(Zero);
52
- }
53
-
54
-
55
- /// <inheritdoc/>
56
- protected override void InitializeSelectedDigit() =>
57
- selectedDigit = digits.GetSelectedObjectOfType<IDigitPlace>();
58
-
59
-
60
- /// <inheritdoc/>
61
- protected override void ProcessInputAmount()
62
- {
63
- if (DigitsShouldBeUpdated())
64
- UpdateDigitsFrom(CalculateDigitAmount());
65
- }
66
-
67
- /// <summary>
68
- ///
69
- /// </summary>
70
- /// <returns></returns>
71
- protected virtual bool DigitsShouldBeUpdated() => HandlersValid() && !DecreasingOnZero() && !IncreasingWhenDigitsMaxed();
72
-
73
- /// <summary>
74
- ///
75
- /// </summary>
76
- /// <returns></returns>
77
- protected virtual bool HandlersValid() => selectedDigit != null && currencyHandler != null;
78
-
79
- /// <summary>
80
- ///
81
- /// </summary>
82
- /// <returns></returns>
83
- protected virtual bool DecreasingOnZero() => directionalRate <= Zero && paidAmount.Value == Zero;
84
-
85
- /// <summary>
86
- ///
87
- /// </summary>
88
- /// <returns></returns>
89
- protected virtual bool IncreasingWhenDigitsMaxed() =>
90
- directionalRate == inputDirectionalRate && ForwardDigitsMaxed(selectedDigit);
91
-
92
- /// <summary>
93
- ///
94
- /// </summary>
95
- /// <param name="starting"></param>
96
- /// <returns></returns>
97
- protected virtual bool ForwardDigitsMaxed(IDigitPlace starting) =>
98
- digits.OfType<IDigitPlace>()
99
- .SkipWhile(digit => digit != starting)
100
- .All(digit => digit.DisplayingMaxDigit());
101
-
102
-
103
- /// <summary>
104
- ///
105
- /// </summary>
106
- /// <param name="amount"></param>
107
- protected virtual void UpdateDigitsFrom(int amount)
108
- {
109
- if (currencyHandler.GetCurrency() + amount < Zero || paidAmount.Value + amount < Zero)
110
- paidAmount.SetValue(Zero);
111
- else if (paidAmount.Value + amount <= currencyHandler.GetCurrency())
112
- paidAmount.SetValue(paidAmount.Value + amount);
113
- else
114
- paidAmount.Invoke();
115
- }
116
-
117
- /// <summary>
118
- ///
119
- /// </summary>
120
- /// <returns></returns>
121
- protected virtual int CalculateDigitAmount() => selectedDigit.GetDigitPlace() * directionalRate;
122
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.EventObjects;
3
+ using DREditor.EventObjectServices;
4
+ using DREditor.Saving.Handlers;
5
+ using DREditor.Utility;
6
+ using System.Collections.Generic;
7
+ using System.Linq;
8
+ using UnityEngine;
9
+
10
+ namespace DREditor.Purchasing
11
+ {
12
+ /// <summary>
13
+ ///
14
+ /// </summary>
15
+ [ClassHeader(nameof(ControlledComponent) + ", " + nameof(DisplayDigits) +
16
+ "\n\n")]
17
+ public class DisplayCurrencyDigits : DisplayDigits
18
+ {
19
+ /// <summary>
20
+ ///
21
+ /// </summary>
22
+ [Header("")]
23
+ [Divider]
24
+ [Tooltip("")]
25
+ [SerializeField] protected List<IntWithEventListener> digits = new();
26
+
27
+ /// <summary>
28
+ ///
29
+ /// </summary>
30
+ [Tooltip("")]
31
+ [SerializeField] protected CurrencyHandler<int> currencyHandler = null;
32
+
33
+ /// <summary>
34
+ ///
35
+ /// </summary>
36
+ [Tooltip("")]
37
+ [SerializeField] protected IntWithEvent paidAmount = null;
38
+
39
+
40
+ /// <summary>
41
+ ///
42
+ /// </summary>
43
+ protected IDigitPlace selectedDigit;
44
+
45
+
46
+ /// <inheritdoc/>
47
+ protected override void Awake()
48
+ {
49
+ base.Awake();
50
+
51
+ paidAmount.SetValue(Zero);
52
+ }
53
+
54
+
55
+ /// <inheritdoc/>
56
+ protected override void InitializeSelectedDigit() =>
57
+ selectedDigit = digits.GetSelectedObjectOfType<IDigitPlace>();
58
+
59
+
60
+ /// <inheritdoc/>
61
+ protected override void ProcessInputAmount()
62
+ {
63
+ if (DigitsShouldBeUpdated())
64
+ UpdateDigitsFrom(CalculateDigitAmount());
65
+ }
66
+
67
+ /// <summary>
68
+ ///
69
+ /// </summary>
70
+ /// <returns></returns>
71
+ protected virtual bool DigitsShouldBeUpdated() => HandlersValid() && !DecreasingOnZero() && !IncreasingWhenDigitsMaxed();
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ /// <returns></returns>
77
+ protected virtual bool HandlersValid() => selectedDigit != null && currencyHandler != null;
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ /// <returns></returns>
83
+ protected virtual bool DecreasingOnZero() => directionalRate <= Zero && paidAmount.Value == Zero;
84
+
85
+ /// <summary>
86
+ ///
87
+ /// </summary>
88
+ /// <returns></returns>
89
+ protected virtual bool IncreasingWhenDigitsMaxed() =>
90
+ directionalRate == inputDirectionalRate && ForwardDigitsMaxed(selectedDigit);
91
+
92
+ /// <summary>
93
+ ///
94
+ /// </summary>
95
+ /// <param name="starting"></param>
96
+ /// <returns></returns>
97
+ protected virtual bool ForwardDigitsMaxed(IDigitPlace starting) =>
98
+ digits.OfType<IDigitPlace>()
99
+ .SkipWhile(digit => digit != starting)
100
+ .All(digit => digit.DisplayingMaxDigit());
101
+
102
+
103
+ /// <summary>
104
+ ///
105
+ /// </summary>
106
+ /// <param name="amount"></param>
107
+ protected virtual void UpdateDigitsFrom(int amount)
108
+ {
109
+ if (currencyHandler.GetCurrency() + amount < Zero || paidAmount.Value + amount < Zero)
110
+ paidAmount.SetValue(Zero);
111
+ else if (paidAmount.Value + amount <= currencyHandler.GetCurrency())
112
+ paidAmount.SetValue(paidAmount.Value + amount);
113
+ else
114
+ paidAmount.Invoke();
115
+ }
116
+
117
+ /// <summary>
118
+ ///
119
+ /// </summary>
120
+ /// <returns></returns>
121
+ protected virtual int CalculateDigitAmount() => selectedDigit.GetDigitPlace() * directionalRate;
122
+ }
123
123
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: 796b32f42dac4bd4c84fa34c2c3a2a38
package/DisplayDigit.cs CHANGED
@@ -1,84 +1,84 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- using DREditor;
3
- using DREditor.EventObjectServices;
4
- using TMPro;
5
- using UnityEngine;
6
-
7
- namespace DREditor.Purchasing
8
- {
9
- /// <summary>
10
- ///
11
- /// </summary>
12
- [ClassHeader(nameof(IntWithEventListener) + ", " + nameof(IDigitPlace) +
13
- "\n\n")]
14
- public class DisplayDigit : IntWithEventListener, IDigitPlace
15
- {
16
- /// <summary>
17
- ///
18
- /// </summary>
19
- [Tooltip("")]
20
- [SerializeField] protected TMP_Text digitText;
21
-
22
- /// <summary>
23
- ///
24
- /// </summary>
25
- [Tooltip("")]
26
- [SerializeField] protected int digitPlace = 1;
27
-
28
- /// <summary>
29
- ///
30
- /// </summary>
31
- [Range(0, 9)]
32
- [Tooltip("")]
33
- [SerializeField] protected int maxDigit = 9;
34
-
35
-
36
- /// <summary>
37
- ///
38
- /// </summary>
39
- private const int DigitModulus = 10;
40
-
41
-
42
- protected virtual void Awake()
43
- {
44
- if (DigitPlaceInvalid())
45
- UnityEngine.Debug.LogError("ALERT: THE DIGIT PLACE IS NOT VALID! Valid Examples: 1, 10, 100");
46
- }
47
-
48
- /// <summary>
49
- ///
50
- /// </summary>
51
- /// <returns></returns>
52
- protected virtual bool DigitPlaceInvalid() => digitPlace == 0 || (digitPlace > 1 && digitPlace % DigitModulus != 0);
53
-
54
-
55
- /// <inheritdoc/>
56
- protected override void OnValueChanged(int updatedValue)
57
- {
58
- base.OnValueChanged(updatedValue);
59
-
60
- UpdateDisplayedDigit();
61
- }
62
-
63
- /// <summary>
64
- ///
65
- /// </summary>
66
- protected virtual void UpdateDisplayedDigit() => digitText.text = CalculateDigit().ToString();
67
-
68
- /// <summary>
69
- ///
70
- /// </summary>
71
- /// <returns></returns>
72
- protected virtual int CalculateDigit() => UpdatedValue < digitPlace ? 0 : UpdatedValue / digitPlace % DigitModulus;
73
-
74
-
75
- /// <inheritdoc/>
76
- public virtual int GetDigitPlace() => digitPlace;
77
-
78
- /// <inheritdoc/>
79
- public virtual string GetDisplayedDigit() => digitText.text;
80
-
81
- /// <inheritdoc/>
82
- public virtual bool DisplayingMaxDigit() => GetDisplayedDigit() == maxDigit.ToString();
83
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor;
3
+ using DREditor.EventObjectServices;
4
+ using TMPro;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.Purchasing
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [ClassHeader(nameof(IntWithEventListener) + ", " + nameof(IDigitPlace) +
13
+ "\n\n")]
14
+ public class DisplayDigit : IntWithEventListener, IDigitPlace
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ [Tooltip("")]
20
+ [SerializeField] protected TMP_Text digitText;
21
+
22
+ /// <summary>
23
+ ///
24
+ /// </summary>
25
+ [Tooltip("")]
26
+ [SerializeField] protected int digitPlace = 1;
27
+
28
+ /// <summary>
29
+ ///
30
+ /// </summary>
31
+ [Range(0, 9)]
32
+ [Tooltip("")]
33
+ [SerializeField] protected int maxDigit = 9;
34
+
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ private const int DigitModulus = 10;
40
+
41
+
42
+ protected virtual void Awake()
43
+ {
44
+ if (DigitPlaceInvalid())
45
+ UnityEngine.Debug.LogError("ALERT: THE DIGIT PLACE IS NOT VALID! Valid Examples: 1, 10, 100");
46
+ }
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ /// <returns></returns>
52
+ protected virtual bool DigitPlaceInvalid() => digitPlace == 0 || (digitPlace > 1 && digitPlace % DigitModulus != 0);
53
+
54
+
55
+ /// <inheritdoc/>
56
+ protected override void OnValueChanged(int updatedValue)
57
+ {
58
+ base.OnValueChanged(updatedValue);
59
+
60
+ UpdateDisplayedDigit();
61
+ }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ protected virtual void UpdateDisplayedDigit() => digitText.text = CalculateDigit().ToString();
67
+
68
+ /// <summary>
69
+ ///
70
+ /// </summary>
71
+ /// <returns></returns>
72
+ protected virtual int CalculateDigit() => UpdatedValue < digitPlace ? 0 : UpdatedValue / digitPlace % DigitModulus;
73
+
74
+
75
+ /// <inheritdoc/>
76
+ public virtual int GetDigitPlace() => digitPlace;
77
+
78
+ /// <inheritdoc/>
79
+ public virtual string GetDisplayedDigit() => digitText.text;
80
+
81
+ /// <inheritdoc/>
82
+ public virtual bool DisplayingMaxDigit() => GetDisplayedDigit() == maxDigit.ToString();
83
+ }
84
84
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: b5dffb98e49b6ec4d8b394b6e7fd408b