EdibleObject
A class in Root.Township, the global namespace.
Makes a pickup edible: bites over time at the mouth, then the server applies its effects and destroys it unless it's docked. Eating also adds the item to the edible pages.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour - Derived types
EdibleEvent,EdibleUnityEvent - Nested types
EatenStage - Documented in Hunger, eating and drinking
Constructors
| Member | What it is |
|---|---|
EdibleObject() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private EdibleObject.EatenStage biteEffects | Bite count, duration per bite and bite effect for this food. |
private AnimationCurve biteHaptic | Haptic curve played on each bite. |
private Dictionary<ConsumptionManager, Coroutine> consumers | Eating coroutines running, one per ConsumptionManager. |
private EffectDefinitionApplication[] consumptionEffects | Backing field for ConsumptionEffects. |
private int currentBites | Bites taken so far by the current holder. |
private EdibleEvent finishedEating | Backing field for FinishedEating. |
private NetworkEntity holdingEntity | The entity holding the food, so bites carry over while the same one holds it. |
private static Logger logger | NLog logger for this class. |
private Pickup pickup | The food's pickup. |
private Coroutine resetingBites | The pending bite-reset coroutine, if any. |
Properties
| Member | What it is |
|---|---|
EffectDefinitionApplication[] ConsumptionEffects { get; } | Effects applied to whoever finishes eating it. |
EdibleEvent FinishedEating { get; } | Raised on both sides when the last bite is done. |
Methods
| Member | What it is |
|---|---|
bool StartEat(ConsumptionManager consumer, Transform mouth) | Starts the biting coroutine for a consumer. False if disabled or that consumer is already eating. |
void StopEat(ConsumptionManager consumer) | Stops a consumer's biting. Bite count is kept until the item is let go. |
6 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the pickup's grab and release events to track who is eating. |
private void BiteEffects() | Client: plays the bite sound and haptics on every hand holding the food. |
private void ResetBites(Interactable interactable, Interactor interactor) | On release, resets the bite count after half a second (straight away if inactive). |
private IEnumerator ResetBites() (iterator) | On release, resets the bite count after half a second (straight away if inactive). |
private IEnumerator StartEating(ConsumptionManager consumer, Transform mouth) (iterator) | Coroutine for one eat: plays bite effects each bite, then applies effects (server), fires FinishedEating, unlocks the food page and destroys the food if not docked. |
private void StartHolding(Interactable interactable, Interactor interactor) | On grab, cancels a pending bite reset and starts the count again if a different entity picked it up. |
Used in
Members of other types that take, return or hold a EdibleObject: