HierarchyPlugin

View source

ExtendsPlugin

Adds synchronized parent/child hierarchy behavior to an App.

Use Children and Parent to describe an entity hierarchy. Adding Children adds or updates each child’s Parent; adding Parent adds the child to its parent’s Children. Removing a Parent removes the child from its parent’s list, and despawning an entity with Children recursively despawns its listed children. These relationships stay synchronized when the corresponding components change; the plugin does not create hierarchy entities for you.

Register CorePlugin and ReflectPlugin before HierarchyPlugin. The app validates these dependencies but does not install missing plugins automatically.

Examples

import { App } from '@wimaengine/app'
import { CorePlugin } from '@wimaengine/core'
import { HierarchyPlugin } from '@wimaengine/hierarchy'
import { ReflectPlugin } from '@wimaengine/reflect'

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new HierarchyPlugin())
  .run()
// Children and Parent relationships stay synchronized as entities change.

Constructor


constructor()

Methods


register(app: App): void

View source

Enables synchronized hierarchy behavior for Children and Parent components in an App.

Adding or removing either component keeps the parent/child relationship in sync. Despawning an entity with Children also despawns its listed descendants.

Parameters

NameDescriptionDefault
app

App to configure.

—

requires(): TypeId[]

View source

Returns the type IDs for the plugins required by this plugin.

The app must already have CorePlugin and ReflectPlugin registered; this plugin does not install missing dependencies automatically.

Returns

Required plugin TypeId values.