the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "Feature.h"
3
4class Level;
5
6class BasicTree : public Feature
7{
8private:
9 // The axisConversionArray, when given a primary index, allows easy
10 // access to the indices of the other two axies. Access the data at the
11 // primary index location to get the horizontal secondary axis.
12 // Access the data at the primary location plus three to get the
13 // remaining, tertiary, axis.
14 // All directions are specified by an index, 0, 1, or 2 which
15 // correspond to x, y, and z.
16 // The axisConversionArray is used in several places
17 // notably the crossection and taperedLimb methods.
18 // Example:
19 // If the primary axis is z, then the primary index is 2.
20 // The secondary index is axisConversionArray[2] which is 0,
21 // the index for the x axis.
22 // The remaining axis is axisConversionArray[2 + 3] which is 1,
23 // the index for the y axis.
24 // Using this method, the secondary axis will always be horizontal (x or z),
25 // and the tertiary always vertical (y), if possible.
26 static byte axisConversionArray[];
27
28 // Set up the pseudorandom number generator
29 Random *rnd;
30
31 // Make fields to hold the level data and the random seed
32 Level *thisLevel;
33
34 // Field to hold the tree origin, x y and z.
35 int origin[3];
36 // Field to hold the tree height.
37 int height;
38 // Other important tree information.
39 int trunkHeight;
40 double trunkHeightScale;
41 double branchDensity;
42 double branchSlope;
43 double widthScale;
44 double foliageDensity;
45 int trunkWidth;
46 int heightVariance;
47 int foliageHeight;
48 // The foliage coordinates are a list of [x,y,z,y of branch base] values for each cluster
49 int **foliageCoords;
50 int foliageCoordsLength;
51 void prepare();
52 void crossection(int x, int y, int z, float radius, byte direction, int material);
53 float treeShape(int y);
54 float foliageShape(int y);
55 void foliageCluster(int x, int y, int z);
56 void limb(int *start, int *end, int material);
57 void makeFoliage();
58 bool trimBranches(int localY);
59 void makeTrunk();
60 void makeBranches();
61 int checkLine(int *start, int *end);
62 bool checkLocation();
63
64public:
65 BasicTree(bool doUpdate);
66 virtual ~BasicTree();
67
68 virtual void init(double heightInit, double widthInit, double foliageDensityInit);
69 virtual bool place(Level *level, Random *random, int x, int y, int z);
70};