Sgcozy Bunnyman
Based on game build 722832 | Last updated: 2026-04-17
Overview
SGcozy_bunnyman is the stategraph responsible for controlling the animations, movement, and reactive behaviors of the Cozy Bunnyman prefab. It manages states for idling, combat, social interactions (cheer, dance, disappoint), and event-specific actions like pillowfighting or hiding. It relies heavily on commonstates for standard locomotion and status effects (sleep, freeze, death).
Usage example
local inst = CreateEntity()
inst:AddComponent("statemachinegraph")
inst.sg:LoadStateGraph("cozy_bunnyman")
-- Trigger a state change via event
inst:PushEvent("cheer", { text = "Yay!" })
-- Manually transition state
inst.sg:GoToState("idle")
Dependencies & tags
External dependencies:
stategraphs/commonstates-- Provides standard handlers for locomotion, sleep, freeze, death, and hopping.
Components used:
locomotor-- Controls movement speed and stopping during states.talker-- Displays speech bubbles during emotes.health-- Checks death status and health percentage for panic logic.combat-- Manages attack targeting and execution.follower-- Tracks leader entity and loyalty percentage.leader-- Checks if leader is roll calling.inventory-- Handles item giving during eat state.entitytracker-- Tracks specific entities like carrots.lootdropper-- Spawns loot on death.timer-- Manages hide duration timers.
Tags:
idle-- Added when idle or creepy.canrotate-- Allows entity rotation during idle/emote states.emote-- Marks social animation states.busy-- Prevents interruption during actions.attack-- Marks combat states.noattack-- Prevents attacking during spawn/despawn.hide-- Marks hidden states.alert-- Marks alert state.jumping-- Marks knockback state.sleeping-- Added by CommonHandlers.frozen-- Added by CommonHandlers.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
AREACLEAR_COMBAT | table | {"_combat"} | Tags used to check for combat entities during hide logic. |
AREACLEAR_CHECK_FOR_HOSTILES | table | {"hostile", "monster"} | Tags used to check for hostile entities during hide logic. |
RINGOUT_TEXT_DATA | table | {text = STRINGS.RABBIT_GIVEUP} | Default text data for ringout disappointment. |
Main functions
State: "idle"
- Description: Default resting state. Plays idle animations and stops movement.
- Parameters:
inst-- Entity instance.data-- State data (unused).
- Returns: None
- Error states: None
State: "cheer"
- Description: Plays happy animation and optional speech.
- Parameters:
inst-- Entity instance.data-- Table containingtext(string or table of strings).
- Returns: None
- Error states: Errors if
inst.components.talkeris nil whendata.textis provided.
State: "dance"
- Description: Plays dance animation with sound effect and optional speech.
- Parameters:
inst-- Entity instance.data-- Table containingtext.
- Returns: None
- Error states: Errors if
inst.components.talkeris nil whendata.textis provided.
State: "disappoint"
- Description: Plays abandonment animation and optional speech.
- Parameters:
inst-- Entity instance.data-- Table containingtext.
- Returns: None
- Error states: Errors if
inst.components.talkeris nil whendata.textis provided.
State: "creepy"
- Description: Plays creepy idle animation and optional speech.
- Parameters:
inst-- Entity instance.data-- Table containingtext.
- Returns: None
- Error states: Errors if
inst.components.talkeris nil whendata.textis provided.
State: "reject"
- Description: Plays rejection animation and optional speech.
- Parameters:
inst-- Entity instance.data-- Table containingtext.
- Returns: None
- Error states: Errors if
inst.components.talkeris nil whendata.textis provided.
State: "funnyidle"
- Description: Dynamic idle state that changes animation based on health, loyalty, and combat status.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: Errors if
inst.components.health,inst.components.follower, orinst.components.combatare nil.
State: "death"
- Description: Plays death animation, stops physics, and drops loot.
- Parameters:
inst-- Entity instance.data-- Table containingafflicter.
- Returns: None
- Error states: Errors if
inst.components.lootdropperis nil.
State: "abandon"
- Description: Plays abandonment animation while facing a leader entity.
- Parameters:
inst-- Entity instance.leader-- Leader entity to face (can be nil).
- Returns: None
- Error states: None
State: "attack"
- Description: Executes standard attack animation and combat logic.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: Errors if
inst.components.combatis nil.
State: "attack_object"
- Description: Executes overhead attack animation for objects.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: Errors if
inst.components.combatis nil.
State: "attack_object_pre_idle"
- Description: Pre-attack idle state for overhead attacks with looping animation.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "eat"
- Description: Handles eating logic, including special hareball barf behavior.
- Parameters:
inst-- Entity instance.data-- State data.
- Returns: None
- Error states: Errors if
inst.components.inventoryorinst.components.entitytrackeris nil during specific logic branches.
State: "disgust"
- Description: Plays disgust animation with rotation loops and sound effects.
- Parameters:
inst-- Entity instance.data-- Table containingloopcount(optional loop counter).
- Returns: None
- Error states: None (data parameter is nil-checked before access)
State: "hide"
- Description: Hides the entity and schedules re-emergence based on area safety.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: Errors if
inst.components.timerorinst.components.healthis nil.
State: "alert"
- Description: Alert state playing attention animation sequence.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "knockback"
- Description: Applies physics knockback away from a source.
- Parameters:
inst-- Entity instance.data-- Table containingradius,knocker,strengthmult.
- Returns: None
- Error states: Errors if
inst.components.healthis nil (no nil check beforeIsDead()).
State: "spawn_pre", State: "spawn_loop", State: "spawn_pst"
- Description: Sequence for spawning from the ground.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "despawn"
- Description: Removes the entity after animation.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "digtolocation"
- Description: Teleports entity to a specific location with spawn effects.
- Parameters:
inst-- Entity instance.data-- Table containingpos,arena.
- Returns: None
- Error states: None
State: "pickup"
- Description: Handles item pickup actions, including body pillows.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "gottoken"
- Description: Reaction to receiving a token.
- Parameters:
inst-- Entity instance.data-- Table containingtext.
- Returns: None
- Error states: Errors if
inst.components.healthis nil (no nil check beforeIsDead()in event handler).
CommonStates.AddWalkStates
- Description: Adds standard walking states and timeline logic.
- Parameters:
statestable, configuration tables. - Returns: None
- Error states: None
CommonStates.AddRunStates
- Description: Adds standard running states and timeline logic.
- Parameters:
statestable, configuration tables. - Returns: None
- Error states: None
State: "hit"
- Description: Damage response state playing hurt animation and recovery.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "refuse"
- Description: Rejection state added via CommonStates helper with pig_reject animation.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
State: "attack_object_pre"
- Description: Pre-attack state for overhead attacks, sets is_holding_overhead memory flag.
- Parameters:
inst-- Entity instance. - Returns: None
- Error states: None
Events & listeners
-
Listens to:
gobacktocave-- Transitions todespawnif not busy/sleeping.cheer-- Transitions tocheerstate if idle.disappoint-- Transitions todisappointstate if idle.dance-- Transitions todancestate if idle.reject-- Transitions torejectstate if idle.question-- Transitions tocreepystate if idle.hide-- Transitions tohidestate if not busy.digtolocation-- Transitions todigtolocationstate if not busy/sleeping.raiseobject-- Transitions toattack_object_prestate.pillowfight_ringout-- Transitions todisappointif alive.doattack-- Transitions toattackorattack_objectstate.pillowfight_ended-- Transitions tocheerordisappointbased on win status.knockback-- Transitions toknockbackstate if alive.gotyotrtoken-- Transitions togottokenstate if alive.cheating-- Transitions todisappointstate if alive.animover-- Internal event to return toidleafter animations.animqueueover-- Internal event to return toidleafter animation queues.OnStep,OnLocomote,OnSleep,OnFreeze,OnAttacked,OnDeath,OnHop,OnSink,OnFallInVoid-- Common stategraph handlers.
-
Pushes:
pillowfight_fighterarrived-- Pushed by arena component duringdigtolocation.oneaten-- Pushed to hareball item duringeatstate.locomote-- Pushed by locomotor component during movement states.