Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ShapeRunner.cs
Go to the documentation of this file.
1
using
System
;
2
using
Microsoft.Xna.Framework
;
3
using
ReLogic.Utilities
;
4
using
Terraria.WorldBuilding
;
5
6
namespace
Terraria.GameContent.Generation
;
7
8
public
class
ShapeRunner
:
GenShape
9
{
10
private
double
_startStrength
;
11
12
private
int
_steps
;
13
14
private
Vector2D
_startVelocity
;
15
16
public
ShapeRunner
(
double
strength,
int
steps,
Vector2D
velocity)
17
{
18
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
19
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
20
_startStrength
= strength;
21
_steps
= steps;
22
_startVelocity
= velocity;
23
}
24
25
public
override
bool
Perform
(
Point
origin,
GenAction
action
)
26
{
27
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
28
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
29
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
30
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
31
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
32
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
33
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
34
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
35
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
36
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
37
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
38
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
39
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
40
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
41
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
42
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
43
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
44
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
45
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
46
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
47
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
48
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
49
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
50
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
51
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
52
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
53
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
54
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
55
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
56
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
57
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
58
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
59
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
60
double
num =
_steps
;
61
double
num2 =
_steps
;
62
double
num3 =
_startStrength
;
63
Vector2D
val =
default
(
Vector2D
);
64
((
Vector2D
)(ref val))._002Ector((
double
)origin.
X
, (double)origin.
Y
);
65
Vector2D
val2 = ((
_startVelocity
==
Vector2D
.
Zero
) ?
Utils
.
RandomVector2D
(
GenBase
.
_random
, -1.0, 1.0) :
_startVelocity
);
66
while
(num > 0.0 && num3 > 0.0)
67
{
68
num3 =
_startStrength
* (num / num2);
69
num -= 1.0;
70
int
num4 =
Math
.
Max
(1, (
int
)(val.
X
- num3 * 0.5));
71
int
num5 =
Math
.
Max
(1, (
int
)(val.
Y
- num3 * 0.5));
72
int
num6 =
Math
.
Min
(
GenBase
.
_worldWidth
, (
int
)(val.
X
+ num3 * 0.5));
73
int
num7 =
Math
.
Min
(
GenBase
.
_worldHeight
, (
int
)(val.
Y
+ num3 * 0.5));
74
for
(
int
i = num4; i < num6; i++)
75
{
76
for
(
int
j = num5; j < num7; j++)
77
{
78
if
(!(
Math
.
Abs
((
double
)i - val.
X
) +
Math
.
Abs
((
double
)j - val.
Y
) >= num3 * 0.5 * (1.0 + (
double
)
GenBase
.
_random
.Next(-10, 11) * 0.015)))
79
{
80
UnitApply
(
action
, origin, i, j);
81
}
82
}
83
}
84
int
num8 = (int)(num3 / 50.0) + 1;
85
num -= (double)num8;
86
val += val2;
87
for
(
int
k = 0; k < num8; k++)
88
{
89
val += val2;
90
val2 +=
Utils
.
RandomVector2D
(
GenBase
.
_random
, -0.5, 0.5);
91
}
92
val2 +=
Utils
.
RandomVector2D
(
GenBase
.
_random
, -0.5, 0.5);
93
val2 =
Vector2D
.
Clamp
(val2, -
Vector2D
.
One
,
Vector2D
.
One
);
94
}
95
return
true
;
96
}
97
}
System.Math.Min
static byte Min(byte val1, byte val2)
Definition
Math.cs:912
System.Math.Abs
static double Abs(double value)
System.Math.Max
static byte Max(byte val1, byte val2)
Definition
Math.cs:738
System.Math
Definition
Math.cs:13
Terraria.GameContent.Generation.ShapeRunner._startVelocity
Vector2D _startVelocity
Definition
ShapeRunner.cs:14
Terraria.GameContent.Generation.ShapeRunner.ShapeRunner
ShapeRunner(double strength, int steps, Vector2D velocity)
Definition
ShapeRunner.cs:16
Terraria.GameContent.Generation.ShapeRunner.Perform
override bool Perform(Point origin, GenAction action)
Definition
ShapeRunner.cs:25
Terraria.GameContent.Generation.ShapeRunner._startStrength
double _startStrength
Definition
ShapeRunner.cs:10
Terraria.GameContent.Generation.ShapeRunner._steps
int _steps
Definition
ShapeRunner.cs:12
Terraria.GameContent.Generation.ShapeRunner
Definition
ShapeRunner.cs:9
Terraria.Utils.RandomVector2D
static Vector2D RandomVector2D(UnifiedRandom random, double min, double max)
Definition
Utils.cs:1828
Terraria.Utils
Definition
Utils.cs:29
Terraria.WorldBuilding.GenAction
Definition
GenAction.cs:6
Terraria.WorldBuilding.GenBase._worldWidth
static int _worldWidth
Definition
GenBase.cs:13
Terraria.WorldBuilding.GenBase._worldHeight
static int _worldHeight
Definition
GenBase.cs:15
Terraria.WorldBuilding.GenBase._random
static UnifiedRandom _random
Definition
GenBase.cs:9
Terraria.WorldBuilding.GenBase
Definition
GenBase.cs:6
Terraria.WorldBuilding.GenShape.UnitApply
bool UnitApply(GenAction action, Point origin, int x, int y, params object[] args)
Definition
GenShape.cs:13
Terraria.WorldBuilding.GenShape
Definition
GenShape.cs:6
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
ReLogic.Utilities
Definition
AttributeUtilities.cs:5
System.ExceptionArgument.action
@ action
System
Definition
BlockingCollection.cs:8
Terraria.GameContent.Generation
Definition
ActionGrass.cs:4
Terraria.WorldBuilding
Definition
Actions.cs:8
Microsoft.Xna.Framework.Point.X
int X
Definition
Point.cs:14
Microsoft.Xna.Framework.Point.Y
int Y
Definition
Point.cs:17
Microsoft.Xna.Framework.Point
Definition
Point.cs:12
ReLogic.Utilities.Vector2D.Zero
static Vector2D Zero
Definition
Vector2D.cs:24
ReLogic.Utilities.Vector2D.Y
double Y
Definition
Vector2D.cs:12
ReLogic.Utilities.Vector2D.X
double X
Definition
Vector2D.cs:10
ReLogic.Utilities.Vector2D.Clamp
static Vector2D Clamp(Vector2D value1, Vector2D min, Vector2D max)
Definition
Vector2D.cs:126
ReLogic.Utilities.Vector2D.One
static Vector2D One
Definition
Vector2D.cs:26
ReLogic.Utilities.Vector2D
Definition
Vector2D.cs:9
source
Terraria.GameContent.Generation
ShapeRunner.cs
Generated by
1.10.0