Skip to main content

WoodcutTreeModel

A class in Root.Township, Alta.Woodcutting.

One choppable segment of a WoodcutTree (a trunk or branch piece). Hits from the tree's impact detector damage its woodcut points; on the server, enough damage around the bottom chops it off.

Constructors​

MemberWhat it is
WoodcutTreeModel()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private BoneWeight[] boneWeightsBone weights for the colour model that shows the cut marks. Clients only.
private int bottomPointIndexIndex of the first of the bottom ring of woodcut points that decide a chop. -1 means the piece can't be chopped.
private bool btnCheckCompleteEditor button that runs CheckComplete.
private bool btnTakingRandomDamageEditor button that runs RandomDamage.
private Color[] colorsBacking field for Colors.
private WoodcutConnection[] connectionsBacking field for Connections: points where child pieces attach.
private PositionRotation[] dropLocationsWhere sticks or wedges spawn when the piece is chopped up. Set through DropLocations.
private int finishedDirectionBacking field for FinishedDirection: the bottom point the piece was chopped through. -1 until chopped.
private ImpactDetector impactDetectorThe tree's shared detector, whose hits go to HandleHit. Set by SetImpactDetector.
private float massBacking field for Mass. Added up through the tree to set the rigidbody's mass. 5 by default.
private Mesh[] meshesBacking field for Meshes, one per LOD. The first is used for the cut colour model.
private WoodcutConnectionType typeBacking field for Type: the connection type, which sets bone count, stick or wedge drops and how it breaks.
private WoodcutPointCollection woodcutPointsCollectionThe synced woodcut points that take damage. Backs WoodcutPoints and BottomPoints.

Properties​

MemberWhat it is
IEnumerable<WoodcutPointData> BottomPoints { get; }The woodcut points around the bottom of the segment, where it is chopped off.
Color[] Colors { get; }Colour data for the segment's mesh.
WoodcutConnection[] Connections { get; }Connection points where child segments attach.
ColorModelCore<NullColorModelPoint, NullColorModelPoint, NullColorModelPoint, WoodcutPointData> Core { get; private set; }Colour model that shows the chop marks on the mesh. Null on a headless server.
PositionRotation[] DropLocations { set; }Where sticks or wedges spawn when the segment is chopped up. Set only.
float DynamicMultiplier { get; set; }Damage multiplier, raised for segments of a felled (non-kinematic) tree.
int FinishedDirection { get; }Index of the point the segment was chopped from, or -1.
WoodcutTree.MapNode MapNode { get; set; }This segment's node in the tree's layout.
float Mass { get; }Mass of this segment.
PooledParticleSystemMeshEmision MeshEffect { get; set; }Particle effect for the segment's mesh.
Mesh[] Meshes { get; }LOD meshes for the segment.
WoodcutTree Tree { get; }The tree this segment belongs to.
WoodcutConnectionType Type { get; }The connection type, which says how many bones it has and whether it is a stick.
List<WoodcutPointData> WoodcutPoints { get; }All woodcut points on the segment.

Events​

MemberWhat it is
event WoodcutTreeModelChopped ChoppedRaised when the segment is chopped off its parent. The tree splits it into a new tree.
event WoodcutTreeModelDamaged TookDamageRaised with the total damage when a hit damages the segment.

Methods​

MemberWhat it is
bool CheckComplete()Server: checks the bottom points against the species thresholds and chops the segment if they are cut deep enough.
void Chop(int side)Marks the segment as chopped from a side and raises Chopped, unless it is the root segment.
override void Initialize()Sets up the colour model for chop marks, except on a headless server.
void PieceChopped()Server: spawns the species' sticks or wedges at the drop locations and destroys the segment.
void SetImpactDetector(ImpactDetector detector)Switches which impact detector's hits damage this segment.
2 private and internal methods
MemberWhat it is
private void HandleHit(ImpactHit impact)Spreads hit damage over the woodcut points by distance and species, plays the hit or done effect on clients, then checks for a chop.
private void RandomDamage()Editor button: gives every woodcut point a little random damage, then checks for a chop.

Used in​

Members of other types that take, return or hold a WoodcutTreeModel: