Initial commit

This commit is contained in:
gunnbr committed 2021-01-11 22:20:43 -08:00
1 parent ee9615239e
commit 16feac691f
4093 files changed
+1030491

No files matched your search

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class ClearOperationSettings : ScriptableObject
{
#region public input variables
public bool m_clearTrees;
public bool m_clearTerrainDetails;
public bool m_clearGameObjects;
public bool m_clearSpawnExtensions;
public bool m_clearProbes;
public bool m_clearStamps;
public ClearSpawnFrom m_clearSpawnFrom;
public ClearSpawnFor m_clearSpawnFor;
public SpawnerSettings m_spawnerSettings;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b6c6e2812e73b674b85b77fb46a715b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class ExportMaskMapOperationSettings : ScriptableObject
{
#region public input variables
/// <summary>
/// Holds the mask map exporter settings used for the export op.
/// </summary>
public MaskMapExportSettings m_maskMapExportSettings;
/// <summary>
/// The terrain names which were exported from.
/// </summary>
public List<string> m_terrainNames = new List<string>();
/// <summary>
/// Whether the export op was global or not. Global means the export will be done per each terrain, local means the epxort will be performed with a fixed range in a fixed location.
/// </summary>
public bool isGlobalExport = false;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94574573407af4f43bbc13d8f1b040e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class FlattenOperationSettings : ScriptableObject
{
#region public input variables
/// <summary>
/// List of all the Terrains that need to be flattened.
/// </summary>
public List<string> m_TerrainsList;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36b46b5874ce3b84a9c90d9efecd582b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,229 @@
using UnityEngine;
using System.Collections;
using System;
using UnityEditor;
namespace Gaia
{
public enum SessionPlaybackState {Queued, Started }
/// <summary>
/// A gaia operation - serialises and deserialises and executes a gaia operation
/// </summary>
[System.Serializable]
public class GaiaOperation
{
/// <summary>
/// Settings for a world creation operation
/// </summary>
private WorldCreationSettings m_worldCreationSettings = null;
public WorldCreationSettings WorldCreationSettings
{
get {
if (m_worldCreationSettings == null)
{
#if UNITY_EDITOR
m_worldCreationSettings = (WorldCreationSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(WorldCreationSettings));
#endif
}
return m_worldCreationSettings;
}
}
private StamperSettings m_stamperSettings = null;
public StamperSettings StamperSettings
{
get
{
if (m_stamperSettings == null)
{
#if UNITY_EDITOR
m_stamperSettings = (StamperSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(StamperSettings));
#endif
}
return m_stamperSettings;
}
}
private SpawnOperationSettings m_spawnOperationSettings = null;
public SpawnOperationSettings SpawnOperationSettings
{
get
{
if (m_spawnOperationSettings == null)
{
#if UNITY_EDITOR
m_spawnOperationSettings = (SpawnOperationSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(SpawnOperationSettings));
#endif
}
return m_spawnOperationSettings;
}
}
private FlattenOperationSettings m_flattenOperationSettings = null;
public FlattenOperationSettings FlattenOperationSettings
{
get
{
if (m_flattenOperationSettings == null)
{
#if UNITY_EDITOR
m_flattenOperationSettings = (FlattenOperationSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(FlattenOperationSettings));
#endif
}
return m_flattenOperationSettings;
}
}
private UndoRedoOperationSettings m_undoRedoOperationSettings = null;
public UndoRedoOperationSettings UndoRedoOperationSettings {
get
{
if (m_undoRedoOperationSettings == null)
{
#if UNITY_EDITOR
m_undoRedoOperationSettings = (UndoRedoOperationSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(UndoRedoOperationSettings));
#endif
}
return m_undoRedoOperationSettings;
}
}
private ClearOperationSettings m_clearOperationSettings = null;
public ClearOperationSettings ClearOperationSettings
{
get
{
if (m_clearOperationSettings == null)
{
#if UNITY_EDITOR
m_clearOperationSettings = (ClearOperationSettings) AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(ClearOperationSettings));
#endif
}
return m_clearOperationSettings;
}
}
private RemoveNonBiomeResourcesSettings m_removeNonBiomeResourcesSettings = null;
public RemoveNonBiomeResourcesSettings RemoveNonBiomeResourcesSettings
{
get
{
if (m_removeNonBiomeResourcesSettings == null)
{
#if UNITY_EDITOR
m_removeNonBiomeResourcesSettings = (RemoveNonBiomeResourcesSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(RemoveNonBiomeResourcesSettings));
#endif
}
return m_removeNonBiomeResourcesSettings;
}
}
private ExportMaskMapOperationSettings m_exportMaskMapOperationSettings = null;
public ExportMaskMapOperationSettings ExportMaskMapOperationSettings
{
get
{
if (m_exportMaskMapOperationSettings == null)
{
#if UNITY_EDITOR
m_exportMaskMapOperationSettings = (ExportMaskMapOperationSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(ExportMaskMapOperationSettings));
#endif
}
return m_exportMaskMapOperationSettings;
}
}
private ScriptableObject m_externalScriptableObject = null;
public ScriptableObject ExternalOperationScriptableObject
{
get
{
if (m_externalScriptableObject == null)
{
#if UNITY_EDITOR
m_externalScriptableObject = (ScriptableObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(scriptableObjectAssetGUID), typeof(ScriptableObject));
#endif
}
return m_externalScriptableObject;
}
}
/// <summary>
/// An optional description
/// </summary>
public string m_description;
/// <summary>
/// The types of operations we can record
/// </summary>
public enum OperationType { CreateWorld, FlattenTerrain, SmoothTerrain, ClearSpawns, Stamp, StampUndo, StampRedo, Spawn, RemoveNonBiomeResources,
MaskMapExport,
ClearWorld,
ExportWorldMapToLocalMap,
External
}
/// <summary>
/// The operation type
/// </summary>
public OperationType m_operationType;
/// <summary>
/// Whether or not the operation is active
/// </summary>
public bool m_isActive = true;
///// <summary>
///// The name of the object that generated this operation
///// </summary>
//public string m_generatedByName;
///// <summary>
///// The ID of the onject that generated this operation
///// </summary>
//public string m_generatedByID;
///// <summary>
///// The type of object that generated this operation
///// </summary>
//public string m_generatedByType;
/// <summary>
/// The list of terrains affected by this operation.
/// </summary>
public string[] m_affectedTerrainNames = new string[0];
/// <summary>
/// When the operation was recorded
/// </summary>
public string m_operationDateTime = DateTime.Now.ToString();
/// <summary>
/// GUID for the scriptable object that holds the actual settings data for the operation
/// </summary>
public string scriptableObjectAssetGUID;
/// <summary>
/// Whether or not we are folded out in the editor
/// </summary>
public bool m_isFoldedOut = false;
public SessionPlaybackState sessionPlaybackState = SessionPlaybackState.Started;
/// <summary>
/// Whether the affected terrains section on the GUI is folded out or not
/// </summary>
public bool m_terrainsFoldedOut;
/// <summary>
/// Holds data from a serialized external action that was saved in the session.
/// </summary>
public byte[] m_serializedExternalAction;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5597a33c6795ff141a5bfd21c7ebc35a
timeCreated: 1540452170
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b7460de6193629443b952f9e783185bd, type: 3}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,205 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Gaia
{
/// <summary>
/// Class to cache the minimum - maximum physical height of a terrain
/// </summary>
[System.Serializable]
public class TerrainMinMaxHeight
{
public string guid;
public bool isWorldmap = false;
public bool recalculate = false;
public float min;
public float max;
}
/// <summary>
/// A wrapper for scriptable objects
/// </summary>
//[System.Serializable]
//public class ScriptableObjectWrapper
//{
// public string m_name;
// public string m_fileName;
// public byte[] m_content;
// /// <summary>
// /// Merge the file name with the sessioned file name
// /// </summary>
// /// <returns></returns>
// public string GetSessionedFileName(string sessionName)
// {
// return PWCommon4.Utils.FixFileName(sessionName) + "_" + Path.GetFileName(m_fileName);
// }
// /// <summary>
// /// Merge the file name with the sessioned file name
// /// </summary>
// /// <param name="sessionName">session file name</param>
// /// <param name="soFileName">scriptable object file name</param>
// /// <returns></returns>
// public static string GetSessionedFileName(string sessionName, string soFileName)
// {
// return PWCommon4.Utils.FixFileName(sessionName) + "_" + Path.GetFileName(soFileName);
// }
//}
/// <summary>
/// A Gaia session - core data structure used to store sessions
/// </summary>
[System.Serializable]
public class GaiaSession : ScriptableObject
{
/// <summary>
/// Session name
/// </summary>
[TextArea(1,1)]
public string m_name = string.Format("Session {0:yyyyMMdd-HHmmss}", DateTime.Now);
/// <summary>
///
/// Session description
/// </summary>
[TextArea(3, 5)]
public string m_description = "";
[HideInInspector]
public Texture2D m_previewImage;
/// <summary>
/// When the session was created
/// </summary>
public string m_dateCreated = DateTime.Now.ToString();
/// <summary>
/// The width of the terrain it was created with
/// </summary>
public int m_terrainWidth = 0;
/// <summary>
/// The depth of the terrain it was created with
/// </summary>
public int m_terrainDepth = 0;
/// <summary>
/// The height of the terrain it was created with
/// </summary>
public int m_terrainHeight = 0;
/// <summary>
/// The session sea level
/// </summary>
public float m_seaLevel = 0f;
/// <summary>
/// The session spawn Density value
/// </summary>
public float m_spawnDensity = 1f;
/// <summary>
/// Locked or not - if locked then no changes will be made to it
/// </summary>
public bool m_isLocked = false;
/// <summary>
/// The preview image for this session
/// </summary>
[HideInInspector]
public byte [] m_previewImageBytes = new byte[0];
/// <summary>
/// Width of preview image if there is one
/// </summary>
[HideInInspector]
public int m_previewImageWidth = 0;
/// <summary>
/// Height of preview image if there is one
/// </summary>
[HideInInspector]
public int m_previewImageHeight = 0;
/// <summary>
/// The operations that this session is made up of
/// </summary>
[HideInInspector]
public List<GaiaOperation> m_operations = new List<GaiaOperation>();
/// <summary>
/// The cache of min-max physical terrain heights
/// </summary>
[HideInInspector]
public List<TerrainMinMaxHeight> m_terrainMinMaxCache = new List<TerrainMinMaxHeight>();
/// <summary>
/// The collision mask cache to compute collision information in the stamper / spawner
/// </summary>
[HideInInspector]
public BakedMaskCacheEntry[] m_bakedMaskCacheEntries = new BakedMaskCacheEntry[0];
/// <summary>
/// Holds all terrain scenes in a multi-terrain scenario with exported terrains.
/// </summary>
//public List<TerrainScene> m_terrainScenes = new List<TerrainScene>();
/// <summary>
/// Store for the current world biome mask settings - required to bake the world biome mask in the spawner for the baked mask cache
/// </summary>
public SpawnerSettings m_worldBiomeMaskSettings;
/// <summary>
/// Get the session name as fixed file name without the extension
/// </summary>
/// <returns></returns>
public string GetSessionFileName()
{
return PWCommon4.Utils.FixFileName(m_name);
}
/// <summary>
/// Get the embedded preview image or null
/// </summary>
/// <returns>Embedded preview image or null</returns>
public Texture2D GetPreviewImage()
{
if (m_previewImageBytes.GetLength(0) == 0)
{
return null;
}
Texture2D image = new Texture2D(m_previewImageWidth, m_previewImageHeight, TextureFormat.ARGB32, false);
image.LoadRawTextureData(m_previewImageBytes);
image.Apply();
//Do a manual colour mod if in linear colour space
#if UNITY_EDITOR
if (PlayerSettings.colorSpace == ColorSpace.Linear)
{
Color[] pixels = image.GetPixels();
for (int idx = 0; idx < pixels.GetLength(0); idx++)
{
pixels[idx] = pixels[idx].gamma;
}
image.SetPixels(pixels);
image.Apply();
}
#endif
image.name = m_name;
return image;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e251860fcd970734c9f14ebd98a146c3
timeCreated: 1540439608
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b7460de6193629443b952f9e783185bd, type: 3}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2dd968c7c0aaf894daa18afd9eac9965
timeCreated: 1540452158
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: b7460de6193629443b952f9e783185bd, type: 3}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class RemoveNonBiomeResourcesSettings : ScriptableObject
{
#region public input variables
public BiomeControllerSettings m_biomeControllerSettings;
public List<SpawnerSettings> m_spawnerSettingsList;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82d4f9a03cde6e4468289cc40346614b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class SpawnOperationSettings : ScriptableObject
{
#region public input variables
/// <summary>
/// The area where the spawn should be executed
/// </summary>
public BoundsDouble m_spawnArea;
/// <summary>
/// The biome controller settings - if the spawn was performed from a biome controller.
/// </summary>
public BiomeControllerSettings m_biomeControllerSettings;
/// <summary>
/// Whether this spawn was performed on the world map or not.
/// </summary>
public bool m_isWorldMapSpawner;
/// <summary>
/// List of all the spawner settings that should be spawned
/// </summary>
public List<SpawnerSettings> m_spawnerSettingsList;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5415a5032c6a32e4ca53206bb5d95f22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class UndoRedoOperationSettings : ScriptableObject
{
#region public input variables
/// <summary>
/// List of all the Terrains that need to be loaded for this undo operation.
/// </summary>
public List<string> m_TerrainsList;
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ba1003322002b64782f334abc44e096
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,135 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class WorldCreationSettings : ScriptableObject
{
#region public input variables
/// <summary>
/// The preset the user chose for world creation. Stored mainly to transfer this setting between UIs easily.
/// </summary>
public GaiaConstants.EnvironmentSizePreset m_targeSizePreset = GaiaConstants.EnvironmentSizePreset.Large;
/// <summary>
/// The preset the user chose for world quality. Stored mainly to transfer this setting between UIs easily.
/// </summary>
public GaiaConstants.EnvironmentTarget m_qualityPreset = GaiaConstants.EnvironmentTarget.Desktop;
/// <summary>
/// The number of terrain tiles on the X-axis
/// </summary>
public int m_xTiles = 1;
/// <summary>
/// The number of terrain tiles on the Z-axis
/// </summary>
public int m_zTiles = 1;
/// <summary>
/// The size of a single terrain tile in unity units.
/// </summary>
public int m_tileSize = 1024;
/// <summary>
/// The height of a single terrain tile in unity units.
/// </summary>
public float m_tileHeight = 1000;
/// <summary>
/// The date time string used naming the terrains etc. during terrain creation. Needs to be stored in the session to allow recreation of the terrains using the same names.
/// </summary>
public string m_dateTimeString;
/// <summary>
/// The sea level in the created world. This will have no impact on the created terrain tiles initially, but will be picked up by other Gaia Tools (stamper, spawner) when they are being added to the scene.
/// </summary>
public int m_seaLevel = 50;
/// <summary>
/// Should the terrain tiles be created in their own scene each? If yes, this allows dynamic loading of terrains during editing and runtime, recommended for large worlds.
/// </summary>
public bool m_createInScene;
/// <summary>
/// Should the individual terrain scenes be unloaded immediately after creation to conserve memory? Recommended for large worlds.
/// </summary>
public bool m_autoUnloadScenes;
/// <summary>
/// Should a floating point imprecision fix be applied to the terrains during terrain creation?
/// </summary>
public bool m_applyFloatingPointFix;
/// <summary>
/// Offset for the world center point. (In case the world is not supposed to be created around 0,0,0)
/// </summary>
/// <returns></returns>
public Vector2 m_centerOffset = Vector2.zero;
/// <summary>
/// Are the terrain tiles to be part of a world map?
/// </summary>
public bool m_isWorldMap;
/// <summary>
/// The default settings for the terrain tiles being created (terrain resolution settings, etc.). If left empty, Gaia will take the current defaults from the Gaia settings.
/// </summary>
public GaiaDefaults m_gaiaDefaults;
/// <summary>
/// The prototypes in these spawners will be added to all terrain tiles automatically. Just leave it null if you don't want to add any prototypes to the terrain.
/// </summary>
public List<BiomeSpawnerListEntry> m_spawnerPresetList;
#endregion
#region Helper methods
public string CheckSettings(bool isWorldMap = false)
{
StringBuilder defStr = new StringBuilder();
if (!Mathf.IsPowerOfTwo(m_gaiaDefaults.m_heightmapResolution - 1))
{
defStr.AppendFormat("Height map size must be power of 2 + 1 number! {0} was changed to {1}.\n", m_gaiaDefaults.m_heightmapResolution, Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_heightmapResolution) + 1);
m_gaiaDefaults.m_heightmapResolution = Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_heightmapResolution) + 1;
}
if (!Mathf.IsPowerOfTwo(m_gaiaDefaults.m_controlTextureResolution))
{
defStr.AppendFormat("Control texture resolution must be power of 2! {0} was changed to {1}.\n", m_gaiaDefaults.m_controlTextureResolution, Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_controlTextureResolution));
m_gaiaDefaults.m_controlTextureResolution = Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_controlTextureResolution);
}
if (m_gaiaDefaults.m_controlTextureResolution > 2048)
{
defStr.AppendFormat("Control texture resolution must be <= 2048! {0} was changed to {1}.\n", m_gaiaDefaults.m_controlTextureResolution, 2048);
m_gaiaDefaults.m_controlTextureResolution = 2048;
}
if (!Mathf.IsPowerOfTwo(m_gaiaDefaults.m_baseMapSize))
{
defStr.AppendFormat("Basemap size must be power of 2! {0} was changed to {1}.\n", m_gaiaDefaults.m_baseMapSize, Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_baseMapSize));
m_gaiaDefaults.m_baseMapSize = Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_baseMapSize);
}
if (m_gaiaDefaults.m_baseMapSize > 2048)
{
defStr.AppendFormat("Basemap size must be <= 2048! {0} was changed to {1}.\n", m_gaiaDefaults.m_baseMapSize, 2048);
m_gaiaDefaults.m_baseMapSize = 2048;
}
if (!Mathf.IsPowerOfTwo(m_gaiaDefaults.m_detailResolution))
{
defStr.AppendFormat("Detail map size must be power of 2! {0} was changed to {1}.\n", m_gaiaDefaults.m_detailResolution, Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_detailResolution));
m_gaiaDefaults.m_detailResolution = Mathf.ClosestPowerOfTwo(m_gaiaDefaults.m_detailResolution);
}
if (m_gaiaDefaults.m_detailResolutionPerPatch < 8)
{
defStr.AppendFormat("Detail resolution per patch must be >= 8! {0} was changed to {1}.\n", m_gaiaDefaults.m_detailResolutionPerPatch, 8);
m_gaiaDefaults.m_detailResolutionPerPatch = 8;
}
return defStr.ToString();
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4cc9961a916782e48bc0339e84343ca6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: