Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ShapeRoot.cs
Go to the documentation of this file.
1using System;
4
6
7public 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}
static double Cos(double d)
static double Sin(double a)
override bool Perform(Point origin, GenAction action)
Definition ShapeRoot.cs:51
ShapeRoot(double angle, double distance=10.0, double startingSize=4.0, double endingSize=1.0)
Definition ShapeRoot.cs:17
bool DoRoot(Point origin, GenAction action, double angle, double distance, double startingSize)
Definition ShapeRoot.cs:25
static double Lerp(double value1, double value2, double amount)
Definition Utils.cs:64
static UnifiedRandom _random
Definition GenBase.cs:9
bool UnitApply(GenAction action, Point origin, int x, int y, params object[] args)
Definition GenShape.cs:13