Skip to main content

Mermcandidate

Overview

This component tracks the calories consumed by a merm entity to determine whether it has accumulated enough energy to trigger a transformation into a stronger variant. It acts as a state manager for merm metamorphosis progression.

Dependencies & Tags

None identified.

Properties

PropertyTypeDefault ValueDescription
caloriesnumber0Current accumulated calorie count from consumed food.
transformation_caloriesnumber50Threshold of calories required for transformation to occur.

Main Functions

AddCalories(food)

  • Description: Adds the hunger value (calories) of the given edible item to the internal calorie counter. Only processes items with an edible component.
  • Parameters:
    • food (Entity): The food entity to consume; must have an edible component for calories to be added.

ResetCalories()

  • Description: Resets the current calorie count to zero, typically used after a successful transformation or to reset progress.
  • Parameters: None.

ShouldTransform()

  • Description: Returns true if the current calorie count meets or exceeds the transformation threshold, indicating the merm is ready to transform.
  • Parameters: None.

OnSave()

  • Description: Serializes the component's state for save/load purposes, returning a table containing current calorie and threshold values.
  • Parameters: None.
  • Returns: { calories: number, transformation_calories: number }

OnLoad(data)

  • Description: Restores component state from saved data, updating calories and transformation_calories if present in the input table.
  • Parameters:
    • data (table): Saved state data containing optional calories and transformation_calories keys.

Events & Listeners

None.