-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUnderwaterIslandsFloorBiome.cs
191 lines (150 loc) · 6.26 KB
/
UnderwaterIslandsFloorBiome.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.IO;
using SMLHelper.V2.Assets;
using SMLHelper.V2.Handlers;
using SMLHelper.V2.Crafting;
using SMLHelper.V2.Interfaces;
using SMLHelper.V2.Json;
using SMLHelper.V2.Utility;
using UnityEngine;
using ReikaKalseki.DIAlterra;
namespace ReikaKalseki.SeaToSea {
public class UnderwaterIslandsFloorBiome : CustomBiome {
public static readonly float minimumDepth = 375;
public static readonly float biomeRadius = 240;
public static readonly Vector3 biomeCenter = new Vector3(-107, -481, 953);
public static readonly string biomeName = "Glass Forest";
public static readonly float waterTemperature = 35;
public static readonly Vector3 wreckCtrPos1 = new Vector3(-110.76F, -499F, 940.19F);
public static readonly Vector3 wreckCtrPos2 = new Vector3(-138.38F, -497F, 932.69F);
// public static Color? waterColor;
public static readonly Vector3 waterColorFalloff = new Vector3(4, 10F, 2.0F);//new Vector3(5, 12.3F, 2.5F);
public static readonly float murkiness = 1.75F;//1.4F;
public static readonly float fogStart = 0;
public static readonly UnderwaterIslandsFloorBiome instance = new UnderwaterIslandsFloorBiome();
private readonly GlassForestAtmoFX atmoFX = new GlassForestAtmoFX();
private readonly Dictionary<string, int> creatureCounts = new Dictionary<string, int>();
private UnderwaterIslandsFloorBiome() : base(biomeName, 0.8F) {
}
public override void register() {
UnityEngine.Random.InitState(234761897);
GenUtil.registerWorldgen(new PositionedPrefab(VanillaCreatures.GHOST_LEVIATHAN.prefab, new Vector3(-125, -450, 980)));
atmoFX.Patch();
/*
for (float i = -100; i <= length+100; i += biomeVolumeRadius*0.5F) {
addAtmoFX(end500m+(end900m-end500m).normalized*i);
}
addAtmoFX(end900m);
*/
//GenUtil.registerWorldgen(atmoFX.ClassID, biomeCenter, Quaternion.identity, go => go.transform.localScale = Vector3.one*(biomeRadius+50));
GenUtil.registerSlotWorldgen(C2CItems.kelp.ClassID, C2CItems.kelp.PrefabFileName, C2CItems.kelp.TechType, EntitySlot.Type.Medium, LargeWorldEntity.CellLevel.Batch, BiomeType.UnderwaterIslands_ValleyFloor, 1, 3.2F);
//GenUtil.registerSlotWorldgen(kelp.ClassID, kelp.PrefabFileName, kelp.TechType, false, BiomeType.UnderwaterIslands_Geyser, 1, 2F);
creatureCounts[SeaToSeaMod.purpleBoomerang.ClassID] = 300;
creatureCounts[SeaToSeaMod.purpleHolefish.ClassID] = 60;
creatureCounts[SeaToSeaMod.purpleHoopfish.ClassID] = 250;
foreach (KeyValuePair<string, int> kvp in creatureCounts) {
for (int i = 0; i < kvp.Value; i++) {
Vector3 pos = MathUtil.getRandomVectorAround(biomeCenter, new Vector3(biomeRadius, 0, biomeRadius)*0.5F).setY(-(UnityEngine.Random.Range(440, 480)));
//SNUtil.log("Spawning "+kvp.Key+" @ "+pos);
GenUtil.registerWorldgen(new PositionedPrefab(kvp.Key, pos));
}
}
}
/*
private void addAtmoFX(Vector3 pos) {
GenUtil.registerWorldgen(atmoFX.ClassID, pos, Quaternion.identity, go => go.transform.localScale = Vector3.one*(100+biomeVolumeRadius));
}*/
public override mset.Sky getSky() {
return WorldUtil.getSkybox(VanillaBiomes.UNDERISLANDS.getIDs().First());
}
public override VanillaMusic[] getMusicOptions() {
return new VanillaMusic[]{VanillaMusic.ILZ, VanillaMusic.JELLYSHROOM, VanillaMusic.AURORA};
}
public override float getSunScale(float orig) {
return 0;
}
public override float getFogStart(float orig) {
return fogStart;
}
public override float getMurkiness(float orig) {
return murkiness;
}
public override Vector3 getColorFalloff(Vector3 orig) {
return waterColorFalloff;
}
public override Color getWaterColor(Color orig) {
return Color.white;//waterColor.Value;
}
public override bool isCaveBiome() {
return false;
}
public override bool existsInSeveralPlaces() {
return false;
}
public void tickPlayer(Player ep) {
}
public void onWorldStart() {
}
public override bool isInBiome(Vector3 pos) {
string orig = WaterBiomeManager.main.GetBiome(pos, false);
return isInBiome(orig, pos);
}
public bool isInBiome(string orig, Vector3 pos) {
if (orig == biomeName)
return true;
if (orig == null || pos.y > -minimumDepth)
return false;
return VanillaBiomes.UNDERISLANDS.containsID(orig) && MathUtil.isPointInCylinder(biomeCenter.setY(-400), pos, biomeRadius, 150);//getDistanceToBiome(pos) < 5;
}
public override double getDistanceToBiome(Vector3 vec) {
float ret = Math.Max(0, Vector3.Distance(vec, biomeCenter)-biomeRadius);
if (vec.y >= -minimumDepth)
ret = Math.Max(ret, vec.y+minimumDepth);
return ret;
}
public float getTemperatureBoost(float baseline, Vector3 pos) {
float boost = ((-pos.y)-minimumDepth-75)*0.5F; // so add about 50C
if (boost <= 0)
return 0;
boost /= 1+(float)getDistanceToBiome(pos)*0.01F;
float ret = Mathf.Min(boost, 200-baseline);
float dist = (float)MathUtil.getDistanceToLineSegment(pos, wreckCtrPos1, wreckCtrPos2);
if (dist <= 40) {
ret *= Mathf.Clamp01(dist/30F);
}
return ret;
}
public bool isAtmoFX(PrefabIdentifier pi) {
return pi && pi.ClassId == atmoFX.ClassID;
}
}
class GlassForestAtmoFX : GenUtil.CustomPrefabImpl {
internal GlassForestAtmoFX() : base("glassforestFX", "62a47c16-bf83-46ee-b16b-8cc35e7df97d") { //valley floor
}
public override void prepareGameObject(GameObject go, Renderer[] r) {
LargeWorldEntity lw = go.EnsureComponent<LargeWorldEntity>();
lw.cellLevel = LargeWorldEntity.CellLevel.VeryFar;
AtmosphereVolume vol = go.EnsureComponent<AtmosphereVolume>();/*
vol.affectsVisuals = true;
vol.priority = 1;
vol.enabled = true;
vol.fogMaxDistance = 150;
vol.fogStartDistance = 90;
vol.fogColor = new Color(0.44F, 0.188F, 1, vol.fogColor.a);
/*
vol.fog.color = vol.fogColor;*//*
vol.fog.maxDistance = 600F;
vol.fog.startDistance = 150F;
GradientColorKey[] keys = vol.fog.dayNightColor.colorKeys;
for (int i = 0; i < keys.Length; i++)
keys[i].color = vol.fogColor;
vol.fog.dayNightColor.colorKeys = keys;
//vol.fog.dayNightColor.
*/
vol.overrideBiome = UnderwaterIslandsFloorBiome.biomeName;
}
}
}