-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtils.cs
66 lines (55 loc) · 2.17 KB
/
Utils.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
using System;
namespace PlentifulOres;
public static class Utils
{
public static void GenerateTile(int id)
{
Config config = PlentifulOres.Config;
bool nearSurface = config.NearSurface;
int x = WorldGen.genRand.Next(0, Main.maxTilesX);
int y = WorldGen.genRand.Next(
minValue: nearSurface ? (int)GenVars.worldSurfaceLow : (int)GenVars.rockLayerLow,
maxValue: Main.maxTilesY);
int additionalStr = config.AdditionalStrength;
int additionalSteps = config.AdditionalSteps;
try
{
WorldGen.TileRunner(x, y,
strength: WorldGen.genRand.Next(10 + additionalStr, 15 + additionalStr),
steps: WorldGen.genRand.Next(3 + additionalSteps, 6 + additionalSteps),
type: id,
addTile: config.NotOnlyReplaceButAdd,
speedX: config.SpeedX,
speedY: config.SpeedY,
noYChange: config.NoYChange,
overRide: config.Override_OnlyChangeIfYouKnowWhatYouAreDoing);
} catch (IndexOutOfRangeException)
{
// This will be thrown if the mod is loaded alongside
// the OreExcavator mod. This happens on world generation.
}
}
public static void GenerateHardmodeTile(int id)
{
Config config = PlentifulOres.Config;
bool nearSurface = config.NearSurface;
int x = WorldGen.genRand.Next(0, Main.maxTilesX);
int y = WorldGen.genRand.Next(
minValue: nearSurface ? (int)GenVars.worldSurfaceLow : (int)GenVars.rockLayerLow,
maxValue: Main.maxTilesY);
Tile tile = Framing.GetTileSafely(x, y);
// Only generate hardmode ores in replace of other ores
if (tile.HasTile && TileID.Sets.Ore[tile.TileType])
{
WorldGen.TileRunner(x, y,
strength: WorldGen.genRand.Next(15, 20),
steps: WorldGen.genRand.Next(3, 6),
type: id,
addTile: false,
speedX: config.SpeedX,
speedY: config.SpeedY,
noYChange: false,
overRide: true);
}
}
}