KBehavior

Represents a behavior that can be applied to a specific type with a given context.

Author

Devin

Since

1.1.7

Parameters

T

The type of the target this behavior is applied to.

C

The type of the context in which this behavior operates. Must implement KBehaviorContext.

KBehavior must be registered within the global behavior registry KBehaviorRegistry. To build a KBehavior you can use the kItemBehaviour builder function.

Inheritors

Properties

Link copied to clipboard
abstract val identifier: KIdentifier

Unique identifier for a behavior. This identifier is used to uniquely register a behavior within a registry and is composed of the plugin's name and a specific string identifier.

Functions

Link copied to clipboard
abstract fun behave(block: T.(context: C) -> Unit)

Sets the behavior logic for a target of type T within a specific context of type C. The behavior logic is provided in the form of a lambda function.

Link copied to clipboard
fun KBehavior<*, *>.register()

Registers this behavior within the global behavior registry.

Link copied to clipboard
abstract fun run(target: T, context: C)

Executes the behavior logic for the specified target within the provided context.