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
| Member | What it is |
|---|
TreeAttachment() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|
private AttachmentEvent broken | Event invoked on Break. The Broken event adds to it. |
private float forceBreak | Force that breaks the attachment off. -1 or less means force never breaks it. |
private MeshRenderer imposter | Backing field for Imposter, the far imposter renderer, added last to Renderers if set. |
private bool isBreakingOnUnroot | Whether Unroot breaks the attachment off. |
private Mesh[] pcMeshes | Backing field for Lods, the LOD meshes used to build Renderers. |
private MethodSync syncBroken | Method sync made in Initialize for SyncBreak. |
Properties
| Member | What 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
| Member | What it is |
|---|
private int IBuildRendererBakeable.SortingOrder { get; } | Bake order for this bakeable: 1. |
Events
| Member | What it is |
|---|
event Action<TreeAttachment> Broken | Raised when the attachment breaks. WoodcutTree uses it to remove the attachment. |
event Action<TreeAttachment> Moved | Raised by OnMoved when the tree baker moves the attachment. |
Methods
| Member | What 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
| Member | What 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:
WoodcutTree.SyncAttachment, WoodcutTree.MapNode.AddAttachment, WoodcutTree.MapNode.Attachments, WoodcutTree.MapNode.RemoveAttachment, WoodcutTreeAttachmentBaker.GetAttachmentMaterial, WoodcutTreeAttachmentBaker.GetLodCount, WoodcutTreeAttachmentBaker.GetMaterial, WoodcutTreeAttachmentBaker.GetMesh, WoodcutTreeAttachmentBaker.GetName, WoodcutTreeAttachmentBaker.GetTransform, WoodcutTreeAttachmentBaker.IsValid, WoodcutTreeBaker.attachments, WoodcutTreeBaker.Remove.