net.dreditor.presents 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.
- package/DREditor.Presents.asmdef +16 -0
- package/DREditor.Presents.asmdef.meta +7 -0
- package/Editor/CreatePresentsWizard.cs +160 -0
- package/Editor/CreatePresentsWizard.cs.meta +11 -0
- package/Editor/DREditor.Presents.Editor.asmdef +18 -0
- package/Editor/DREditor.Presents.Editor.asmdef.meta +7 -0
- package/Editor/DescriptionsByIDOption.cs +106 -0
- package/Editor/DescriptionsByIDOption.cs.meta +2 -0
- package/Editor/PresentDatabaseEditor.cs +184 -0
- package/Editor/PresentDatabaseEditor.cs.meta +11 -0
- package/Editor/PresentEditor.cs +153 -0
- package/Editor/PresentEditor.cs.meta +11 -0
- package/Editor/PresentGoogleSheetsImportOption.cs +55 -0
- package/Editor/PresentGoogleSheetsImportOption.cs.meta +2 -0
- package/Editor/PresentImportOptionBase.cs +132 -0
- package/Editor/PresentImportOptionBase.cs.meta +2 -0
- package/Editor/PresentReactionLevelOption.cs +81 -0
- package/Editor/PresentReactionLevelOption.cs.meta +2 -0
- package/Editor/PresentUtility.cs +42 -0
- package/Editor/PresentUtility.cs.meta +11 -0
- package/Editor/ReactionByIDCharactersOption.cs +136 -0
- package/Editor/ReactionByIDCharactersOption.cs.meta +2 -0
- package/Editor/ReactionByIDOption.cs +54 -0
- package/Editor/ReactionByIDOption.cs.meta +2 -0
- package/Editor/ReactionImportOption.cs +74 -0
- package/Editor/ReactionImportOption.cs.meta +2 -0
- package/Editor/ReactionImporter.cs +59 -0
- package/Editor/ReactionImporter.cs.meta +11 -0
- package/Editor/RenamePresentsByIDOption.cs +96 -0
- package/Editor/RenamePresentsByIDOption.cs.meta +2 -0
- package/Editor/StudentReactionCollectionEditor.cs +104 -0
- package/Editor/StudentReactionCollectionEditor.cs.meta +2 -0
- package/Editor/StudentReactionEditor.cs +83 -0
- package/Editor/StudentReactionEditor.cs.meta +2 -0
- package/Editor.meta +8 -0
- package/IAmountablePresent.cs +29 -0
- package/IAmountablePresent.cs.meta +2 -0
- package/INewPresentObtained.cs +22 -0
- package/INewPresentObtained.cs.meta +2 -0
- package/IPresentData.cs +10 -0
- package/IPresentData.cs.meta +2 -0
- package/IPresentManager.cs +38 -0
- package/IPresentManager.cs.meta +2 -0
- package/IReactionEntry.cs +21 -0
- package/IReactionEntry.cs.meta +2 -0
- package/Present.cs +24 -0
- package/Present.cs.meta +11 -0
- package/PresentData.cs +50 -0
- package/PresentData.cs.meta +11 -0
- package/PresentDatabase.cs +28 -0
- package/PresentDatabase.cs.meta +11 -0
- package/PresentManager.cs +71 -0
- package/PresentManager.cs.meta +11 -0
- package/PresentManagerBase.cs +35 -0
- package/PresentManagerBase.cs.meta +2 -0
- package/PresentReactionLevel.cs +12 -0
- package/PresentReactionLevel.cs.meta +11 -0
- package/PresentSaveBase.cs +26 -0
- package/PresentSaveBase.cs.meta +2 -0
- package/ReactionLevelDatabase.cs +35 -0
- package/ReactionLevelDatabase.cs.meta +11 -0
- package/Samples/Present_Manager.prefab +54 -0
- package/Samples/Present_Manager.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/StudentReaction.cs +28 -0
- package/StudentReaction.cs.meta +2 -0
- package/StudentReactionCollection.cs +45 -0
- package/StudentReactionCollection.cs.meta +2 -0
- package/package.json +34 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,55 @@
|
|
|
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 System.Linq;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Presents.Editor
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[Serializable]
|
|
14
|
+
public abstract class PresentGoogleSheetsImportOption : PresentImportOptionBase
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <param name="pattern"></param>
|
|
20
|
+
/// <returns></returns>
|
|
21
|
+
protected virtual List<string> GetListOfNamesGoogleSheetFormat(string pattern)
|
|
22
|
+
{
|
|
23
|
+
var matches = Regex.Matches(textArea, pattern);
|
|
24
|
+
|
|
25
|
+
List<string> words = new();
|
|
26
|
+
|
|
27
|
+
foreach (Match match in matches)
|
|
28
|
+
if (match.Value == string.Empty || string.IsNullOrWhiteSpace(match.Value))
|
|
29
|
+
continue;
|
|
30
|
+
else
|
|
31
|
+
words.Add(match.Value.Replace(tab, ""));
|
|
32
|
+
|
|
33
|
+
return words;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
/// <param name="ids"></param>
|
|
40
|
+
/// <param name="words"></param>
|
|
41
|
+
/// <param name="dictionary"></param>
|
|
42
|
+
protected virtual void CreatePairing(List<int> ids, List<string> words, out Dictionary<int, string> dictionary)
|
|
43
|
+
{
|
|
44
|
+
var count = Math.Min(ids.Count, words.Count);
|
|
45
|
+
|
|
46
|
+
dictionary = ids.Take(count)
|
|
47
|
+
.Zip(words.Take(count), (id, word) => new { id, word })
|
|
48
|
+
.ToDictionary(pair => pair.id, pair => pair.word);
|
|
49
|
+
|
|
50
|
+
foreach (var pair in dictionary)
|
|
51
|
+
UnityEngine.Debug.Log($"Key: {pair.Key}, Value: {pair.Value}");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
#endif
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Editor.Utility;
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.Editor
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Serializable]
|
|
16
|
+
public abstract class PresentImportOptionBase
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected PresentDatabase presentDatabase;
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[TextArea(10, 50)]
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected string textArea;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[ReadOnly]
|
|
35
|
+
[Tooltip("")]
|
|
36
|
+
[SerializeField] protected string anyNumberRegex = "\\D+";
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
protected readonly string tab = "\t";
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
///
|
|
46
|
+
/// </summary>
|
|
47
|
+
protected Action Close;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
public abstract void Invoke();
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
/// <param name="Close"></param>
|
|
61
|
+
public virtual void Initialize(Action Close)
|
|
62
|
+
{
|
|
63
|
+
this.Close = Close;
|
|
64
|
+
|
|
65
|
+
InitializeDatabases();
|
|
66
|
+
|
|
67
|
+
CloseIfInitializationFailed();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
///
|
|
72
|
+
/// </summary>
|
|
73
|
+
protected virtual void InitializeDatabases() => presentDatabase = DatabaseUtility.LoadDatabase<PresentDatabase>();
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
protected virtual void CloseIfInitializationFailed()
|
|
79
|
+
{
|
|
80
|
+
if (InitializationFailed())
|
|
81
|
+
Close();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <returns></returns>
|
|
88
|
+
protected virtual bool InitializationFailed()
|
|
89
|
+
{
|
|
90
|
+
bool result = !presentDatabase;
|
|
91
|
+
|
|
92
|
+
if (result)
|
|
93
|
+
EditorUtility.DisplayDialog("Missing Databases", "Please make sure you have a Present Database to " +
|
|
94
|
+
"use this functionality!", "OK");
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
///
|
|
102
|
+
/// </summary>
|
|
103
|
+
/// <returns></returns>
|
|
104
|
+
protected virtual List<int> GetListOfIDs() => CollectIDs(Regex.Split(textArea, anyNumberRegex));
|
|
105
|
+
|
|
106
|
+
/// <summary>
|
|
107
|
+
///
|
|
108
|
+
/// </summary>
|
|
109
|
+
/// <param name="matches"></param>
|
|
110
|
+
/// <returns></returns>
|
|
111
|
+
protected virtual List<int> CollectIDs(string[] matches)
|
|
112
|
+
{
|
|
113
|
+
List<int> ids = new();
|
|
114
|
+
|
|
115
|
+
foreach (string matchedString in matches)
|
|
116
|
+
{
|
|
117
|
+
if (matchedString == string.Empty)
|
|
118
|
+
continue;
|
|
119
|
+
|
|
120
|
+
int matchedInt = Int32.Parse(matchedString.Replace(tab, ""));
|
|
121
|
+
|
|
122
|
+
if (ids.Contains(matchedInt))
|
|
123
|
+
continue;
|
|
124
|
+
else
|
|
125
|
+
ids.Add(matchedInt);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return ids;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
#endif
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Characters;
|
|
4
|
+
using System;
|
|
5
|
+
using System.Text.RegularExpressions;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
namespace DREditor.Presents.Editor
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
[Serializable]
|
|
15
|
+
public class PresentReactionLevelOption : ReactionImportOption
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Header("")]
|
|
21
|
+
[Divider]
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected Character character;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/// <inheritdoc/>
|
|
27
|
+
public override void Invoke()
|
|
28
|
+
{
|
|
29
|
+
if (InvalidCharacterSelected())
|
|
30
|
+
return;
|
|
31
|
+
|
|
32
|
+
AssetDatabase.StartAssetEditing();
|
|
33
|
+
|
|
34
|
+
SetPresentsReactionLevel();
|
|
35
|
+
|
|
36
|
+
AssetDatabase.StopAssetEditing();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
/// <returns></returns>
|
|
43
|
+
protected virtual bool InvalidCharacterSelected()
|
|
44
|
+
{
|
|
45
|
+
bool result = character == null || string.IsNullOrEmpty(character.FirstName);
|
|
46
|
+
|
|
47
|
+
if (result)
|
|
48
|
+
{
|
|
49
|
+
EditorUtility.DisplayDialog("No Character Selected", "Please make sure you select a character to " +
|
|
50
|
+
"use this functionality!", "OK");
|
|
51
|
+
|
|
52
|
+
Close();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
protected virtual void SetPresentsReactionLevel()
|
|
62
|
+
{
|
|
63
|
+
int count = 0;
|
|
64
|
+
|
|
65
|
+
foreach (Present present in presentDatabase.presents)
|
|
66
|
+
{
|
|
67
|
+
var matches = Regex.Match(textArea, present.DisplayName);
|
|
68
|
+
|
|
69
|
+
if (matches.Length > 0)
|
|
70
|
+
{
|
|
71
|
+
count++;
|
|
72
|
+
|
|
73
|
+
ApplyReactions(present, character.FirstName);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
UnityEngine.Debug.Log("REPORT: Found Presents: " + count);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
#endif
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Editor.Utility;
|
|
4
|
+
using DREditor.Services;
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Presents.Editor
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
public static class PresentUtility
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
[MenuItem("DREditor/FTE/Give All Presents")]
|
|
19
|
+
public static void DebugGiveAllPresents()
|
|
20
|
+
{
|
|
21
|
+
if (!Application.isPlaying)
|
|
22
|
+
{
|
|
23
|
+
UnityEngine.Debug.LogWarning("ANALYSIS: You must be in play mode to use this command.");
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!ServiceLocator.HasService(out IPresentManager presentManager))
|
|
29
|
+
{
|
|
30
|
+
UnityEngine.Debug.LogWarning($"ALERT: There was no service with the type {nameof(IPresentManager)}, aborting command.");
|
|
31
|
+
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
PresentDatabase presentDatabase = BuilderUtility.FindAssetByType<PresentDatabase>();
|
|
36
|
+
|
|
37
|
+
foreach (Present present in presentDatabase.presents)
|
|
38
|
+
presentManager?.AddPresent(present.ID);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
@@ -0,0 +1,136 @@
|
|
|
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 System.IO;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
using UnityEditor;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Presents.Editor
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Serializable]
|
|
16
|
+
public class ReactionByIDCharactersOption : ReactionImportOption
|
|
17
|
+
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[Header("")]
|
|
22
|
+
[Divider]
|
|
23
|
+
[Header("")]
|
|
24
|
+
[ReadOnly]
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected string splitLineRegex = @"(?:^|[,\\s\\t]+)([A-Za-z]+(?:\\s+[A-Za-z]+)*)";
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
protected List<int> idMatches;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/// <inheritdoc/>
|
|
36
|
+
public override void Invoke()
|
|
37
|
+
{
|
|
38
|
+
try
|
|
39
|
+
{
|
|
40
|
+
AssetDatabase.StartAssetEditing();
|
|
41
|
+
|
|
42
|
+
SetAllOfReactionType();
|
|
43
|
+
}
|
|
44
|
+
catch (Exception exception)
|
|
45
|
+
{
|
|
46
|
+
UnityEngine.Debug.LogError("ALERT: Failed to apply process so it was aborted. \nReason: " + exception.ToString());
|
|
47
|
+
}
|
|
48
|
+
finally
|
|
49
|
+
{
|
|
50
|
+
AssetDatabase.StopAssetEditing();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
///
|
|
56
|
+
/// </summary>
|
|
57
|
+
protected virtual void SetAllOfReactionType()
|
|
58
|
+
{
|
|
59
|
+
using var stringReader = new StringReader(textArea);
|
|
60
|
+
|
|
61
|
+
string line;
|
|
62
|
+
|
|
63
|
+
while ((line = stringReader.ReadLine()) != null)
|
|
64
|
+
if (MatchedIDs(line))
|
|
65
|
+
ApplyMatchedNames(Regex.Split(line, splitLineRegex));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
///
|
|
70
|
+
/// </summary>
|
|
71
|
+
/// <param name="line"></param>
|
|
72
|
+
/// <returns></returns>
|
|
73
|
+
protected virtual bool MatchedIDs(string line)
|
|
74
|
+
{
|
|
75
|
+
idMatches = CollectIDs(Regex.Split(line, anyNumberRegex));
|
|
76
|
+
|
|
77
|
+
return idMatches != null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
/// <param name="nameMatches"></param>
|
|
84
|
+
protected virtual void ApplyMatchedNames(string[] nameMatches)
|
|
85
|
+
{
|
|
86
|
+
for (int i = 0; i < nameMatches.Length; i++)
|
|
87
|
+
if (i == 0 || TotalFailedMatch(nameMatches[i]))
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// <summary>
|
|
92
|
+
///
|
|
93
|
+
/// </summary>
|
|
94
|
+
/// <param name="tryMatch"></param>
|
|
95
|
+
/// <returns></returns>
|
|
96
|
+
protected virtual bool TotalFailedMatch(string tryMatch)
|
|
97
|
+
{
|
|
98
|
+
var nameMatch = tryMatch.Replace(",", "");
|
|
99
|
+
|
|
100
|
+
if (FailedMatch(nameMatch))
|
|
101
|
+
return true;
|
|
102
|
+
else
|
|
103
|
+
PassedMatch(nameMatch);
|
|
104
|
+
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
///
|
|
110
|
+
/// </summary>
|
|
111
|
+
/// <param name="nameMatch"></param>
|
|
112
|
+
/// <returns></returns>
|
|
113
|
+
protected virtual bool FailedMatch(string nameMatch)
|
|
114
|
+
{
|
|
115
|
+
if (nameMatch == "")
|
|
116
|
+
return true;
|
|
117
|
+
else
|
|
118
|
+
UnityEngine.Debug.Log("REPORT: Name Matched: " + nameMatch);
|
|
119
|
+
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
///
|
|
125
|
+
/// </summary>
|
|
126
|
+
/// <param name="nameMatch"></param>
|
|
127
|
+
protected virtual void PassedMatch(string nameMatch)
|
|
128
|
+
{
|
|
129
|
+
if (presentDatabase.GetPresentByID(idMatches[0]) is Present present)
|
|
130
|
+
ApplyReactions(present, nameMatch);
|
|
131
|
+
else
|
|
132
|
+
UnityEngine.Debug.LogWarning("ALERT: Couldn't Find Present With ID: " + idMatches[0]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
#endif
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Characters;
|
|
4
|
+
using System;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Presents.Editor
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[Serializable]
|
|
14
|
+
public class ReactionByIDOption : ReactionImportOption
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
[Header("")]
|
|
20
|
+
[Divider]
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected Character character;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/// <inheritdoc/>
|
|
26
|
+
public override void Invoke() => SetReactionByID();
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
protected virtual void SetReactionByID()
|
|
32
|
+
{
|
|
33
|
+
List<int> ids = GetListOfIDs();
|
|
34
|
+
|
|
35
|
+
foreach (int id in ids)
|
|
36
|
+
SetReaction(id);
|
|
37
|
+
|
|
38
|
+
Close();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
/// <param name="id"></param>
|
|
45
|
+
protected virtual void SetReaction(int id)
|
|
46
|
+
{
|
|
47
|
+
if (presentDatabase.GetPresentByID(id) is Present present)
|
|
48
|
+
ApplyReactions(present, character.FirstName);
|
|
49
|
+
else
|
|
50
|
+
UnityEngine.Debug.LogWarning("ALERT: Couldn't Find Present With ID: " + id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
#endif
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Items;
|
|
4
|
+
using DREditor.Editor.Utility;
|
|
5
|
+
using System;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
|
|
9
|
+
namespace DREditor.Presents.Editor
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
[Serializable]
|
|
15
|
+
public abstract class ReactionImportOption : PresentImportOptionBase
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected ReactionLevelDatabase reactionDatabase;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected int reactionLevel;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/// <inheritdoc/>
|
|
31
|
+
protected override void InitializeDatabases()
|
|
32
|
+
{
|
|
33
|
+
base.InitializeDatabases();
|
|
34
|
+
|
|
35
|
+
reactionDatabase = DatabaseUtility.LoadDatabase<ReactionLevelDatabase>();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// <inheritdoc/>
|
|
39
|
+
protected override bool InitializationFailed() => base.InitializationFailed() || ReactionIndexInvalid();
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
/// <returns></returns>
|
|
45
|
+
protected virtual bool ReactionIndexInvalid()
|
|
46
|
+
{
|
|
47
|
+
bool result = reactionDatabase != null && !reactionDatabase.ReactionIndexValid(reactionLevel);
|
|
48
|
+
|
|
49
|
+
if (result)
|
|
50
|
+
UnityEngine.Debug.LogWarning("ALERT: Database missing or the reaction index inputted was not " +
|
|
51
|
+
"a valid one within the reaction database." +
|
|
52
|
+
"\nPROPOSAL: Ensure the index of the reaction you're using is valid.");
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
/// <param name="InventoryItem"></param>
|
|
62
|
+
/// <param name="matchingName"></param>
|
|
63
|
+
protected virtual void ApplyReactions(InventoryItem InventoryItem, string matchingName)
|
|
64
|
+
{
|
|
65
|
+
if (InventoryItem is Present present)
|
|
66
|
+
foreach (var data in present.attributes)
|
|
67
|
+
if (data is StudentReactionCollection collection)
|
|
68
|
+
collection.SetReaction(matchingName, reactionLevel);
|
|
69
|
+
|
|
70
|
+
EditorUtility.SetDirty(InventoryItem);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
#endif
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Presents.Editor
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
public class ReactionImporter : ScriptableWizard
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[SelectType]
|
|
17
|
+
[SerializeReference]
|
|
18
|
+
[Tooltip("")]
|
|
19
|
+
[SerializeField] protected PresentImportOptionBase importOption;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
protected bool exitEarly = false;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
[MenuItem("DREditor/Import/FTE/Present Reactions")]
|
|
29
|
+
public static void SpawnWizard() => DisplayWizard<ReactionImporter>("Reaction Importer", "Apply");
|
|
30
|
+
|
|
31
|
+
protected virtual void OnWizardCreate()
|
|
32
|
+
{
|
|
33
|
+
importOption.Initialize(CloseWindowEarly);
|
|
34
|
+
|
|
35
|
+
if (exitEarly)
|
|
36
|
+
return;
|
|
37
|
+
|
|
38
|
+
importOption.Invoke();
|
|
39
|
+
|
|
40
|
+
if (exitEarly)
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
UnityEngine.Debug.Log("REPORT: Option Invocation Process Completed.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
protected virtual void CloseWindowEarly()
|
|
50
|
+
{
|
|
51
|
+
exitEarly = true;
|
|
52
|
+
|
|
53
|
+
UnityEngine.Debug.Log("REPORT: Aborted Active Wizard.");
|
|
54
|
+
|
|
55
|
+
Close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
#endif
|