using UnityEngine; using System.Collections; using System.Collections.Generic; using System; using System.IO; #if UNITY_EDITOR using UnityEditor; #endif namespace Gaia { /// /// Class to cache the minimum - maximum physical height of a terrain /// [System.Serializable] public class TerrainMinMaxHeight { public string guid; public bool isWorldmap = false; public bool recalculate = false; public float min; public float max; } /// /// A wrapper for scriptable objects /// //[System.Serializable] //public class ScriptableObjectWrapper //{ // public string m_name; // public string m_fileName; // public byte[] m_content; // /// // /// Merge the file name with the sessioned file name // /// // /// // public string GetSessionedFileName(string sessionName) // { // return PWCommon3.Utils.FixFileName(sessionName) + "_" + Path.GetFileName(m_fileName); // } // /// // /// Merge the file name with the sessioned file name // /// // /// session file name // /// scriptable object file name // /// // public static string GetSessionedFileName(string sessionName, string soFileName) // { // return PWCommon3.Utils.FixFileName(sessionName) + "_" + Path.GetFileName(soFileName); // } //} /// /// A Gaia session - core data structure used to store sessions /// [System.Serializable] public class GaiaSession : ScriptableObject { /// /// Session name /// [TextArea(1,1)] public string m_name = string.Format("Session {0:yyyyMMdd-HHmmss}", DateTime.Now); /// /// /// Session description /// [TextArea(3, 5)] public string m_description = ""; [HideInInspector] public Texture2D m_previewImage; /// /// When the session was created /// public string m_dateCreated = DateTime.Now.ToString(); /// /// The width of the terrain it was created with /// public int m_terrainWidth = 0; /// /// The depth of the terrain it was created with /// public int m_terrainDepth = 0; /// /// The height of the terrain it was created with /// public int m_terrainHeight = 0; /// /// The session sea level /// public float m_seaLevel = 0f; /// /// The session spawn Density value /// public float m_spawnDensity = 1f; /// /// Locked or not - if locked then no changes will be made to it /// public bool m_isLocked = false; /// /// The preview image for this session /// [HideInInspector] public byte [] m_previewImageBytes = new byte[0]; /// /// Width of preview image if there is one /// [HideInInspector] public int m_previewImageWidth = 0; /// /// Height of preview image if there is one /// [HideInInspector] public int m_previewImageHeight = 0; /// /// The operations that this session is made up of /// [HideInInspector] public List m_operations = new List(); /// /// The cache of min-max physical terrain heights /// [HideInInspector] public List m_terrainMinMaxCache = new List(); /// /// The collision mask cache to compute collision information in the stamper / spawner /// [HideInInspector] public BakedMaskCacheEntry[] m_bakedMaskCacheEntries = new BakedMaskCacheEntry[0]; /// /// Holds all terrain scenes in a multi-terrain scenario with exported terrains. /// //public List m_terrainScenes = new List(); /// /// Store for the current world biome mask settings - required to bake the world biome mask in the spawner for the baked mask cache /// public SpawnerSettings m_worldBiomeMaskSettings; /// /// Get the session name as fixed file name without the extension /// /// public string GetSessionFileName() { return PWCommon3.Utils.FixFileName(m_name); } /// /// Get the embedded preview image or null /// /// Embedded preview image or null 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; } } }