401 lines
7.7 KiB
C#
401 lines
7.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Boo.Lang.Runtime;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class terrain_class
|
|
{
|
|
[NonSerialized]
|
|
public terrain_class[] neighbors;
|
|
|
|
public bool active;
|
|
|
|
public bool foldout;
|
|
|
|
public int index;
|
|
|
|
public int index_old;
|
|
|
|
public bool on_row;
|
|
|
|
public Color color_terrain;
|
|
|
|
public int copy_terrain;
|
|
|
|
public bool copy_terrain_settings;
|
|
|
|
public Component rtp_script;
|
|
|
|
public neighbor_class neighbor;
|
|
|
|
public Texture2D[] splat_alpha;
|
|
|
|
public Texture2D ColorGlobal;
|
|
|
|
public Terrain terrain;
|
|
|
|
public Transform parent;
|
|
|
|
public GameObject objectParent;
|
|
|
|
public string name;
|
|
|
|
public area_class prearea;
|
|
|
|
public float[,,] map;
|
|
|
|
public List<splatPrototype_class> splatPrototypes;
|
|
|
|
public splatPrototype_class colormap;
|
|
|
|
public bool splats_foldout;
|
|
|
|
public Rect splat_rect;
|
|
|
|
public List<treePrototype_class> treePrototypes;
|
|
|
|
public bool trees_foldout;
|
|
|
|
public List<detailPrototype_class> detailPrototypes;
|
|
|
|
public bool details_foldout;
|
|
|
|
public float[] splat;
|
|
|
|
public float[] splat_calc;
|
|
|
|
public float[] splat_layer;
|
|
|
|
public int splat_length;
|
|
|
|
public float[] color;
|
|
|
|
public float[] color_layer;
|
|
|
|
public int color_length;
|
|
|
|
public float[] grass;
|
|
|
|
public int heightmap_resolution_list;
|
|
|
|
public int splatmap_resolution_list;
|
|
|
|
public int basemap_resolution_list;
|
|
|
|
public int detailmap_resolution_list;
|
|
|
|
public int detail_resolution_per_patch_list;
|
|
|
|
public Vector3 size;
|
|
|
|
public bool size_xz_link;
|
|
|
|
public float tile_x;
|
|
|
|
public float tile_z;
|
|
|
|
public Vector2 tiles;
|
|
|
|
public Rect rect;
|
|
|
|
public bool data_foldout;
|
|
|
|
public Vector3 scale;
|
|
|
|
public bool maps_foldout;
|
|
|
|
public bool settings_foldout;
|
|
|
|
public bool resolution_foldout;
|
|
|
|
public bool scripts_foldout;
|
|
|
|
public bool reset_foldout;
|
|
|
|
public bool size_foldout;
|
|
|
|
public int raw_file_index;
|
|
|
|
public raw_file_class raw_save_file;
|
|
|
|
public float heightmap_resolution;
|
|
|
|
public float splatmap_resolution;
|
|
|
|
public float detail_resolution;
|
|
|
|
public float detail_resolution_per_patch;
|
|
|
|
public float basemap_resolution;
|
|
|
|
public bool size_synchronous;
|
|
|
|
public bool resolutions_synchronous;
|
|
|
|
public bool splat_synchronous;
|
|
|
|
public bool tree_synchronous;
|
|
|
|
public bool detail_synchronous;
|
|
|
|
public Vector2 splatmap_conversion;
|
|
|
|
public Vector2 heightmap_conversion;
|
|
|
|
public Vector2 detailmap_conversion;
|
|
|
|
public bool splat_foldout;
|
|
|
|
public bool tree_foldout;
|
|
|
|
public int tree_length;
|
|
|
|
public bool detail_foldout;
|
|
|
|
public float detail_scale;
|
|
|
|
public bool base_terrain_foldout;
|
|
|
|
public bool tree_detail_objects_foldout;
|
|
|
|
public bool wind_settings_foldout;
|
|
|
|
public bool settings_all_terrain;
|
|
|
|
public float heightmapPixelError;
|
|
|
|
public int heightmapMaximumLOD;
|
|
|
|
public bool castShadows;
|
|
|
|
public float basemapDistance;
|
|
|
|
public float treeDistance;
|
|
|
|
public float detailObjectDistance;
|
|
|
|
public float detailObjectDensity;
|
|
|
|
public int treeMaximumFullLODCount;
|
|
|
|
public float treeBillboardDistance;
|
|
|
|
public float treeCrossFadeLength;
|
|
|
|
public bool draw;
|
|
|
|
public bool editor_draw;
|
|
|
|
public TerrainDetail script_terrainDetail;
|
|
|
|
public bool settings_runtime;
|
|
|
|
public bool settings_editor;
|
|
|
|
public float wavingGrassSpeed;
|
|
|
|
public float wavingGrassAmount;
|
|
|
|
public float wavingGrassStrength;
|
|
|
|
public Color wavingGrassTint;
|
|
|
|
public terrain_class()
|
|
{
|
|
neighbors = new terrain_class[4];
|
|
active = true;
|
|
color_terrain = new Color(2f, 2f, 2f, 1f);
|
|
copy_terrain_settings = true;
|
|
neighbor = new neighbor_class();
|
|
prearea = new area_class();
|
|
splatPrototypes = new List<splatPrototype_class>();
|
|
colormap = new splatPrototype_class();
|
|
treePrototypes = new List<treePrototype_class>();
|
|
detailPrototypes = new List<detailPrototype_class>();
|
|
size_xz_link = true;
|
|
tiles = new Vector2(1f, 1f);
|
|
data_foldout = true;
|
|
raw_file_index = -1;
|
|
raw_save_file = new raw_file_class();
|
|
heightmap_resolution = 256f;
|
|
splatmap_resolution = 256f;
|
|
detail_resolution = 256f;
|
|
detail_resolution_per_patch = 8f;
|
|
basemap_resolution = 256f;
|
|
size_synchronous = true;
|
|
resolutions_synchronous = true;
|
|
splat_synchronous = true;
|
|
tree_synchronous = true;
|
|
detail_synchronous = true;
|
|
detail_scale = 1f;
|
|
base_terrain_foldout = true;
|
|
tree_detail_objects_foldout = true;
|
|
wind_settings_foldout = true;
|
|
settings_all_terrain = true;
|
|
heightmapPixelError = 5f;
|
|
basemapDistance = 20000f;
|
|
treeDistance = 20000f;
|
|
detailObjectDistance = 250f;
|
|
detailObjectDensity = 1f;
|
|
treeMaximumFullLODCount = 50;
|
|
treeBillboardDistance = 250f;
|
|
treeCrossFadeLength = 200f;
|
|
draw = true;
|
|
editor_draw = true;
|
|
settings_editor = true;
|
|
wavingGrassSpeed = 0.5f;
|
|
wavingGrassAmount = 0.5f;
|
|
wavingGrassStrength = 0.5f;
|
|
wavingGrassTint = new Color(0.698f, 0.6f, 0.5f);
|
|
}
|
|
|
|
public virtual void add_splatprototype(int splat_number)
|
|
{
|
|
splatPrototypes.Insert(splat_number, new splatPrototype_class());
|
|
}
|
|
|
|
public virtual void erase_splatprototype(int splat_number)
|
|
{
|
|
if (splatPrototypes.Count > 0)
|
|
{
|
|
splatPrototypes.RemoveAt(splat_number);
|
|
}
|
|
}
|
|
|
|
public virtual void clear_splatprototype()
|
|
{
|
|
splatPrototypes.Clear();
|
|
}
|
|
|
|
public virtual void clear_null_splatprototype()
|
|
{
|
|
for (int i = 0; i < splatPrototypes.Count; i++)
|
|
{
|
|
if (splatPrototypes[i].texture == null)
|
|
{
|
|
splatPrototypes.RemoveAt(i);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void add_treeprototype(int tree_number)
|
|
{
|
|
treePrototypes.Insert(tree_number, new treePrototype_class());
|
|
}
|
|
|
|
public virtual void erase_treeprototype(int tree_number)
|
|
{
|
|
if (treePrototypes.Count > 0)
|
|
{
|
|
treePrototypes.RemoveAt(tree_number);
|
|
}
|
|
}
|
|
|
|
public virtual void clear_treeprototype()
|
|
{
|
|
treePrototypes.Clear();
|
|
}
|
|
|
|
public virtual void clear_null_treeprototype()
|
|
{
|
|
for (int i = 0; i < treePrototypes.Count; i++)
|
|
{
|
|
if (treePrototypes[i].prefab == null)
|
|
{
|
|
treePrototypes.RemoveAt(i);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void add_detailprototype(int detail_number)
|
|
{
|
|
detailPrototypes.Insert(detail_number, new detailPrototype_class());
|
|
}
|
|
|
|
public virtual void erase_detailprototype(int detail_number)
|
|
{
|
|
if (detailPrototypes.Count > 0)
|
|
{
|
|
detailPrototypes.RemoveAt(detail_number);
|
|
}
|
|
}
|
|
|
|
public virtual void clear_detailprototype()
|
|
{
|
|
detailPrototypes.Clear();
|
|
}
|
|
|
|
public virtual void clear_null_detailprototype()
|
|
{
|
|
for (int i = 0; i < detailPrototypes.Count; i++)
|
|
{
|
|
if (detailPrototypes[i].prototype == null && detailPrototypes[i].prototypeTexture == null)
|
|
{
|
|
detailPrototypes.RemoveAt(i);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void SetAllNeighbors(List<terrain_class> terrains)
|
|
{
|
|
for (int i = 0; i < terrains.Count; i++)
|
|
{
|
|
terrains[i].SetNeighbors(terrains);
|
|
}
|
|
}
|
|
|
|
public virtual void SetNeighbors(List<terrain_class> terrains)
|
|
{
|
|
Terrain[] array = new Terrain[4];
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
SetNeighbor(terrains, i);
|
|
if (!RuntimeServices.EqualityOperator(neighbors[i], null))
|
|
{
|
|
array[i] = neighbors[i].terrain;
|
|
}
|
|
else
|
|
{
|
|
array[i] = null;
|
|
}
|
|
}
|
|
if (terrain != null)
|
|
{
|
|
terrain.SetNeighbors(array[3], array[0], array[1], array[2]);
|
|
}
|
|
}
|
|
|
|
public virtual void SetNeighbor(List<terrain_class> terrains, int direction)
|
|
{
|
|
Vector2 vector = default(Vector2);
|
|
switch (direction)
|
|
{
|
|
case 0:
|
|
vector = new Vector2(0f, 1f);
|
|
break;
|
|
case 1:
|
|
vector = new Vector2(1f, 0f);
|
|
break;
|
|
case 2:
|
|
vector = new Vector2(0f, -1f);
|
|
break;
|
|
default:
|
|
vector = new Vector2(-1f, 0f);
|
|
break;
|
|
}
|
|
for (int i = 0; i < terrains.Count; i++)
|
|
{
|
|
if (!(terrains[i].terrain == null) && terrains[i].terrain.transform.position.x == terrain.transform.position.x + terrain.terrainData.size.x * vector.x && terrains[i].terrain.transform.position.z == terrain.transform.position.z + terrain.terrainData.size.z * vector.y)
|
|
{
|
|
neighbors[direction] = terrains[i];
|
|
return;
|
|
}
|
|
}
|
|
neighbors[direction] = null;
|
|
}
|
|
}
|