Sgmoonpig
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGmoonpig defines the state graph for the Werepig entity, managing its core gameplay behaviors such as idle, run, attack, howl, and death animations/sequences. It integrates with the ECS by reacting to events (e.g., combat, damage, work requests) and invoking functions on components like combat, locomotor, health, and lootdropper. This stategraph is part of the stategraphs domain and is used by AI-controlled characters.
Usage example
-- The stategraph is registered automatically for the 'moonpig' prefab
-- To spawn or inspect a Werepig's state graph:
local pig = SpawnPrefab("moonpig")
if pig and pig.sg then
pig.sg:GoToState("howl")
end
Dependencies & tags
Components used: combat, health, locomotor, lootdropper, workable
Tags added: busy, idle, canrotate, moving, running, attack, working, noelectrocute
Tags checked: electrocute, busy, hiding
Properties
No public properties. State memory is stored internally in inst.sg.statemem.
Main functions
This stategraph does not expose public functions beyond those provided by the StateGraph engine. It is initialized and managed by the game engine when the moonpig entity is instantiated.
Events & listeners
-
Listens to:
OnStep— viaCommonHandlers.OnStep()OnLocomote— viaCommonHandlers.OnLocomote(true, false)OnSleep— viaCommonHandlers.OnSleep()OnFreeze— viaCommonHandlers.OnFreeze()OnElectrocute— viaCommonHandlers.OnElectrocute()OnAttack— viaCommonHandlers.OnAttack()OnAttacked— viaCommonHandlers.OnAttacked()OnIpecacPoop— viaCommonHandlers.OnIpecacPoop()death— triggersdeathstate, passesdeadflaggiveuptarget— transitions tohowlif target lost and not electrocutednewcombattarget— plays howl or idle sound on acquiring a new targetworkmoonbase— triggersworkmoonbasestate if working on a valid Moon Baseanimover,animqueueover— transitions between animation-dependent statestimeout— inrunstate, loops run animation
-
Pushes:
- None — only responds to events; does not fire custom events.