Skip to main content

TreeAttachment

A class in Root.Township, Alta.Woodcutting.

Something attached to a tree's node, such as leaves, that can break off. Attached by WoodcutTree; breaking is synced from the server.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private AttachmentEvent brokenEvent invoked on Break. The Broken event adds to it.
private float forceBreakForce that breaks the attachment off. -1 or less means force never breaks it.
private MeshRenderer imposterBacking field for Imposter, the far imposter renderer, added last to Renderers if set.
private bool isBreakingOnUnrootWhether Unroot breaks the attachment off.
private Mesh[] pcMeshesBacking field for Lods, the LOD meshes used to build Renderers.
private MethodSync syncBrokenMethod sync made in Initialize for SyncBreak.

Properties​

MemberWhat it is
WoodcutTree.MapNode AttachedTo { get; set; }The tree map node this attachment hangs on.
Renderer Imposter { get; }The far-distance imposter renderer, if any.
Mesh[] Lods { get; }The LOD meshes for this attachment.
MeshRenderer[] Renderers { get; private set; }The renderers built by GenerateRenderers, null before that.
1 private and internal property
MemberWhat it is
private int IBuildRendererBakeable.SortingOrder { get; }Bake order for this bakeable: 1.

Events​

MemberWhat it is
event Action<TreeAttachment> BrokenRaised when the attachment breaks. WoodcutTree uses it to remove the attachment.
event Action<TreeAttachment> MovedRaised by OnMoved when the tree baker moves the attachment.

Methods​

MemberWhat it is
void Break()Raises Broken; on the server also tells clients to break it.
void CheckForce(float forceSquared)Breaks the attachment if it has a break force set and the given squared force is above it. Called by the tree on impacts.
void GenerateRenderers(AtlasDefinition[] attachmentDefinitions)Builds one renderer per LOD mesh (plus the imposter) once, with atlased materials from the baker.
override void Initialize()Sets up the synced break message.
void OnMoved()Raises Moved. Called by WoodcutTreeBaker.
void Unroot()Breaks the attachment if it is set to break when the tree is uprooted.
4 private and internal methods
MemberWhat it is
private void IBuildRendererBakeable.Bake(bool isSaving)Build bake hook. Empty.
private void IBuildRendererBakeable.Clean()Build clean hook. Empty.
private MeshRenderer GetRendererAtLOD(int lod)Makes a "Leaves LOD" child with the LOD mesh, atlased with the material from WoodcutTreeAttachmentBaker.
private void SyncBreak(IPlayer player, Stream stream)Method sync sent by the server on Break. Clients run Break when they get it.

Used in​

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