Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ShapeRoot.cs
Go to the documentation of this file.
1
using
System
;
2
using
Microsoft.Xna.Framework
;
3
using
Terraria.WorldBuilding
;
4
5
namespace
Terraria.GameContent.Generation
;
6
7
public
class
ShapeRoot
:
GenShape
8
{
9
private
double
_angle
;
10
11
private
double
_startingSize
;
12
13
private
double
_endingSize
;
14
15
private
double
_distance
;
16
17
public
ShapeRoot
(
double
angle,
double
distance = 10.0,
double
startingSize = 4.0,
double
endingSize = 1.0)
18
{
19
_angle
= angle;
20
_distance
= distance;
21
_startingSize
= startingSize;
22
_endingSize
= endingSize;
23
}
24
25
private
bool
DoRoot
(
Point
origin,
GenAction
action
,
double
angle,
double
distance,
double
startingSize)
26
{
27
double
num = origin.
X
;
28
double
num2 = origin.
Y
;
29
for
(
double
num3 = 0.0; num3 < distance * 0.85; num3 += 1.0)
30
{
31
double
num4 = num3 / distance;
32
double
num5 =
Utils
.
Lerp
(startingSize,
_endingSize
, num4);
33
num +=
Math
.
Cos
(angle);
34
num2 +=
Math
.
Sin
(angle);
35
angle += (double)
GenBase
.
_random
.NextFloat() - 0.5 + (double)
GenBase
.
_random
.NextFloat() * (
_angle
- 1.5707963705062866) * 0.1 * (1.0 - num4);
36
angle = angle * 0.4 + 0.45 *
Utils
.Clamp(angle,
_angle
- 2.0 * (1.0 - 0.5 * num4),
_angle
+ 2.0 * (1.0 - 0.5 * num4)) +
Utils
.
Lerp
(
_angle
, 1.5707963705062866, num4) * 0.15;
37
for
(
int
i = 0; i < (int)num5; i++)
38
{
39
for
(
int
j = 0; j < (int)num5; j++)
40
{
41
if
(!
UnitApply
(
action
, origin, (
int
)num + i, (int)num2 + j) &&
_quitOnFail
)
42
{
43
return
false
;
44
}
45
}
46
}
47
}
48
return
true
;
49
}
50
51
public
override
bool
Perform
(
Point
origin,
GenAction
action
)
52
{
53
return
DoRoot
(origin,
action
,
_angle
,
_distance
,
_startingSize
);
54
}
55
}
System.Math.Cos
static double Cos(double d)
System.Math.Sin
static double Sin(double a)
System.Math
Definition
Math.cs:13
Terraria.GameContent.Generation.ShapeRoot.Perform
override bool Perform(Point origin, GenAction action)
Definition
ShapeRoot.cs:51
Terraria.GameContent.Generation.ShapeRoot._endingSize
double _endingSize
Definition
ShapeRoot.cs:13
Terraria.GameContent.Generation.ShapeRoot._angle
double _angle
Definition
ShapeRoot.cs:9
Terraria.GameContent.Generation.ShapeRoot._startingSize
double _startingSize
Definition
ShapeRoot.cs:11
Terraria.GameContent.Generation.ShapeRoot.ShapeRoot
ShapeRoot(double angle, double distance=10.0, double startingSize=4.0, double endingSize=1.0)
Definition
ShapeRoot.cs:17
Terraria.GameContent.Generation.ShapeRoot._distance
double _distance
Definition
ShapeRoot.cs:15
Terraria.GameContent.Generation.ShapeRoot.DoRoot
bool DoRoot(Point origin, GenAction action, double angle, double distance, double startingSize)
Definition
ShapeRoot.cs:25
Terraria.GameContent.Generation.ShapeRoot
Definition
ShapeRoot.cs:8
Terraria.Utils.Lerp
static double Lerp(double value1, double value2, double amount)
Definition
Utils.cs:64
Terraria.Utils
Definition
Utils.cs:29
Terraria.WorldBuilding.GenAction
Definition
GenAction.cs:6
Terraria.WorldBuilding.GenBase._random
static UnifiedRandom _random
Definition
GenBase.cs:9
Terraria.WorldBuilding.GenBase
Definition
GenBase.cs:6
Terraria.WorldBuilding.GenShape._quitOnFail
bool _quitOnFail
Definition
GenShape.cs:9
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
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
source
Terraria.GameContent.Generation
ShapeRoot.cs
Generated by
1.10.0