Energy

Energy is a Need common to all Cultivators and Mortals, and is a measure of how tired they are.
==Mechanics==
A character will interrupt their task and start sleeping on the spot when their energy falls below 30, 20 and 0.01XiaWorld.RestNeed.OnLevelChange(), unless their sleep was interrupted recently. Moreover, if they were doing a task when they fell asleep, they'll wake up again once their energy reaches 30 - which counts as sleep interrupted, with the associated negative moodlet and the "Can't sleep" modifier for 100s.
Assuming standard Energy Consumption Bonus and Energy Replenishment Bonus values, a Mortal will want a bit more than 6 hours of sleep every day. However as disciples will sleep until their energy is recovered, and never oversleep, there's no harm having additional sleep scheduled throughout the day. This also avoids the disciples falling asleep on the job as will happen if their energy falls below 30.
== Going to sleep ==
All characters will choose to sleep (as a behaviour)CommandTakeRest.CouldBeFind():
* if they're in the Sect map and not fighting
* during a "Work" or "Sleep" period on the Work Schedule Planner if their Energy is between 0.01 and 30: however as they'll fall asleep on the spot if their energy falls below 30, this happens infrequently
* during a "Practice" or "Eat" period on the Work Schedule Planner if their energy is <0.01, same as above.
Moreover, an outer will also choose to sleep during a "Sleep" period on the Work Schedule Planner and their Energy is < 75. 
The sleep duration is set until the disciple recovers Energy fully. If they're in an Injury-induced sleep or their health is below 70%, their sleep can't be interrupted. Otherwise, they'll stop sleeping if their energy is above 30 and the Work Schedule Planner is on a "Practice" or "Eat" period. This is not treated as a sleep interruption and has no adverse consequences.
== Consumption ==
Energy consumption rate, the rate at which Energy is consumed, depends on a character's Energy Consumption Bonus. The higher this value, the faster Energy is lost per unit time. By equipping a high Tier Talisman of Spiritual Cleansing, it is possible to have this value be reduced to zero, therefore removing the need for sleep.
Energy decreases based on the followingXiaWorld.RestNeed.GetSubValue():
* 0 If the character is sleeping, in an non-Injury-related coma or in a Breakthrough.
* The current Biome Rest Multiplier, depending on the Character's Energy levelSettings/Biomes/BiomeBase.xml [Rest]. This value is constant for all non-modded maps, but can be changed by Mods.
Energy	Energy	Consumption /s
>= 	< 	Consumption /s
30 	 	0.146
20 	30 	0.073
0.01 	20 	0.0.37
 	0.01 	0.013
* If the character is in an Injury-related coma, the consumption is multiplied by 3
* Finally, the consumption is multiplied by the character's s Energy Consumption Bonus.
By default (with an Energy Consumption Bonus of 1), assuming an uninterrupted work schedule and an energy above 30, a character will consume 3.65 Energy per hour. Using those assumptions, It takes about 480s for a disciple to go from 100 Energy to 30, or 19 hours and 12 minutes.
==Restoration==
Mortals can only acquire Energy by sleeping, and lose Energy constantly while awake. Cultivators, however are considered to be resting during Cultivation (Practice for Xiandao Cultivation) and therefore can just recover Energy by cultivating.
The amount of Energy gained while sleeping depends on the location of sleep (Bed vs the Ground), as well as the character's Energy Replenishment Bonus. The formula is 0.417 * RestEffectiveness * EnergyReplenishmentBonus in energy/s. By default, with a RestEffectiveness and Energy Replenishment Bonus of 1, this means a recovery of 10.425 Energy per hour.
The Energy Restoration rate (RestEffectiveness) is as follows:
Sleep Location
ThingDefName	Energy Restoration
Bed
Bed	1Settings\ThingDef\Building\Building_Furniture.xml
Double Bed
DoubleBed	1.1
Bamboo BedDLC
BambooBed	1Settings\ThingDef\Building\Building_PANDA.xml
Pet's Bed
LsDogHouse	1Settings\ThingDef\Building\Building_LingShou.xml
Flooring
FloorBase	1Settings\ThingDef\Building\Building_Floor.xml
Ground	0.7XiaWorld.ToilTakeRest()
Beds should therefore be placed near the working locations of Disciples to ensure that they are less likely to sleep on the floor and receive negative Moodlets.
=== Ominous Room ===
Every 1 second, if the Character is sleeping in an Ominous room, a random roll will be carried outXiaWorld.ToilTakeRest.OnStepToil:
*Slightly Ominous: 0.01%
*Ominous: 0.02%
*Very Ominous: 0.05%
If this roll succeeds, a Cultivator will receive a single stack of Qi Overflow injurySettings\Npc\Damages\GongDamages.xml, and an Outer Disciple or Animal will immediately die of Heart Palpitations.
===Items===
No items can restore Energy directly, however certain items such as Talisman of Spiritual Cleansing can increase the rate at which Energy is gained. 
== Energy Moodlets ==
When the energy falls below certain thresholds, negative moodlets are acquired.
Energy	Energy	Moodlet 	Modifier	Description
>= 	< 	Moodlet 	Modifier	Description
20 	30 	Tired 	-8 	Some sleep would hit the spot.
0.01 	20 	Fatigued 	-15 	If I don't get some rest, I'm liable to pass out.
 	0.01 	Exhausted	-25 	I feel like I'll pass out at any moment.
This "Tired" Moodlet is unrelated to the one obtained from dismissing a Sect or Branch Leader.
== References ==
Category:Game Mechanics
Category:Energy
Category:Needs