WoodcutTreeBaker
A class in Root.Township, Alta.Woodcutting.
Client component on a woodcut tree that combines its damaged trunk pieces and attachments into baked meshes in the distance LOD group, and updates the baked vertex colours as pieces are chopped. Does nothing on headless servers.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
WoodcutTreeBaker() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
19 private and internal fields
| Member | What it is |
|---|---|
private AtlasDefinition[] attachmentDefinitions | Atlas definitions for attachment renderers. |
private MeshFilter[] attachmentLodFilters | Mesh filters for baked attachment LODs. |
private MeshRenderer[] attachmentLodRenderers | Renderers for baked attachment LODs. |
private Mesh[] attachmentLods | Baked attachment meshes. |
private HashSet<TreeAttachment> attachments | Attachments currently included in the bake. |
private List<WoodcutTree.MapNode> damaged | Nodes with changed colours that are baked into the damaged mesh. |
private Mesh[] damagedLod | Baked damaged-node meshes. |
private MeshFilter[] damagedLodFilter | Mesh filters that show the damaged bake. |
private MeshRenderer[] damagedLodRenderer | Renderers that show the damaged bake. |
private List<int> damagedVertexOffset | Start vertex of each damaged node within the damaged mesh. |
private DistanceLODGroup distanceLODGroup | The tree's distance LOD group that renderers are added to and removed from. |
private bool isLeavesModified | Leaves dirty flag. |
private bool isLod0Modified | Set while a LOD 0 rebake is scheduled. |
private MeshFilter[] lodFilters | Mesh filters for trunk LODs. Not used in this class. |
private MeshRenderer[] lodRenderers | Renderers for trunk LODs. Not used in this class. |
private Mesh[] lods | Trunk LOD meshes. Cleaned up on destroy but never created in this class. |
private HashSet<WoodcutTree.MapNode> nodes | Tree nodes found during the last setup. |
private WoodcutTree tree | The woodcut tree being baked. |
private AtlasDefinition[] trunkDefinitions | Atlas definitions for trunk renderers. Not used in this class. |
Methods
11 private and internal methods
| Member | What it is |
|---|---|
private void Clear(ref Mesh[] meshes) | Cleans up an array of baked meshes and nulls it. |
private IEnumerator DelayRegenerateLeaves() (iterator) | Coroutine that regenerates leaves at the end of the frame. Not started anywhere. |
private IEnumerator DelayRegenerateLod0() (iterator) | Coroutine that rebakes the damaged LOD 0 mesh at the end of the frame. |
private void Generate() | Creates the baked meshes, bakes the damaged LOD 0 mesh and points the third attachment LOD at the second one's mesh. |
private void Initialize(WoodcutTree.MapNode node, List<Renderer>[] renderersToModify) | On clients, hooks Setup to the tree's ready-for-bake and chopped events. The private overload walks a node tree and collects its renderers and attachments. |
private void NodeModified(ColorModelCore<NullColorModelPoint, NullColorModelPoint, NullColorModelPoint, WoodcutPointData> core) | When a node's colours change, adds it to the damaged bake and schedules a rebake, or updates its colours in place if already baked. |
private void OnDestroy() | Cleans up all baked meshes. |
private void RegenerateLeaves() | Only clears the leaves modified flag; leaf rebaking is not done here. |
private void RegenerateLod0(bool isGeneratingUndamaged) | Bakes all damaged nodes into the damaged LOD mesh, hides their own first renderers and copies their colours in. |
private void Remove(TreeAttachment attachment) | Removes a broken or moved attachment from the baker and the LOD group. |
private void Setup() | Clears the previous bake, walks the tree from its root to rebuild LOD renderer lists, then calls Generate. |