Skip to main content

Lunarthrall Plant Gestalt Brain

Based on game build 714014 | Last updated: 2026-02-27

Overview

This brain component governs the behavior of Lunarthrall Plant Gestalt entities — mobile entities that seek to infest specific plants. It implements a behavior tree (BT) that prioritizes movement logic based on plant proximity and player visibility. When a valid target plant exists and the gestalt is within close range, it triggers the "infest" state. If the target is too far or invalid, or no target is available, it generates randomized movement paths to stay offscreen while waiting for respawn opportunities. It relies on the lunarthrall_plantspawner component for plant validation and offscreen teleportation logic.

Dependencies & Tags

  • Components used:
    • inst.components.timer — to check for the "justspawned" timer (via TimerExists("justspawned"))
    • TheWorld.components.lunarthrall_plantspawner — to:
      • call FindPlant() for plant revalidation
      • call MoveGestaltToPlant(inst) for offscreen positioning
  • Tags: None identified.
  • Behaviors used: follow, wander, standstill, faceentity are imported but not directly used in the current implementation.

Properties

The constructor does not define any explicit instance properties. All state is carried on inst, which is the entity instance to which the brain is attached.

PropertyTypeDefault ValueDescription
inst.plant_targetEntity or nilnilReference to the target plant the gestalt is moving toward. Set externally or updated in MoveToPointAction.
inst.randomdirectionnumber (radians)nilPersisted random direction used for wandering; initialized on first use.
inst.sgStateGraphReference to the entity's state graph, accessed during action resolution.
inst.btBTBehavior tree root assigned in OnStart.

Main Functions

MoveToPointAction(inst)

  • Description: Helper function that computes a target position for the gestalt to move toward. It evaluates the entity's plant_target and current player visibility. It may cause the entity to infest a plant, move toward the plant, or generate a random position offscreen.
  • Parameters:
    • inst (Entity): The entity instance (typically the gestalt) requesting movement action.
  • Returns:
    • BufferedAction or nil: A buffered walk action toward the computed pos, or nil if no position was set.

LunarThrall_Plant_Gestalt_Brain:OnStart()

  • Description: Initializes the brain's behavior tree on start. Sets up a root PriorityNode that continuously executes MoveToPointAction while the entity is in the "idle" state tag.
  • Parameters: None.
  • Returns: None. Assigns self.bt to a BT instance with a behavior tree rooted in a PriorityNode.

Events & Listeners

None identified.