Skip to main content

ConsumptionManager

A class in Root.Township, the global namespace.

Component on the player that decides whether they can eat or drink something (based on a stat such as Fullness) and applies the food's effects. Used by Eater, PlayerDrinkingMouth and EdibleObject.

Constructors​

MemberWhat it is
ConsumptionManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private bool canConsumeWastefullyIf true, the player can consume whenever the stat is below maximum, even if the food would overflow it.
private bool canConsumeWhenStatIsFullIf true, the stat check is skipped and the player can always consume.
private Eater eaterThe player's Eater. Not used by this class itself.
private EffectHandler effectHandlerEffect handler that consumption effects are applied to.
private float effectHandlingStrengthMultiplier on consumed effects' strength, used both for applying them and for the fullness check.
private static Logger loggerNLog logger for this class.
private PlayerDrinkingMouth mouthThe player's drinking mouth. Not used by this class itself.
private PlayerController playerBacking field for Player.
private AltaEvent rejectEdibleConsumptionEvent played when the player tries to eat while too full.
private AltaEvent rejectLiquidConsumptionEvent played when the player tries to drink while too full.
private Stat statThe monitored stat instance from statManager.
private StatManager statManagerStat manager the monitored stat is read from.
private StatDefinition statToMonitorStat definition that limits consumption (likely Fullness).

Properties​

MemberWhat it is
PlayerController Player { get; }The PlayerController this manager belongs to.

Methods​

MemberWhat it is
bool AreValidEffects(IEnumerable<EffectDefinitionApplication> effects)True if consuming these effects wouldn't push the monitored stat over its maximum (or always, with canConsumeWhenStatIsFull).
bool CanConsumeEdible(EdibleObject edible)Whether the player can eat this food. False in spirit form; plays the reject event if the stat is too full.
bool CanConsumeLiquid(LiquidData liquid)Whether the player can drink this liquid. False for null or in spirit form; plays the reject event if too full.
4 private and internal methods
MemberWhat it is
private void Awake()Looks up the monitored stat and the owning PlayerController.
internal void HandleConsumptionEffects(IEnumerable<EffectDefinitionApplication> effects)Applies each effect through the effect handler and forces a server update of any stat an indirect modifier targets. Called on the server.
internal void HandleFailedDrinking(LiquidData liquid)Client: fires the reject-drink event for the local player.
internal void HandleFailedEating(EdibleObject edible)Client: fires the reject-eat event for the local player.

Used in​

Members of other types that take, return or hold a ConsumptionManager: