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.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour - Derived types
UnityWoodcutTreeModelEvent,WoodcutTreeModelEvent - Documented in Farming, woodcutting and carpentry
Constructors
| Member | What it is |
|---|---|
WoodcutTreeModel() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private BoneWeight[] boneWeights | Bone weights for the colour model that shows the cut marks. Clients only. |
private int bottomPointIndex | Index of the first of the bottom ring of woodcut points that decide a chop. -1 means the piece can't be chopped. |
private bool btnCheckComplete | Editor button that runs CheckComplete. |
private bool btnTakingRandomDamage | Editor button that runs RandomDamage. |
private Color[] colors | Backing field for Colors. |
private WoodcutConnection[] connections | Backing field for Connections: points where child pieces attach. |
private PositionRotation[] dropLocations | Where sticks or wedges spawn when the piece is chopped up. Set through DropLocations. |
private int finishedDirection | Backing field for FinishedDirection: the bottom point the piece was chopped through. -1 until chopped. |
private ImpactDetector impactDetector | The tree's shared detector, whose hits go to HandleHit. Set by SetImpactDetector. |
private float mass | Backing field for Mass. Added up through the tree to set the rigidbody's mass. 5 by default. |
private Mesh[] meshes | Backing field for Meshes, one per LOD. The first is used for the cut colour model. |
private WoodcutConnectionType type | Backing field for Type: the connection type, which sets bone count, stick or wedge drops and how it breaks. |
private WoodcutPointCollection woodcutPointsCollection | The synced woodcut points that take damage. Backs WoodcutPoints and BottomPoints. |
Properties
| Member | What 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
| Member | What it is |
|---|---|
event WoodcutTreeModelChopped Chopped | Raised when the segment is chopped off its parent. The tree splits it into a new tree. |
event WoodcutTreeModelDamaged TookDamage | Raised with the total damage when a hit damages the segment. |
Methods
| Member | What 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
| Member | What 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:
WoodcutConnection.model, WoodcutConnection.Model, WoodcutConnectionType.Break, WoodcutTree.Add, WoodcutTree.CheckAttachment, WoodcutTree.HandleSplit, WoodcutTree.LookForChildren, WoodcutTree.ModelChopped, WoodcutTree.OnPartTookDamage, WoodcutTree.MapNode.Model, WoodcutTreeModelChopped.BeginInvoke, WoodcutTreeModelChopped.Invoke, WoodcutTreeModelDamaged.BeginInvoke, WoodcutTreeModelDamaged.Invoke.