net.dreditor.presents 0.0.0-stage → 0.1.7

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 (71) hide show
  1. package/.attestation.p7m +0 -0
  2. package/DREditor.Presents.asmdef +16 -0
  3. package/DREditor.Presents.asmdef.meta +7 -0
  4. package/Editor/CreatePresentsWizard.cs +160 -0
  5. package/Editor/CreatePresentsWizard.cs.meta +11 -0
  6. package/Editor/DREditor.Presents.Editor.asmdef +18 -0
  7. package/Editor/DREditor.Presents.Editor.asmdef.meta +7 -0
  8. package/Editor/DescriptionsByIDOption.cs +106 -0
  9. package/Editor/DescriptionsByIDOption.cs.meta +2 -0
  10. package/Editor/PresentDatabaseEditor.cs +184 -0
  11. package/Editor/PresentDatabaseEditor.cs.meta +11 -0
  12. package/Editor/PresentEditor.cs +153 -0
  13. package/Editor/PresentEditor.cs.meta +11 -0
  14. package/Editor/PresentGoogleSheetsImportOption.cs +55 -0
  15. package/Editor/PresentGoogleSheetsImportOption.cs.meta +2 -0
  16. package/Editor/PresentImportOptionBase.cs +132 -0
  17. package/Editor/PresentImportOptionBase.cs.meta +2 -0
  18. package/Editor/PresentReactionLevelOption.cs +81 -0
  19. package/Editor/PresentReactionLevelOption.cs.meta +2 -0
  20. package/Editor/PresentUtility.cs +42 -0
  21. package/Editor/PresentUtility.cs.meta +11 -0
  22. package/Editor/ReactionByIDCharactersOption.cs +136 -0
  23. package/Editor/ReactionByIDCharactersOption.cs.meta +2 -0
  24. package/Editor/ReactionByIDOption.cs +54 -0
  25. package/Editor/ReactionByIDOption.cs.meta +2 -0
  26. package/Editor/ReactionImportOption.cs +74 -0
  27. package/Editor/ReactionImportOption.cs.meta +2 -0
  28. package/Editor/ReactionImporter.cs +59 -0
  29. package/Editor/ReactionImporter.cs.meta +11 -0
  30. package/Editor/RenamePresentsByIDOption.cs +96 -0
  31. package/Editor/RenamePresentsByIDOption.cs.meta +2 -0
  32. package/Editor/StudentReactionCollectionEditor.cs +104 -0
  33. package/Editor/StudentReactionCollectionEditor.cs.meta +2 -0
  34. package/Editor/StudentReactionEditor.cs +83 -0
  35. package/Editor/StudentReactionEditor.cs.meta +2 -0
  36. package/Editor.meta +8 -0
  37. package/IAmountablePresent.cs +29 -0
  38. package/IAmountablePresent.cs.meta +2 -0
  39. package/INewPresentObtained.cs +22 -0
  40. package/INewPresentObtained.cs.meta +2 -0
  41. package/IPresentData.cs +10 -0
  42. package/IPresentData.cs.meta +2 -0
  43. package/IPresentManager.cs +38 -0
  44. package/IPresentManager.cs.meta +2 -0
  45. package/IReactionEntry.cs +21 -0
  46. package/IReactionEntry.cs.meta +2 -0
  47. package/Present.cs +24 -0
  48. package/Present.cs.meta +11 -0
  49. package/PresentData.cs +50 -0
  50. package/PresentData.cs.meta +11 -0
  51. package/PresentDatabase.cs +28 -0
  52. package/PresentDatabase.cs.meta +11 -0
  53. package/PresentManager.cs +71 -0
  54. package/PresentManager.cs.meta +11 -0
  55. package/PresentManagerBase.cs +35 -0
  56. package/PresentManagerBase.cs.meta +2 -0
  57. package/PresentReactionLevel.cs +12 -0
  58. package/PresentReactionLevel.cs.meta +11 -0
  59. package/PresentSaveBase.cs +26 -0
  60. package/PresentSaveBase.cs.meta +2 -0
  61. package/ReactionLevelDatabase.cs +35 -0
  62. package/ReactionLevelDatabase.cs.meta +11 -0
  63. package/Samples~/Present_Manager.prefab +54 -0
  64. package/Samples~/Present_Manager.prefab.meta +7 -0
  65. package/StudentReaction.cs +28 -0
  66. package/StudentReaction.cs.meta +2 -0
  67. package/StudentReactionCollection.cs +45 -0
  68. package/StudentReactionCollection.cs.meta +2 -0
  69. package/package.json +37 -4
  70. package/package.json.meta +7 -0
  71. package/README.md +0 -3
@@ -0,0 +1,96 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using System;
4
+ using System.Collections.Generic;
5
+ using UnityEditor;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.Presents.Editor
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [Serializable]
14
+ public class RenamePresentsByIDOption : PresentGoogleSheetsImportOption
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ [Header("")]
20
+ [Divider]
21
+ [Header("")]
22
+ [ReadOnly]
23
+ [Tooltip("")]
24
+ [SerializeField] protected string googleSheetsRegex = "(\\t\\D\\d\\D+|\\D+)|(\\t\\D+|\\D+)";
25
+
26
+
27
+ /// <summary>
28
+ ///
29
+ /// </summary>
30
+ protected Dictionary<int, string> entries;
31
+
32
+
33
+ /// <inheritdoc/>
34
+ public override void Invoke() => RenamePresentsByID();
35
+
36
+ /// <summary>
37
+ ///
38
+ /// </summary>
39
+ protected virtual void RenamePresentsByID()
40
+ {
41
+ List<int> ids = GetListOfIDs();
42
+
43
+ List<string> words = GetListOfNamesGoogleSheetFormat(googleSheetsRegex);
44
+
45
+ if (ids.Count == words.Count)
46
+ RenamePresents(ids, words);
47
+ else
48
+ OnFailedRename();
49
+ }
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected virtual void OnFailedRename()
55
+ {
56
+ EditorUtility.DisplayDialog("Sheet Format Incorrect: Inconsistent ID's and Name count",
57
+ "Please Copy each column on your google sheets with the ID and Name to use this functionality!", "OK");
58
+
59
+ Close();
60
+ }
61
+
62
+ /// <summary>
63
+ ///
64
+ /// </summary>
65
+ /// <param name="ids"></param>
66
+ /// <param name="words"></param>
67
+ protected virtual void RenamePresents(List<int> ids, List<string> words)
68
+ {
69
+ CreatePairing(ids, words, out entries);
70
+
71
+ AssetDatabase.StartAssetEditing();
72
+
73
+ foreach (Present present in presentDatabase.presents)
74
+ if (entries.ContainsKey(present.ID))
75
+ RenamePresent(present);
76
+ else
77
+ UnityEngine.Debug.LogWarning("ALERT: Couldn't Find Present in dictionary With ID: " + present.ID);
78
+
79
+ AssetDatabase.StopAssetEditing();
80
+
81
+ Close();
82
+ }
83
+
84
+ /// <summary>
85
+ ///
86
+ /// </summary>
87
+ /// <param name="present"></param>
88
+ protected virtual void RenamePresent(Present present)
89
+ {
90
+ present.DisplayName = entries[present.ID].Trim().Replace("\r", "");
91
+
92
+ EditorUtility.SetDirty(present);
93
+ }
94
+ }
95
+ }
96
+ #endif
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 53226808e6400dc4ea134e8c38caf1dd
@@ -0,0 +1,104 @@
1
+ // Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ #if UNITY_EDITOR
3
+ using DREditor.Editor.Utility;
4
+ using UnityEditor;
5
+
6
+ namespace DREditor.Presents.Editor
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [CustomClassEditor(typeof(StudentReactionCollection))]
12
+ public class StudentReactionCollectionEditor : ClassEditorBase
13
+ {
14
+ /// <summary>
15
+ ///
16
+ /// </summary>
17
+ private const string ReactionsFieldName = "studentReactions";
18
+
19
+
20
+ /// <inheritdoc/>
21
+ protected override void OnInspectorGUI()
22
+ {
23
+ var parentEditor = GetFirstParameter<UnityEditor.Editor>();
24
+
25
+ var serializedProperty = GetFirstParameter<SerializedProperty>();
26
+
27
+ var eventIndex = GetFirstParameter<InterfaceEditorBase>().currentlyDisplayedEventIndex;
28
+
29
+ var reactionsProp = serializedProperty.GetArrayElementAtIndex(eventIndex)
30
+ .FindPropertyRelative(ReactionsFieldName);
31
+
32
+ var cache = parentEditor as INestedEditorCacheable;
33
+
34
+ if (!ValidateContext(parentEditor, serializedProperty, cache))
35
+ return;
36
+
37
+ var editor = CreateReactionEditor(parentEditor, cache);
38
+
39
+ DisplayClearEntriesButton(editor);
40
+
41
+ editor.DisplayInterfaceInstances(reactionsProp, cache);
42
+
43
+ UpdateCache(cache, editor);
44
+ }
45
+
46
+ /// <summary>
47
+ ///
48
+ /// </summary>
49
+ /// <param name="parent"></param>
50
+ /// <param name="prop"></param>
51
+ /// <param name="cache"></param>
52
+ /// <returns></returns>
53
+ protected virtual bool ValidateContext(UnityEditor.Editor parent, SerializedProperty prop, INestedEditorCacheable cache)
54
+ {
55
+ if (cache != null)
56
+ return true;
57
+
58
+ HandyFields.Label($"ALERT: Parent editor must inherit {nameof(INestedEditorCacheable)}", EditorStyles.helpBox);
59
+
60
+ return false;
61
+ }
62
+
63
+ /// <summary>
64
+ ///
65
+ /// </summary>
66
+ /// <param name="parent"></param>
67
+ /// <param name="cache"></param>
68
+ /// <returns></returns>
69
+ protected virtual InterfaceEditor<IReactionEntry> CreateReactionEditor(UnityEditor.Editor parent, INestedEditorCacheable cache)
70
+ {
71
+ if (!cache.VisibilityCaches.TryGetValue(baseTarget, out bool isVisible))
72
+ isVisible = true;
73
+
74
+ cache.IndexCaches.TryGetValue(baseTarget, out int index);
75
+
76
+ return new InterfaceEditor<IReactionEntry>(parent, ((StudentReactionCollection)baseTarget).studentReactions, isVisible, index);
77
+ }
78
+
79
+ /// <summary>
80
+ ///
81
+ /// </summary>
82
+ /// <param name="editor"></param>
83
+ protected virtual void DisplayClearEntriesButton(InterfaceEditor<IReactionEntry> editor)
84
+ {
85
+ if (HandyFields.Button("Clear") && EditorUtility.DisplayDialog("Clear Entries", "Are you sure you want to clear all entries?",
86
+ "Yes", "No"))
87
+ editor.instances.Clear();
88
+ }
89
+
90
+ /// <summary>
91
+ ///
92
+ /// </summary>
93
+ /// <param name="cache"></param>
94
+ /// <param name="editor"></param>
95
+ protected virtual void UpdateCache(INestedEditorCacheable cache, InterfaceEditor<IReactionEntry> editor)
96
+ {
97
+ cache.VisibilityCaches[baseTarget] = editor.showDiaEvents;
98
+
99
+ cache.IndexCaches[baseTarget] = editor.currentlyPickedIndex;
100
+ }
101
+ }
102
+ }
103
+
104
+ #endif
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: ebb5eff9c9392944f98b161ff01c7588
@@ -0,0 +1,83 @@
1
+ // Original Author: KHeartz
2
+ // Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
3
+ #if UNITY_EDITOR
4
+ using DREditor.Editor.Utility;
5
+ using UnityEditor;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.Presents.Editor
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [CustomClassEditor(typeof(StudentReaction))]
14
+ public class StudentReactionEditor : ClassEditorBase
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ protected ReactionLevelDatabase reactionDatabase;
20
+
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ protected readonly string VerticalBoxLayoutStyle = "Box";
25
+
26
+
27
+ /// <inheritdoc/>
28
+ protected override void OnInspectorGUI()
29
+ {
30
+ INestedEditorCacheable cache = GetFirstParameter<INestedEditorCacheable>();
31
+
32
+ if ((bool)!cache?.TryGetData(out reactionDatabase))
33
+ cache.AddData(DatabaseUtility.LoadDatabase<ReactionLevelDatabase>());
34
+
35
+ if (reactionDatabase == null || cache == null)
36
+ return;
37
+
38
+ using (new EditorGUILayout.HorizontalScope(VerticalBoxLayoutStyle))
39
+ DisplayReaction(baseTarget as StudentReaction);
40
+ }
41
+
42
+ /// <summary>
43
+ ///
44
+ /// </summary>
45
+ /// <param name="reaction"></param>
46
+ protected virtual void DisplayReaction(StudentReaction reaction)
47
+ {
48
+ DisplayStudent(reaction);
49
+
50
+ DisplayReactionDropdown(reaction);
51
+
52
+ EditorGUILayout.Space();
53
+ }
54
+
55
+ /// <summary>
56
+ ///
57
+ /// </summary>
58
+ /// <param name="reaction"></param>
59
+ protected virtual void DisplayStudent(StudentReaction reaction)
60
+ {
61
+ using (new EditorGUILayout.VerticalScope())
62
+ reaction.Character = HandyFields.UnityField(reaction.Character);
63
+ }
64
+
65
+ /// <summary>
66
+ ///
67
+ /// </summary>
68
+ /// <param name="reaction"></param>
69
+ protected virtual void DisplayReactionDropdown(StudentReaction reaction)
70
+ {
71
+ using (new EditorGUILayout.VerticalScope())
72
+ {
73
+ GUILayout.FlexibleSpace();
74
+
75
+ reaction.ReactionIndex = EditorGUILayout.Popup(reaction.ReactionIndex, reactionDatabase.GetReactionNames());
76
+
77
+ GUILayout.FlexibleSpace();
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ #endif
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 5e8757e6f41d69a4ea0b090ed3993202
package/Editor.meta ADDED
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: d2a5f914dfa554b45adc054337b79ebe
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,29 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Processables;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public interface IAmountablePresent : IIdentifiable
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ public int Amount { get; set; }
15
+
16
+
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ /// <param name="amt"></param>
21
+ void Add(int amt = 1);
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ /// <param name="amt"></param>
27
+ void Remove(int amt = 1);
28
+ }
29
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 3b66fa1cfc9f4d94ba2aec98954293b6
@@ -0,0 +1,22 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Processables;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public interface INewPresentObtained : IIdentifiable
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ public bool JustObtained { get; set; }
15
+
16
+
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ void NoLongerNew();
21
+ }
22
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 201c231f6c570f9468b439370d8a5795
@@ -0,0 +1,10 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Items;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public interface IPresentData : IItemAttribute { }
10
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: c8269fce4e37f9a478c2c5834ea9271c
@@ -0,0 +1,38 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Processables;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public interface IPresentManager
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ int Count { get; }
15
+
16
+
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ /// <param name="id"></param>
21
+ /// <returns></returns>
22
+ T Get<T>(int id) where T : IIdentifiable;
23
+
24
+ /// <summary>
25
+ ///
26
+ /// </summary>
27
+ /// <param name="id"></param>
28
+ /// <param name="amt"></param>
29
+ void AddPresent(int id, int amt = 1);
30
+
31
+ /// <summary>
32
+ ///
33
+ /// </summary>
34
+ /// <param name="id"></param>
35
+ /// <returns></returns>
36
+ bool HadPresent(int id);
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 239cd4dec7bd53644a524a47ca4323bc
@@ -0,0 +1,21 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Characters;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ public interface IReactionEntry
10
+ {
11
+ /// <summary>
12
+ ///
13
+ /// </summary>
14
+ Character Character { get; set; }
15
+
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ int ReactionIndex { get; set; }
20
+ }
21
+ }
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 762b013cc69379a4e8230bea8fe13c31
package/Present.cs ADDED
@@ -0,0 +1,24 @@
1
+ // Original Author: KHeartz
2
+ // Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
3
+ using DREditor.Items;
4
+ using DREditor.Processables;
5
+ using UnityEngine;
6
+
7
+ namespace DREditor.Presents
8
+ {
9
+ /// <summary>
10
+ ///
11
+ /// </summary>
12
+ [System.Serializable]
13
+ [CreateAssetMenu(menuName = "DREditor/Presents/Present", fileName = "Present")]
14
+ public class Present : AttributableInventoryItem<IPresentData>, IIdentifiable
15
+ {
16
+ /// <summary>
17
+ ///
18
+ /// </summary>
19
+ [SerializeField] protected int id;
20
+
21
+
22
+ public virtual int ID { get => id; set => id = value; }
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4708e17348037514e8ae9b21cb0dfd4f
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/PresentData.cs ADDED
@@ -0,0 +1,50 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using UnityEngine;
3
+
4
+ namespace DREditor.Presents
5
+ {
6
+ /// <summary>
7
+ ///
8
+ /// </summary>
9
+ [System.Serializable]
10
+ public class PresentData : PresentSaveBase, INewPresentObtained, IAmountablePresent
11
+ {
12
+ /// <summary>
13
+ ///
14
+ /// </summary>
15
+ [Tooltip("")]
16
+ [SerializeField] protected int amount = 0;
17
+
18
+ /// <summary>
19
+ ///
20
+ /// </summary>
21
+ [Tooltip("")]
22
+ [SerializeField] protected bool justObtained = true;
23
+
24
+
25
+ public virtual int Amount { get => amount; set => amount = value; }
26
+
27
+ public virtual bool JustObtained { get => justObtained; set => justObtained = value; }
28
+
29
+
30
+ public PresentData() { }
31
+
32
+ public PresentData(int ID, int amount) : base(ID) => this.amount = amount;
33
+
34
+
35
+ /// <inheritdoc/>
36
+ public virtual void NoLongerNew() => JustObtained = false;
37
+
38
+ /// <inheritdoc/>
39
+ public virtual void Add(int amt = 1) => Amount += amt;
40
+
41
+ /// <inheritdoc/>
42
+ public virtual void Remove(int amt = 1)
43
+ {
44
+ if (Amount > 0)
45
+ Amount -= amt;
46
+ else
47
+ UnityEngine.Debug.LogWarning("ALERT: You are trying to remove a present the player doesn't have enough of.");
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 8b67a7b969e67924fa3382a46e69ff25
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,28 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For DREditor
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using UnityEngine;
5
+
6
+ namespace DREditor.Presents
7
+ {
8
+ /// <summary>
9
+ ///
10
+ /// </summary>
11
+ [System.Serializable]
12
+ [CreateAssetMenu(menuName = "DREditor/Presents/Database", fileName = "PresentDatabase")]
13
+ public class PresentDatabase : ScriptableObject
14
+ {
15
+ /// <summary>
16
+ ///
17
+ /// </summary>
18
+ public List<Present> presents = new();
19
+
20
+
21
+ /// <summary>
22
+ ///
23
+ /// </summary>
24
+ /// <param name="id"></param>
25
+ /// <returns></returns>
26
+ public virtual Present GetPresentByID(int id) => presents.Where(p => p.ID == id).FirstOrDefault();
27
+ }
28
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 29abc245fd095e3438e5e68d986d00d7
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,71 @@
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ using DREditor.Saving;
3
+ using DREditor.Services;
4
+ using DREditor.Utility;
5
+ using System.Collections.Generic;
6
+ using UnityEngine;
7
+
8
+ namespace DREditor.Presents
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [ClassHeader(nameof(ServiceHolder<IPresentManager>) + " for type: " + nameof(IPresentManager) +
14
+ "\n\n")]
15
+ public class PresentManager : PresentManagerBase<PresentData>, IDRESaveable, IDRELoadableManager, ILoadOnChapterSelect
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Header("")]
21
+ [Divider]
22
+ [Tooltip("")]
23
+ [SerializeField] protected string saveKey = "presentData";
24
+
25
+
26
+ /// <inheritdoc/>
27
+ public override void AddPresent(int id, int amt = 1)
28
+ {
29
+ IAmountablePresent data = Get<IAmountablePresent>(id);
30
+
31
+ if (data != null)
32
+ data.Add(amt);
33
+ else
34
+ presentDatas.Add(new(id, amt));
35
+ }
36
+
37
+
38
+ /// <inheritdoc/>
39
+ public virtual void Save(Dictionary<string, object> saveData) => saveData.Set(saveKey, presentDatas);
40
+
41
+ /// <inheritdoc/>
42
+ public virtual void LoadManager(Dictionary<string, object> saveDatas, bool inChapterSelect)
43
+ {
44
+ if (!inChapterSelect)
45
+ SetPresentData(saveDatas.Get<List<PresentData>>(saveKey));
46
+ }
47
+
48
+ /// <summary>
49
+ ///
50
+ /// </summary>
51
+ /// <param name="newDatas"></param>
52
+ protected virtual void SetPresentData(List<PresentData> newDatas)
53
+ {
54
+ ClearPresentData();
55
+
56
+ if (newDatas != null)
57
+ foreach (var presentData in newDatas)
58
+ presentDatas.Add(presentData.DeepCopy());
59
+ }
60
+
61
+ /// <summary>
62
+ ///
63
+ /// </summary>
64
+ protected virtual void ClearPresentData() => presentDatas.Clear();
65
+
66
+
67
+ /// <inheritdoc/>
68
+ public virtual void CarryOverOnChapterSelect(Dictionary<string, object> oldSaveDatas, Dictionary<string, object> newSaveDatas) =>
69
+ newSaveDatas.Set(saveKey, oldSaveDatas.Get<List<PresentData>>(saveKey));
70
+ }
71
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c1e952d7bcf686c40b3de7ed39ee3f59
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: