🏷️ 食物与饮品能量管理能力¶
tongsim.entity.ability.impl.consumable_energy ¶
tongsim.entity.ability.impl.consumable_energy
ConsumableEnergyAbility ¶
Bases: Protocol
ConsumableEnergyAbility 定义了食物与饮品能量管理的接口。
支持能量读取与设置,包括食物类型和饮品类型。
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
async_get_consumable_energy
async
¶
async_get_consumable_energy() -> tuple[float, float]
异步获取当前实体的抗饥饿值与抗口渴值。
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: (anti_hungry, anti_thirsty) |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
23 24 25 26 27 28 29 |
|
get_consumable_energy ¶
get_consumable_energy() -> tuple[float, float]
同步获取当前实体的抗饥饿值与抗口渴值。
Returns:
Type | Description |
---|---|
tuple[float, float]
|
tuple[float, float]: (anti_hungry, anti_thirsty) |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
31 32 33 34 35 36 37 |
|
async_set_edible_energy
async
¶
async_set_edible_energy(
anti_hungry: float, anti_thirsty: float, max_parts: int
) -> bool
异步设置当前实体的可食用能量值。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anti_hungry
|
float
|
抗饥饿值, 代表吃下该实体后, agent 的饥饿值会上升多少。范围: 0.0 ~ 2.0, agent 的饥饿值范围为 -1.0 ~ 1.0。 -1.0 代表完全饱腹 |
required |
anti_thirsty
|
float
|
抗口渴值, 代表吃下该实体后, agent 的口渴值会上升多少。范围: 0.0 ~ 2.0, agent 的口渴值范围为 -1.0 ~ 1.0。 -1.0 代表水分充足 |
required |
max_parts
|
int
|
吃完需要吃几口 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否成功。 |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
set_edible_energy ¶
set_edible_energy(
anti_hungry: float, anti_thirsty: float, max_parts: int
) -> bool
同步设置当前实体的可食用能量值。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anti_hungry
|
float
|
抗饥饿值, 代表吃下该实体后, agent 的饥饿值会上升多少。范围: 0.0 ~ 2.0, agent 的饥饿值范围为 -1.0 ~ 1.0。 -1.0 代表完全饱腹 |
required |
anti_thirsty
|
float
|
抗口渴值, 代表吃下该实体后, agent 的口渴值会上升多少。范围: 0.0 ~ 2.0, agent 的口渴值范围为 -1.0 ~ 1.0。 -1.0 代表水分充足 |
required |
max_parts
|
int
|
喝完需要喝几口 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否成功。 |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
async_set_beverage_energy
async
¶
async_set_beverage_energy(
anti_hungry: float, anti_thirsty: float, max_parts: int
) -> bool
异步设置当前实体的可饮用能量值。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anti_hungry
|
float
|
抗饥饿值, 代表喝下该实体后, agent 的饥饿值会上升多少。范围: 0.0 ~ 2.0, agent 的饥饿值范围为 -1.0 ~ 1.0。 -1.0 代表完全饱腹 |
required |
anti_thirsty
|
float
|
抗口渴值, 代表喝下该实体后, agent 的口渴值会上升多少。范围: 0.0 ~ 2.0, agent 的口渴值范围为 -1.0 ~ 1.0。 -1.0 代表水分充足 |
required |
max_parts
|
int
|
喝完需要喝几口 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否成功。 |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
set_beverage_energy ¶
set_beverage_energy(
anti_hungry: float, anti_thirsty: float, max_parts: int
) -> bool
同步设置当前实体的可饮用能量值。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anti_hungry
|
float
|
抗饥饿值, 代表喝下该实体后, agent 的饥饿值会上升多少。范围: 0.0 ~ 2.0, agent 的饥饿值范围为 -1.0 ~ 1.0。 -1.0 代表完全饱腹 |
required |
anti_thirsty
|
float
|
抗口渴值, 代表喝下该实体后, agent 的口渴值会上升多少。范围: 0.0 ~ 2.0, agent 的口渴值范围为 -1.0 ~ 1.0。 -1.0 代表水分充足 |
required |
max_parts
|
int
|
喝完需要喝几口 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否成功。 |
Source code in src\tongsim\entity\ability\impl\consumable_energy.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|