net.dreditor.saveables 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.Saveables.asmdef +16 -0
- package/DREditor.Saveables.asmdef.meta +7 -0
- package/ISaveManager.cs +59 -0
- package/ISaveManager.cs.meta +11 -0
- package/ManagerData.cs +53 -0
- package/ManagerData.cs.meta +11 -0
- package/ManagerDataSet.cs +43 -0
- package/ManagerDataSet.cs.meta +11 -0
- package/Samples/Save_Managers_Handler.prefab +49 -0
- package/Samples/Save_Managers_Handler.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/SaveManagersHandler.cs +69 -0
- package/SaveManagersHandler.cs.meta +11 -0
- package/package.json +34 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Saveables",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"DREditor"
|
|
6
|
+
],
|
|
7
|
+
"includePlatforms": [],
|
|
8
|
+
"excludePlatforms": [],
|
|
9
|
+
"allowUnsafeCode": false,
|
|
10
|
+
"overrideReferences": false,
|
|
11
|
+
"precompiledReferences": [],
|
|
12
|
+
"autoReferenced": true,
|
|
13
|
+
"defineConstraints": [],
|
|
14
|
+
"versionDefines": [],
|
|
15
|
+
"noEngineReferences": false
|
|
16
|
+
}
|
package/ISaveManager.cs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.Saveables
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
/// <remarks></remarks>
|
|
10
|
+
public interface ISaveManager
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
int SubID { get; }
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
/// <returns></returns>
|
|
22
|
+
string Save();
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
/// <param name="data"></param>
|
|
28
|
+
void Load(string data);
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
/// <returns></returns>
|
|
34
|
+
List<string> GetPreviousNames();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// NOTE: Another issue with the Savables structure is that this structure is harder to extend and may not be super useful.
|
|
38
|
+
// NOTE: As of writing this the only topics that use this are The UISpriteCharacterSwapper and Maps data.
|
|
39
|
+
// Honestly, this system should be removed. Updating how maps are saved should be investigated.
|
|
40
|
+
// NOTE: Issue with the Save Manager structure: If you rename something after a save files been made
|
|
41
|
+
// the game won't be able to load that data because the save is by the name of the class.
|
|
42
|
+
/* The ISaveManager is designed to make managers to dynamically save data by transfering it to data strings and
|
|
43
|
+
* being able to load it whenever one needs it etc.
|
|
44
|
+
public class Manager : ISaveManager
|
|
45
|
+
{
|
|
46
|
+
|
|
47
|
+
public int SubID { get => subID; }
|
|
48
|
+
[SerializeField] int subID;
|
|
49
|
+
public string Save()
|
|
50
|
+
{
|
|
51
|
+
return JsonUtility.ToJson(InstanceData);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public void Load(string data)
|
|
55
|
+
{
|
|
56
|
+
InstanceData = JsonUtility.FromJson<MapData>(data);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
*/
|
package/ManagerData.cs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine.Serialization;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Saveables
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
/// <remarks></remarks>
|
|
12
|
+
[Serializable]
|
|
13
|
+
public class ManagerData
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
[FormerlySerializedAs("DataList")]
|
|
19
|
+
public List<ManagerDataSet> dataSets = new();
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <returns></returns>
|
|
26
|
+
public virtual bool HasDuplicate()
|
|
27
|
+
{
|
|
28
|
+
foreach (var item in dataSets)
|
|
29
|
+
foreach (var info in dataSets)
|
|
30
|
+
if (item != info && SetsMatch(item, info))
|
|
31
|
+
return true;
|
|
32
|
+
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
/// <param name="setOne"></param>
|
|
40
|
+
/// <param name="setTwo"></param>
|
|
41
|
+
/// <returns></returns>
|
|
42
|
+
protected virtual bool SetsMatch(ManagerDataSet setOne, ManagerDataSet setTwo)
|
|
43
|
+
{
|
|
44
|
+
bool result = setOne.subID == setTwo.subID && setOne.typeName == setTwo.typeName;
|
|
45
|
+
|
|
46
|
+
UnityEngine.Debug.LogWarning("2 Managers of type : " + setOne.GetType().Name +
|
|
47
|
+
" . Contain the same SubIDs! This is not allowed because otherwise the " +
|
|
48
|
+
"ISaveManager will not load Save Data Correctly!");
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.Saveables
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
/// <remarks></remarks>
|
|
10
|
+
[Serializable]
|
|
11
|
+
public class ManagerDataSet
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
public int subID;
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
public string data;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
public string typeName;
|
|
27
|
+
|
|
28
|
+
public ManagerDataSet(ISaveManager manager)
|
|
29
|
+
{
|
|
30
|
+
if (manager != null)
|
|
31
|
+
{
|
|
32
|
+
subID = manager.SubID;
|
|
33
|
+
|
|
34
|
+
data = manager.Save();
|
|
35
|
+
|
|
36
|
+
typeName = manager.GetType().Name;
|
|
37
|
+
}
|
|
38
|
+
else
|
|
39
|
+
UnityEngine.Debug.Log($"REPORT: Logging notice of manager data set without interface." +
|
|
40
|
+
$"\nSPECULATION: It is likely an old save file is present.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
%YAML 1.1
|
|
2
|
+
%TAG !u! tag:unity3d.com,2011:
|
|
3
|
+
--- !u!1 &1435333383496617487
|
|
4
|
+
GameObject:
|
|
5
|
+
m_ObjectHideFlags: 0
|
|
6
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
7
|
+
m_PrefabInstance: {fileID: 0}
|
|
8
|
+
m_PrefabAsset: {fileID: 0}
|
|
9
|
+
serializedVersion: 6
|
|
10
|
+
m_Component:
|
|
11
|
+
- component: {fileID: 1435333383496617480}
|
|
12
|
+
- component: {fileID: 1435333383496617481}
|
|
13
|
+
m_Layer: 0
|
|
14
|
+
m_Name: Save_Managers_Handler
|
|
15
|
+
m_TagString: Untagged
|
|
16
|
+
m_Icon: {fileID: 0}
|
|
17
|
+
m_NavMeshLayer: 0
|
|
18
|
+
m_StaticEditorFlags: 0
|
|
19
|
+
m_IsActive: 1
|
|
20
|
+
--- !u!4 &1435333383496617480
|
|
21
|
+
Transform:
|
|
22
|
+
m_ObjectHideFlags: 0
|
|
23
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
24
|
+
m_PrefabInstance: {fileID: 0}
|
|
25
|
+
m_PrefabAsset: {fileID: 0}
|
|
26
|
+
m_GameObject: {fileID: 1435333383496617487}
|
|
27
|
+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
28
|
+
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
29
|
+
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
30
|
+
m_ConstrainProportionsScale: 0
|
|
31
|
+
m_Children: []
|
|
32
|
+
m_Father: {fileID: 0}
|
|
33
|
+
m_RootOrder: 0
|
|
34
|
+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
35
|
+
--- !u!114 &1435333383496617481
|
|
36
|
+
MonoBehaviour:
|
|
37
|
+
m_ObjectHideFlags: 0
|
|
38
|
+
m_CorrespondingSourceObject: {fileID: 0}
|
|
39
|
+
m_PrefabInstance: {fileID: 0}
|
|
40
|
+
m_PrefabAsset: {fileID: 0}
|
|
41
|
+
m_GameObject: {fileID: 1435333383496617487}
|
|
42
|
+
m_Enabled: 1
|
|
43
|
+
m_EditorHideFlags: 0
|
|
44
|
+
m_Script: {fileID: 11500000, guid: 2e5482539302a674c942368d0724f457, type: 3}
|
|
45
|
+
m_Name:
|
|
46
|
+
m_EditorClassIdentifier:
|
|
47
|
+
registerService: 1
|
|
48
|
+
dontDestroyOnLoad: 0
|
|
49
|
+
saveKey: ManagerData
|
package/Samples.meta
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Saving;
|
|
3
|
+
using DREditor.Services;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Saveables
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(ServiceHolder<SaveManagersHandler>) + " for type: " + nameof(SaveManagersHandler) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class SaveManagersHandler : ServiceHolder<SaveManagersHandler>, IDRESaveable, IDRELoadableManager
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Tooltip("")]
|
|
21
|
+
[SerializeField] protected string saveKey = "ManagerData";
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
/// <param name="data"></param>
|
|
27
|
+
protected virtual void LoadManagerData(ManagerData data)
|
|
28
|
+
{
|
|
29
|
+
if (data == null)
|
|
30
|
+
return;
|
|
31
|
+
|
|
32
|
+
var list = FindObjectsByType<MonoBehaviour>().OfType<ISaveManager>();
|
|
33
|
+
|
|
34
|
+
foreach (var item in list)
|
|
35
|
+
foreach (var info in data.dataSets)
|
|
36
|
+
if (info.subID == item.SubID &&
|
|
37
|
+
(item.GetType().Name == info.typeName || item.GetPreviousNames().Contains(info.typeName)))
|
|
38
|
+
item.Load(info.data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
/// <returns></returns>
|
|
45
|
+
protected virtual ManagerData CreateManagerData()
|
|
46
|
+
{
|
|
47
|
+
ManagerData data = new();
|
|
48
|
+
|
|
49
|
+
var list = FindObjectsByType<MonoBehaviour>().OfType<ISaveManager>();
|
|
50
|
+
|
|
51
|
+
foreach (var manager in list)
|
|
52
|
+
if (manager != null)
|
|
53
|
+
data.dataSets.Add(new ManagerDataSet(manager));
|
|
54
|
+
|
|
55
|
+
data.HasDuplicate();
|
|
56
|
+
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/// <inheritdoc/>
|
|
62
|
+
public virtual void Save(Dictionary<string, object> saveData)
|
|
63
|
+
=> saveData.Set(saveKey, CreateManagerData());
|
|
64
|
+
|
|
65
|
+
/// <inheritdoc/>
|
|
66
|
+
public virtual void LoadManager(Dictionary<string, object> saveDatas, bool inChapterSelect)
|
|
67
|
+
=> LoadManagerData(saveDatas.Get<ManagerData>(saveKey));
|
|
68
|
+
}
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "net.dreditor.saveables",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "net.dreditor.saveables",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"displayName": "DREditor Saveables",
|
|
5
|
+
"description": "The beta for DREditor. A tool to create death game style projects without having to code.",
|
|
6
|
+
"unity": "6000.4",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"net.dreditor.core": "0.1.6"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Benjamin \"Sweden\" Jillson",
|
|
15
|
+
"email": "dreditortool@gmail.com",
|
|
16
|
+
"url": "https://dreditor.net"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"editor",
|
|
20
|
+
"tool",
|
|
21
|
+
"dreditor"
|
|
22
|
+
],
|
|
23
|
+
"samples": [
|
|
24
|
+
{
|
|
25
|
+
"displayName": "Samples",
|
|
26
|
+
"description": "",
|
|
27
|
+
"path": "Samples~"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"documentationUrl": "https://dreditor.net",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"licensesUrl": "https://dreditor.net/docs/LICENSE.html",
|
|
33
|
+
"changelogUrl": "https://dreditor.net/docs/CHANGELOG.html"
|
|
34
|
+
}
|
package/README.md
DELETED