Closeinspector
Overview
This component provides a mechanism for an entity to define and execute custom logic when it is "inspected" in close proximity, either by targeting another entity or a specific point. It acts as a configurable interface for defining contextual close-range interactions, typically beyond standard combat or interaction components, allowing other systems to query and trigger these custom behaviors.
Dependencies & Tags
- Dependencies: None identified.
- Tags Added:
closeinspector(on initialization and removed on removal).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inspecttargetfn | function | nil | A callback function invoked when CloseInspectTarget is called. Expected to return success (boolean) and an optional reason (string). |
inspectpointfn | function | nil | A callback function invoked when CloseInspectPoint is called. Expected to return success (boolean) and an optional reason (string). |
Main Functions
OnRemoveFromEntity()
- Description: Called automatically when this component is removed from its owning entity. It ensures the
closeinspectortag is removed from the entity. - Parameters: None.
SetInspectTargetFn(fn)
- Description: Sets the custom callback function that will be executed when an entity attempts to "close inspect" another target. This function defines the specific logic for target inspection.
- Parameters:
fn: (function) The callback function to set. It is expected to take(inst, doer, target)as arguments (whereinstis the component's owner,doeris the inspecting entity, andtargetis the entity being inspected) and should returnsuccess(boolean) and an optionalreason(string).
SetInspectPointFn(fn)
- Description: Sets the custom callback function that will be executed when an entity attempts to "close inspect" a specific point in the world. This function defines the specific logic for point inspection.
- Parameters:
fn: (function) The callback function to set. It is expected to take(inst, doer, pt)as arguments (whereinstis the component's owner,doeris the inspecting entity, andptis aVector3representing the inspected point) and should returnsuccess(boolean) and an optionalreason(string).
CloseInspectTarget(doer, target)
- Description: Triggers the custom inspection logic for a target if a callback function (
inspecttargetfn) has been previously set usingSetInspectTargetFn. - Parameters:
doer: (Entity) The entity initiating the inspection.target: (Entity) The entity being inspected.
- Returns: The results (
success,reason) from theinspecttargetfncallback if it exists, otherwisenil.
CloseInspectPoint(doer, pt)
- Description: Triggers the custom inspection logic for a specific point if a callback function (
inspectpointfn) has been previously set usingSetInspectPointFn. - Parameters:
doer: (Entity) The entity initiating the inspection.pt: (Vector3) The point (coordinates) in the world being inspected.
- Returns: The results (
success,reason) from theinspectpointfncallback if it exists, otherwisenil.