Beefalometrics
Overview
The beefalometrics component is attached to beefalo entities to monitor and report analytics related to their domestication lifecycle. It listens for key events such as being fed, brushed, ridden, attacked, or dying, and pushes this data to the game's metrics system. The component also tracks the last player who interacted with the beefalo for domestication purposes, ensuring this information persists across game sessions.
Dependencies & Tags
Dependencies:
uniqueid: Used to identify the specific beefalo in metrics events.domesticatable: Used to get domestication levels and status.rideable: Used to track rider information and mounted combat events.
Tags:
- None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | entity | inst | A reference to the entity instance this component is attached to. |
lastdomesticator | entity (player) | nil | A runtime reference to the last player who performed a domestication action (e.g., feeding, brushing). |
lastdomesticator_id | string | nil | The User ID of the last domesticator, used for persistence across game saves. |
ridestarttime | number | nil | Stores the game time when a player starts riding the beefalo, used to calculate ride duration. |
Main Functions
SetLastDomesticator(player)
- Description: Sets or updates the last player who performed a domestication-related action on the beefalo. This clears any previously stored user ID.
- Parameters:
player(entity): The player entity to be set as the last domesticator.
GetLastDomesticator()
- Description: Retrieves the last known domesticator. It prioritizes the active player entity reference. If that is unavailable, it attempts to find the player in the world using the saved
lastdomesticator_id. - Parameters: None.
OnSave()
- Description: Called when the game saves. It packages the
useridof thelastdomesticatorfor persistence. - Parameters: None.
OnLoad(data)
- Description: Called when the game loads. It restores the
lastdomesticator_idfrom the saved data. - Parameters:
data(table): The saved data table containing thelastdomesticator_id.
Events & Listeners
This component listens for several events on its owner entity to trigger metrics reporting.
- Listens to
domesticationdelta: Pushes abeefalo.domestication.startmetric when domestication first begins (i.e., when the value changes from 0 to greater than 0). - Listens to
oneat: Pushes abeefalo.domestication.feedmetric when the beefalo is fed. Records the feeder as thelastdomesticator. - Listens to
brushed: Pushes abeefalo.domestication.brushedmetric when the beefalo is brushed. Records the brusher as thelastdomesticator. - Listens to
domesticated: Pushes abeefalo.domestication.domesticatedmetric when the beefalo becomes fully domesticated, including tendency data. - Listens to
goneferal: Pushes abeefalo.domestication.feralmetric when the beefalo reverts to a feral state. - Listens to
death: Pushes abeefalo.domestication.deathmetric if a beefalo with any amount of domestication dies. - Listens to
riderchanged: Tracks ride duration. When a rider dismounts, it pushes abeefalo.domestication.ridemetric with the total ride time. - Listens to
attacked: Pushes abeefalo.domestication.mountedattackedmetric if the beefalo is attacked while being ridden. - Listens to
riderdoattackother: Pushes abeefalo.domestication.mountedattackmetric when the rider initiates an attack while mounted.