portals and dash. Also a bit of terrain building and level design
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e6cf49ae4faced43a3455211e94cdf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
//[CreateAssetMenu(menuName = "Griffin/Backup Data")]
|
||||
public class GBackupData : ScriptableObject
|
||||
{
|
||||
private static GBackupData instance;
|
||||
public static GBackupData Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
instance = Resources.Load<GBackupData>("GriffinBackupData");
|
||||
#endif
|
||||
if (instance == null)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<GBackupData>();
|
||||
}
|
||||
//instance.hideFlags = HideFlags.DontSaveInBuild;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<GHistoryEntry> historyEntries;
|
||||
public List<GHistoryEntry> HistoryEntries
|
||||
{
|
||||
get
|
||||
{
|
||||
if (historyEntries == null)
|
||||
{
|
||||
historyEntries = new List<GHistoryEntry>();
|
||||
}
|
||||
return historyEntries;
|
||||
}
|
||||
set
|
||||
{
|
||||
historyEntries = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d0c634e26e75ac4599b6db3e923cfd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,263 @@
|
||||
#if GRIFFIN
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
public static class GBackupFile
|
||||
{
|
||||
public const string DIRECTORY = "GriffinBackup";
|
||||
public const string INITIAL_HISTORY_PREFIX = "Begin";
|
||||
public const string EXTENSION = ".gbackup";
|
||||
public const string ALBEDO_R_SUFFIX = "albedo_r";
|
||||
public const string ALBEDO_G_SUFFIX = "albedo_g";
|
||||
public const string ALBEDO_B_SUFFIX = "albedo_b";
|
||||
public const string ALBEDO_A_SUFFIX = "albedo_a";
|
||||
public const string METALLIC_SUFFIX = "metallic";
|
||||
public const string SMOOTHNESS_SUFFIX = "smoothness";
|
||||
public const string CONTROL_R_SUFFIX = "control_r";
|
||||
public const string CONTROL_G_SUFFIX = "control_g";
|
||||
public const string CONTROL_B_SUFFIX = "control_b";
|
||||
public const string CONTROL_A_SUFFIX = "control_a";
|
||||
public const string TREE_SUFFIX = "tree";
|
||||
public const string GRASS_SUFFIX = "grass";
|
||||
public const string PROTOTYPEINDEX_SUFFIX = "protoindex";
|
||||
public const string POSITION_SUFFIX = "position";
|
||||
public const string ROTATION_SUFFIX = "rotation";
|
||||
public const string SCALE_SUFFIX = "scale";
|
||||
|
||||
public const string HEIGHT_R_SUFFIX = "heightmap_r";
|
||||
public const string HEIGHT_G_SUFFIX = "heightmap_g";
|
||||
public const string HEIGHT_B_SUFFIX = "heightmap_b";
|
||||
public const string HEIGHT_A_SUFFIX = "heightmap_a";
|
||||
|
||||
public const string MASK_R_SUFFIX = "maskmap_r";
|
||||
public const string MASK_G_SUFFIX = "maskmap_g";
|
||||
public const string MASK_B_SUFFIX = "maskmap_b";
|
||||
public const string MASK_A_SUFFIX = "maskmap_a";
|
||||
|
||||
private static string GetRootDirectory()
|
||||
{
|
||||
string assetsFolder = Application.dataPath;
|
||||
string projectFolder = Directory.GetParent(assetsFolder).FullName;
|
||||
return Path.Combine(projectFolder, DIRECTORY);
|
||||
}
|
||||
|
||||
public static string GetFileDirectory(string backupName)
|
||||
{
|
||||
return Path.Combine(GetRootDirectory(), backupName);
|
||||
}
|
||||
|
||||
public static string GetFilePath(string backupName, string fileNameNoExt)
|
||||
{
|
||||
return Path.Combine(GetFileDirectory(backupName), fileNameNoExt + EXTENSION);
|
||||
}
|
||||
|
||||
public static bool Exist(string backupName, string fileNameNoExt)
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GHistoryEntry entry = GetHistoryEntry(backupName);
|
||||
if (entry == null)
|
||||
return false;
|
||||
GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Equals(fileNameNoExt));
|
||||
return buffer != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = GetFilePath(backupName, fileNameNoExt);
|
||||
return File.Exists(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HistoryContainsDataForTerrain(string backupName, string terrainId)
|
||||
{
|
||||
GHistoryEntry entry = GetHistoryEntry(backupName);
|
||||
if (entry == null)
|
||||
return false;
|
||||
GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Contains(terrainId));
|
||||
return buffer != null;
|
||||
}
|
||||
|
||||
public static string Create(string backupName, string fileNameNoExt, byte[] data)
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GHistoryEntry entry = EnsureHistoryEntryExists(backupName);
|
||||
GHistoryBuffer buffer = new GHistoryBuffer(fileNameNoExt, data);
|
||||
entry.Buffers.Add(buffer);
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUtilities.EnsureDirectoryExists(Path.Combine(GetRootDirectory(), backupName));
|
||||
string filePath = GetFilePath(backupName, fileNameNoExt);
|
||||
File.WriteAllBytes(filePath, data);
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
|
||||
private static GHistoryEntry EnsureHistoryEntryExists(string backupName)
|
||||
{
|
||||
GHistoryEntry entry = GetHistoryEntry(backupName);
|
||||
if (entry == null)
|
||||
{
|
||||
entry = new GHistoryEntry(backupName);
|
||||
GBackupData.Instance.HistoryEntries.Add(entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
private static GHistoryEntry GetHistoryEntry(string backupName)
|
||||
{
|
||||
return GBackupData.Instance.HistoryEntries.Find(e => e.Name.Equals(backupName));
|
||||
}
|
||||
|
||||
public static string[] GetAllFilePaths(string backupName)
|
||||
{
|
||||
List<string> files = new List<string>(Directory.GetFiles(GetFileDirectory(backupName)));
|
||||
files.RemoveAll(f => !f.EndsWith(EXTENSION));
|
||||
return files.ToArray();
|
||||
}
|
||||
|
||||
public static void SetBackupCreationTime(string backupName, System.DateTime time)
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GHistoryEntry entry = GetHistoryEntry(backupName);
|
||||
if (entry != null)
|
||||
{
|
||||
entry.CreationTime = time;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string folder = GetFileDirectory(backupName);
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
Directory.SetCreationTime(folder, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static System.DateTime GetBackupCreationTime(string backupName)
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GHistoryEntry entry = GetHistoryEntry(backupName);
|
||||
if (entry != null)
|
||||
{
|
||||
return entry.CreationTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
return System.DateTime.MaxValue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string folder = GetFileDirectory(backupName);
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
return Directory.GetCreationTime(folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
return System.DateTime.MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] GetAllBackupNames()
|
||||
{
|
||||
GUtilities.EnsureDirectoryExists(GetRootDirectory());
|
||||
List<string> names = new List<string>(Directory.GetDirectories(GetRootDirectory()));
|
||||
for (int i = 0; i < names.Count; ++i)
|
||||
{
|
||||
names[i] = Path.GetFileNameWithoutExtension(names[i]);
|
||||
}
|
||||
names.Sort((b0, b1) =>
|
||||
{
|
||||
return GBackupFile.GetBackupCreationTime(b0).CompareTo(GBackupFile.GetBackupCreationTime(b1));
|
||||
});
|
||||
|
||||
List<GHistoryEntry> historyEntries = GBackupData.Instance.HistoryEntries;
|
||||
for (int i = 0; i < historyEntries.Count; ++i)
|
||||
{
|
||||
names.Add(historyEntries[i].Name);
|
||||
}
|
||||
|
||||
return names.ToArray();
|
||||
}
|
||||
|
||||
public static void Delete(string backupName)
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GBackupData.Instance.HistoryEntries.RemoveAll(e => e.Name.Equals(backupName));
|
||||
}
|
||||
else
|
||||
{
|
||||
string folder = GetFileDirectory(backupName);
|
||||
if (Directory.Exists(folder))
|
||||
{
|
||||
Directory.Delete(folder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] ReadAllBytes(string backupName, string fileNameNoExtension)
|
||||
{
|
||||
if (Exist(backupName, fileNameNoExtension))
|
||||
{
|
||||
if (backupName.StartsWith("~"))
|
||||
{
|
||||
GHistoryEntry entry = GBackupData.Instance.HistoryEntries.Find(e => e.Name.Equals(backupName));
|
||||
GHistoryBuffer buffer = entry.Buffers.Find(b => b.Name.Equals(fileNameNoExtension));
|
||||
return buffer.Bytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
return File.ReadAllBytes(GetFilePath(backupName, fileNameNoExtension));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetBackupNameByTimeNow()
|
||||
{
|
||||
System.DateTime d = System.DateTime.Now;
|
||||
string s = string.Format("{0}{1}{2}{3}{4}{5}", d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void ClearHistory()
|
||||
{
|
||||
string[] backupNames = GetAllBackupNames();
|
||||
for (int i = 0; i < backupNames.Length; ++i)
|
||||
{
|
||||
if (backupNames[i].StartsWith("~"))
|
||||
{
|
||||
Delete(backupNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetInitialHistoryPrefix(string prefixWithoutWaveSymbol)
|
||||
{
|
||||
return string.Format("~{0} {1}", INITIAL_HISTORY_PREFIX, prefixWithoutWaveSymbol);
|
||||
}
|
||||
|
||||
public static string GetHistoryPrefix(string prefixWithoutWaveSymbol)
|
||||
{
|
||||
return string.Format("~{0}", prefixWithoutWaveSymbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2d72582ae295994fa1f96e6ecb17ab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
#if GRIFFIN
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
public static class GBackupInternal
|
||||
{
|
||||
public static string TryCreateAndMergeInitialBackup(string historyPrefix, List<GStylizedTerrain> terrains, List<GTerrainResourceFlag> flags, bool showProgess = true)
|
||||
{
|
||||
if (terrains.Count == 0)
|
||||
return null;
|
||||
string backupName = GBackup.TryCreateInitialBackup(historyPrefix, terrains[0], flags, showProgess);
|
||||
if (!string.IsNullOrEmpty(backupName))
|
||||
{
|
||||
for (int i = 1; i < terrains.Count; ++i)
|
||||
{
|
||||
GBackup.BackupTerrain(terrains[i], backupName, flags);
|
||||
}
|
||||
}
|
||||
return backupName;
|
||||
}
|
||||
|
||||
public static string TryCreateAndMergeBackup(string historyPrefix, List<GStylizedTerrain> terrains, List<GTerrainResourceFlag> flags, bool showProgress = true)
|
||||
{
|
||||
if (terrains.Count == 0)
|
||||
return null;
|
||||
string backupName = GBackup.TryCreateBackup(historyPrefix, terrains[0], flags, showProgress);
|
||||
if (!string.IsNullOrEmpty(backupName))
|
||||
{
|
||||
for (int i = 1; i < terrains.Count; ++i)
|
||||
{
|
||||
GBackup.BackupTerrain(terrains[i], backupName, flags);
|
||||
}
|
||||
}
|
||||
return backupName;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c489d7a0d42e0c54b970f16c116f49a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct GBackupToolSettings
|
||||
{
|
||||
//[SerializeField]
|
||||
//private bool dontClearHistoryOnEditorExit;
|
||||
//public bool DontClearHistoryOnEditorExit
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return dontClearHistoryOnEditorExit;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// dontClearHistoryOnEditorExit = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
[SerializeField]
|
||||
private int bufferSizeMB;
|
||||
public int BufferSizeMB
|
||||
{
|
||||
get
|
||||
{
|
||||
return bufferSizeMB;
|
||||
}
|
||||
set
|
||||
{
|
||||
bufferSizeMB = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d43fa27c8e41ede478e374dbd40a79ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
[System.Serializable]
|
||||
public class GHistoryBuffer
|
||||
{
|
||||
[SerializeField]
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private byte[] bytes;
|
||||
public byte[] Bytes
|
||||
{
|
||||
get
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
set
|
||||
{
|
||||
bytes = value;
|
||||
}
|
||||
}
|
||||
|
||||
public GHistoryBuffer(string bufferName, byte[] data)
|
||||
{
|
||||
name = bufferName;
|
||||
bytes = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3805b92c5b9abb84885810b464c1c877
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
#if GRIFFIN
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DateTime = System.DateTime;
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
[System.Serializable]
|
||||
public class GHistoryEntry
|
||||
{
|
||||
[SerializeField]
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private DateTime creationTime;
|
||||
public DateTime CreationTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return creationTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
creationTime = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<GHistoryBuffer> buffers;
|
||||
public List<GHistoryBuffer> Buffers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (buffers == null)
|
||||
{
|
||||
buffers = new List<GHistoryBuffer>();
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
set
|
||||
{
|
||||
buffers = value;
|
||||
}
|
||||
}
|
||||
|
||||
public GHistoryEntry(string n)
|
||||
{
|
||||
name = n;
|
||||
creationTime = DateTime.Now;
|
||||
buffers = new List<GHistoryBuffer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e798d06c788fc8c449adc0066940f76b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
#if GRIFFIN
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Pinwheel.Griffin.BackupTool
|
||||
{
|
||||
//[CreateAssetMenu(fileName = "UndoCompatibleBuffer", menuName = "Griffin/Undo Compatible Buffer")]
|
||||
public class GUndoCompatibleBuffer : ScriptableObject
|
||||
{
|
||||
private static GUndoCompatibleBuffer instance;
|
||||
public static GUndoCompatibleBuffer Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
instance = Resources.Load<GUndoCompatibleBuffer>("UndoCompatibleBuffer");
|
||||
#endif
|
||||
if (instance == null)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<GUndoCompatibleBuffer>();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private string currentBackupName;
|
||||
public string CurrentBackupName
|
||||
{
|
||||
get
|
||||
{
|
||||
return currentBackupName;
|
||||
}
|
||||
set
|
||||
{
|
||||
currentBackupName = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Undo.willFlushUndoRecord += OnWillUndoFlush;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Undo.willFlushUndoRecord -= OnWillUndoFlush;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void RecordUndo()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Undo.RegisterCompleteObjectUndo(this, "Terrain Editing");
|
||||
Undo.IncrementCurrentGroup();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnWillUndoFlush()
|
||||
{
|
||||
CurrentBackupName = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2aedad9cacd3b54996f2e6ef60fcff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user