-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCrystals.cs
43 lines (34 loc) · 1.24 KB
/
Crystals.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
using System.ComponentModel;
using Terraria.ModLoader.Config;
namespace MoreLifeCrystals;
public class Config : ModConfig
{
public override ConfigScope Mode => ConfigScope.ClientSide;
[DefaultValue(100)]
public int LifeCrystalsAmount;
}
public class Crystals : ModSystem
{
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref double totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Life Crystals"));
if (ShiniesIndex != -1)
{
tasks.Insert(ShiniesIndex + 1, new PassLegacy(nameof(MoreLifeCrystals), LifeCrystals));
}
}
private void LifeCrystals(GenerationProgress progress, GameConfiguration configuration)
{
progress.Message = "Adding even more life crystals";
int amount = ModContent.GetInstance<Config>().LifeCrystalsAmount;
for (int n = 0; n < amount; n++)
{
for (int k = 0; k < (int)(Main.maxTilesX * Main.maxTilesY * 6E-05); k++)
{
int x = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
int y = WorldGen.genRand.Next((int)GenVars.rockLayerLow, Main.maxTilesY);
_ = WorldGen.AddLifeCrystal(x, y);
}
}
}
}