Sglightflier
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGlightflier defines the state machine for the lightflier entity, controlling its movement, actions, and reactions in the game world. It uses the StateGraph framework to transition between states such as idle, action, startled, and go_home, and integrates with common state helpers for locomotion, combat, sleep, freeze, and electrocution behaviors. Flying-specific logic (e.g., buzz enabling/disabling, liftoff/land transitions) is implemented via helper functions and extended using CommonStates.
Usage example
local inst = CreateEntity()
inst:AddTag("lightflier")
inst:AddComponent("stategraph")
inst.components.stategraph:SetStateGraph("SGlightflier")
-- The stategraph activates automatically upon initialization
Dependencies & tags
Components used: None directly referenced (uses inst.Physics, inst.AnimState, inst.SoundEmitter, inst.sg, and buffered action APIs provided by core engine).
Tags: None added/removed by this stategraph itself. State-specific tags include "idle", "canrotate" (on idle), and "busy" (on startled, go_home).
Properties
No public properties.
Main functions
Not applicable.
Events & listeners
- Listens to:
animover— triggers transition back toidleafter animation completion inidle,action, andstartledstates.startled— enters thestartledstate unless currently electrocuted.GOHOMEaction (viaActionHandler) — initiates thego_homestate.- Common handlers:
OnLocomote,OnFreeze,OnElectrocute,OnAttacked,OnDeath,OnSleepEx,OnWakeEx(imported fromcommonstates.lua).
- Pushes: No events are directly pushed by this stategraph; it relies on external systems to fire events and uses internal transitions via
GoToState.