Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
Adsito committed Jul 11, 2020
2 parents 45112ce + a4e454e commit 0078e4c
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 42 deletions.
13 changes: 12 additions & 1 deletion Assets/MapEditor/Managers/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ public static void Initialise(string bundlesRoot)
{
if (!IsInitialised)
{
if (!Directory.Exists(SettingsManager.RustDirectory))
{
Debug.LogError("Directory does not exist: " + bundlesRoot);
return;
}

if (!SettingsManager.RustDirectory.EndsWith("Rust"))
{
Debug.LogError("Not a valid Rust install directory: " + SettingsManager.RustDirectory);
return;
}

ProgressBarManager.Display("Loading Bundles", "Loading Root Bundle", 0.1f);
BundlePath = bundlesRoot;
var rootBundle = AssetBundle.LoadFromFile(bundlesRoot);
Expand All @@ -36,7 +48,6 @@ public static void Initialise(string bundlesRoot)
}

var manifestList = rootBundle.LoadAllAssets<AssetBundleManifest>();

if (manifestList.Length != 1)
{
Debug.LogError("Couldn't find AssetBundleManifest - " + manifestList.Length);
Expand Down
2 changes: 1 addition & 1 deletion Assets/MapEditor/Managers/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public static void Load(WorldSerialization world, string loadPath = "")
/// <param name="path">The path to save to.</param>
public static void Save(string path)
{
SaveLayer(TerrainTopology.TypeToIndex((int)TopologyLayer));
SaveLayer();
ProgressBarManager.Display("Saving Map: " + path, "Saving Prefabs ", 0.4f);
WorldSerialization world = TerrainToWorld(Land, Water);
ProgressBarManager.Display("Saving Map: " + path, "Saving to disk ", 0.8f);
Expand Down
5 changes: 3 additions & 2 deletions Assets/MapEditor/Managers/PrefabManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static GameObject Process(GameObject go, string filePath)
foreach (var item in go.GetComponentsInChildren<MeshCollider>())
{
item.cookingOptions = MeshColliderCookingOptions.None;
item.enabled = false;
item.isTrigger = false;
item.convex = false;
}
Expand Down Expand Up @@ -134,7 +135,7 @@ private static IEnumerator SpawnPrefabsCoroutine(PrefabData[] prefabs)
ProgressBarManager.SetProgressIncrement(1f / prefabs.Length);
for (int i = 0; i < prefabs.Length; i++)
{
if (sw.Elapsed.TotalSeconds > 2f)
if (sw.Elapsed.TotalSeconds > 1.5f)
{
sw.Restart();
ProgressBarManager.DisplayIncremental("Spawning Prefabs", "Spawning Prefabs: " + i + " / " + prefabs.Length);
Expand All @@ -156,7 +157,7 @@ private static IEnumerator ReplaceWithLoadedCoroutine(PrefabDataHolder[] prefabs
ProgressBarManager.SetProgressIncrement(1f / prefabs.Length);
for (int i = 0; i < prefabs.Length; i++)
{
if (sw.Elapsed.TotalSeconds > 2f)
if (sw.Elapsed.TotalSeconds > 1.5f)
{
ProgressBarManager.DisplayIncremental("Replacing Prefabs", "Spawning Prefabs: " + i + " / " + prefabs.Length);
yield return null;
Expand Down
2 changes: 1 addition & 1 deletion Assets/MapEditor/Managers/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void SetDefaultSettings()
{
RustDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\Rust";
ToolTips.rustDirectoryPath.text = RustDirectory;
PrefabRenderDistance = 750f;
PrefabRenderDistance = 700f;
PathRenderDistance = 250f;
WaterTransparency = 0.2f;
SetDefaultPrefabPaths();
Expand Down
65 changes: 40 additions & 25 deletions Assets/MapEditor/Managers/TerrainManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ private static void TextureChanged(Terrain terrain, string textureName, RectInt
/// <param name="topology">The Topology layer to change to.</param>
public static void ChangeLandLayer(LandLayers layer, int topology = 0)
{
if (layer == LandLayers.Alpha)
return;
if (layer == LandLayer)
SaveLayer(LastTopologyLayer);
SetLayer(layer, topology);
EditorCoroutineUtility.StartCoroutineOwnerless(Coroutine.ChangeLayer(layer, topology));
}

/// <summary>Returns the SplatMap at the selected LandLayer.</summary>
Expand Down Expand Up @@ -195,27 +191,10 @@ public static void SetLayer(LandLayers layer, int topology = 0)
}

/// <summary>Saves any changes made to the Alphamaps, like the paint brush.</summary>
/// <param name="topologyLayer">The Topology layer, if active.</param>
public static void SaveLayer(int topologyLayer = 0)
/// <param name="topology">The Topology layer, if active.</param>
public static void SaveLayer()
{
if (LayerSet == false)
{
Debug.LogError("Saving Layer before layer is set");
return;
}

switch (LandLayer)
{
case LandLayers.Ground:
GroundArray = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
case LandLayers.Biome:
BiomeArray = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
case LandLayers.Topology:
TopologyArray[topologyLayer] = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
}
EditorCoroutineUtility.StartCoroutineOwnerless(Coroutine.SaveLayer());
}

private static void GetTextures()
Expand Down Expand Up @@ -274,10 +253,24 @@ private static TerrainLayer[] GetGroundTextures()

private class Coroutines
{
public IEnumerator ChangeLayer(LandLayers layer, int topology = 0)
{
yield return EditorCoroutineUtility.StartCoroutineOwnerless(SaveLayerCoroutine());
yield return EditorCoroutineUtility.StartCoroutineOwnerless(SetLayerCoroutine(layer, topology));
LayerSet = true;
}

public IEnumerator SetLayer(LandLayers layer, int topology = 0)
{
yield return EditorCoroutineUtility.StartCoroutineOwnerless(SetLayerCoroutine(layer, topology));
LayerSet = true;
foreach (var item in Land.terrainData.alphamapTextures)
Undo.ClearUndo(item);
}

public IEnumerator SaveLayer()
{
yield return EditorCoroutineUtility.StartCoroutineOwnerless(SaveLayerCoroutine());
}

private IEnumerator SetLayerCoroutine(LandLayers layer, int topology = 0)
Expand Down Expand Up @@ -307,6 +300,28 @@ private IEnumerator SetLayerCoroutine(LandLayers layer, int topology = 0)
TopologyLayer = (TerrainTopology.Enum)TerrainTopology.IndexToType(topology);
yield return null;
}

private IEnumerator SaveLayerCoroutine()
{
while (!LayerSet)
{
yield return null;
}

switch (LandLayer)
{
case LandLayers.Ground:
GroundArray = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
case LandLayers.Biome:
BiomeArray = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
case LandLayers.Topology:
TopologyArray[LastTopologyLayer] = Land.terrainData.GetAlphamaps(0, 0, Land.terrainData.alphamapWidth, Land.terrainData.alphamapHeight);
break;
}
yield return null;
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/MapEditor/Scripts/ToolTips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class ToolTips
public static GUIContent systemOS = new GUIContent("OS: " + SystemInfo.operatingSystem);
public static GUIContent systemRAM = new GUIContent("RAM: " + SystemInfo.systemMemorySize / 1000 + "GB");
public static GUIContent unityVersion = new GUIContent("Unity Version: " + Application.unityVersion);
public static GUIContent editorVersion = new GUIContent("Editor Version: v0.1.2");
public static GUIContent editorVersion = new GUIContent("Editor Version: v0.1.3");

public static GUIContent runPreset = new GUIContent("Run Preset", "Run this preset with all it's current nodes.");
public static GUIContent deletePreset = new GUIContent("Delete Preset", "Delete this preset from Unity.");
Expand Down
13 changes: 6 additions & 7 deletions Assets/Resources/Materials/Water.mat
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Water
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _GLOSSYREFLECTIONS_OFF _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
m_Shader: {fileID: 4800000, guid: 663c5869691e3624391cd8cd28896134, type: 3}
m_ShaderKeywords: _ALPHABLEND_ON _GLOSSYREFLECTIONS_OFF _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
_SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
Expand Down Expand Up @@ -74,13 +73,13 @@ Material:
- _Glossiness: 0.5
- _GlossyReflections: 0
- _Metallic: 0
- _Mode: 3
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Shininess: 0.05
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 0
- _SrcBlend: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
Expand Down
8 changes: 8 additions & 0 deletions Assets/Resources/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions Assets/Resources/Shaders/TransparentDiffuseBase.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

Shader "Nature/Terrain/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
[HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
LOD 200

CGPROGRAM
#pragma surface surf Lambert vertex:SplatmapVert addshadow fullforwardshadows alpha:fade
#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
#pragma multi_compile_local __ _ALPHATEST_ON

#define TERRAIN_BASE_PASS
#include "TerrainSplatmapCommon.cginc"

sampler2D _MainTex;
fixed4 _Color;

void surf (Input IN, inout SurfaceOutput o) {
#ifdef _ALPHATEST_ON
ClipHoles(IN.tc.xy);
#endif
fixed4 c = tex2D(_MainTex, IN.tc.xy) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG

UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
}

Fallback "Legacy Shaders/VertexLit"
}
9 changes: 9 additions & 0 deletions Assets/Resources/Shaders/TransparentDiffuseBase.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/Resources/land.asset
Binary file not shown.
Binary file modified Assets/Resources/water.asset
Binary file not shown.
4 changes: 2 additions & 2 deletions Assets/Scenes/Editor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ Terrain:
m_HeightmapMaximumLOD: 0
m_ShadowCastingMode: 0
m_DrawHeightmap: 1
m_DrawInstanced: 0
m_DrawInstanced: 1
m_DrawTreesAndFoliage: 0
m_ReflectionProbeUsage: 0
m_MaterialTemplate: {fileID: 10650, guid: 0000000000000000f000000000000000, type: 0}
Expand Down Expand Up @@ -586,7 +586,7 @@ Terrain:
m_HeightmapMaximumLOD: 0
m_ShadowCastingMode: 0
m_DrawHeightmap: 1
m_DrawInstanced: 0
m_DrawInstanced: 1
m_DrawTreesAndFoliage: 0
m_ReflectionProbeUsage: 0
m_MaterialTemplate: {fileID: 2100000, guid: 49df9a9fa69740e4782b406d0c541009, type: 2}
Expand Down
4 changes: 2 additions & 2 deletions EditorSettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"rustDirectory": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Rust",
"prefabRenderDistance": 750.0,
"prefabRenderDistance": 700.0,
"pathRenderDistance": 250.0,
"waterTransparency": 0.2,
"waterTransparency": 0.20000000298023225,
"prefabPaths": [
"assets/bundled/prefabs/autospawn/",
"assets/bundled/prefabs/bunker_rooms/",
Expand Down

0 comments on commit 0078e4c

Please sign in to comment.