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.
- Listed in Global namespace: C to D
- Inherits or implements
MonoBehaviour - Documented in Hunger, eating and drinking
Constructors
| Member | What it is |
|---|---|
ConsumptionManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private bool canConsumeWastefully | If true, the player can consume whenever the stat is below maximum, even if the food would overflow it. |
private bool canConsumeWhenStatIsFull | If true, the stat check is skipped and the player can always consume. |
private Eater eater | The player's Eater. Not used by this class itself. |
private EffectHandler effectHandler | Effect handler that consumption effects are applied to. |
private float effectHandlingStrength | Multiplier on consumed effects' strength, used both for applying them and for the fullness check. |
private static Logger logger | NLog logger for this class. |
private PlayerDrinkingMouth mouth | The player's drinking mouth. Not used by this class itself. |
private PlayerController player | Backing field for Player. |
private AltaEvent rejectEdibleConsumption | Event played when the player tries to eat while too full. |
private AltaEvent rejectLiquidConsumption | Event played when the player tries to drink while too full. |
private Stat stat | The monitored stat instance from statManager. |
private StatManager statManager | Stat manager the monitored stat is read from. |
private StatDefinition statToMonitor | Stat definition that limits consumption (likely Fullness). |
Properties
| Member | What it is |
|---|---|
PlayerController Player { get; } | The PlayerController this manager belongs to. |
Methods
| Member | What 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
| Member | What 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: