-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSurvivalSurfaceGeneratorMod.cs
More file actions
70 lines (63 loc) · 2.59 KB
/
SurvivalSurfaceGeneratorMod.cs
File metadata and controls
70 lines (63 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Harmony;
using UnityEngine;
//[HarmonyPatch(typeof(SurvivalSurfaceGenerator), "GenerateCubes")]
public static class SurvivalSurfaceGeneratorMod
{
//[HarmonyPrefix]
public static bool Prefix(Segment s, PerlinCache cache)
{
long realCubeX = s.baseX;
long realCubeZ = s.baseZ;
long offsetX = realCubeX - WorldScript.mDefaultOffset;
long offsetZ = realCubeZ - WorldScript.mDefaultOffset;
if (Math.Abs(offsetX) < 17 && Math.Abs(offsetZ) < 17)
{
return true;
}
return false;
}
public static void Suffix(Segment s, PerlinCache cache, ushort[,] ___SurfaceValCache)
{
for (int x = 0; x < WorldHelper.SegmentX + TerrainGenerator.doublePerlinBorder; x++)
{
for (int z = 0; z < WorldHelper.SegmentZ + TerrainGenerator.doublePerlinBorder; z++)
{
for (int y = 0; y < WorldHelper.SegmentY + TerrainGenerator.doublePerlinBorder; y++)
{
long realCubeX = s.baseX + x - PerlinCache.STANDARD_PERLIN_BORDER;
long realCubeZ = s.baseZ + z - PerlinCache.STANDARD_PERLIN_BORDER;
long offsetX = realCubeX - WorldScript.mDefaultOffset;
long offsetZ = realCubeZ - WorldScript.mDefaultOffset;
// Pythag
float offsetSquared = Mathf.Pow(offsetX, 2) + Mathf.Pow(offsetZ, 2);
if (offsetSquared > 100)
{
cache.maCubes[x, y, z] = eCubeTypes.Air;
cache.maCubeValues[x, y, z] = 0;
}
else
{
// Top layer is organic detritus with several meters of rock
if (y == WorldHelper.SegmentY + 1)
{
cache.maCubes[x, y, z] = eCubeTypes.NewSurvivalSurface;
cache.maCubeValues[x, y, z] = ___SurfaceValCache[x, z];
}
else if (y > 8 && y < WorldHelper.SegmentY + 1)
{
cache.maCubes[x, y, z] = eCubeTypes.RoughHewnRock;
}
else
{
cache.maCubes[x, y, z] = eCubeTypes.Air;
}
}
}
}
}
}
}