C++ TheEarthOnline 用户开发手册 API
在 TheEarthOnline 中,你可以连接并调用现实世界,想使用 TheEarthOnline,先得调用 #include<TheEarthOnline> 库。
People
TheEarthOnline 添加了 People 类以调用人类。
创建
People 类创建语法如下:
template <class GENDER, class TYPE>
class People通俗一点,People 类用下列语句以创建一个新 People。
People<GENDER, TYPE> EarthPeopleID;GENDER
GENDER 确定了创建的性别,TheEarthOnline 提供了下列 种 GENDER 类。
GENDER | 解释 |
|---|---|
MALE | 男性 |
FEMALE | 女性 |
UNKNOWN | 未知 |
GENDERLESS | 无性 |
HERMAPHRODITE | |
WALMART_SHOPPING_BAG | 沃尔玛购物袋 |
GUNSHIP | 武装直升机 |
TYPE
TYPE 确定了创建的类型,TheEarthOnline 提供了下列 种 TYPE 类。
TYPE | 解释 |
|---|---|
PEOPLE | 人 |
GOD | 泛指神 |
DEVIL | 泛指魔、鬼 |
MAGICCAT | 魔法猫咪 |
MICHELIN | 米其林轮胎 |
EarthPeopleID
地球人类 ID,也就是创建的这个类的名字。
创建 People 类示例:
People<MALE, PEOPLE> linzilOng;
People<WALMART_SHOPPING_BAG, DEVIL> Oier;调用
在 People 类中,想要调用人类,首先要创建一个 PeopleComponent 类型的变量以调用。想要将某物的组件绑定到此变量,就要使用 PeopleGetComponet() 函数。
PeopleGetComponent()
PeopleGetComponent() 函数原型如下:
PeopleComponent* PeopleGetComponet(class People people, const* char component)People
输入想要调用的人类的 EarthPeopleID。
component
想要调用的人类组件,支持下列 种常量。
| 常量名 | 描述 |
|---|---|
EYES | 眼睛 |
BRAIN | 脑 |
BODY | 身体总控 |
HEART | 心脏 |
调用人类组件示例:
People<MALE, PEOPLE> Oier;
int main()
{
PeopleComponent eyes = PeopleGetComponent(Oier, EYES);
}组件
People 支持调用 种人类组件。
EYES 眼睛
EYES 支持以下几种调用:
| 名称 | 描述 |
|---|---|
open_left() | 睁左眼 |
open_right() | 睁右眼 |
close_left() | 闭左眼 |
close_right() | 闭右眼 |
blink() | 眨眼 |
lookat() | 看向某物 |
其中,blink() 函数原型为
void* blink(const* char type, int time)type 支持以下 种。
| 常量 | 描述 |
|---|---|
EYELFET | 左眼 |
EYERIGHT | 右眼 |
EYEALL | 双眼 |
time 指代闭上多久再睁眼,以 为单位。
lookat() 函数原型为
void lookat(char* object)object 指代 EarthID,比如 EarthPeopleID。
比如我们要让 People Oier 进行持续 的左眼 Wink,如下:
PeopleComponent eyes = PeopleGetComponent(Oier, EYES);
eyes.blink(EYELEFT, 200);BRAIN 脑
BRAIN 支持以下调用:
| 名称 | 描述 |
|---|---|
think() | 思考 |
thinkwith() | 思考某物 |
示例:
PeopleComponent brain = PeopleGetComponent(Oier, BRAIN);
brain.think();HEART 心脏
HEART 支持以下 种调用:
| 名称 | 描述 |
|---|---|
beat() | 单次跳动 |
repeat() | 循环跳动 |
stop() | 停止跳动 |
explode() | 爆炸 |
其中,repeat() 函数原型如下:
void* repeat(int length, int count)length 代表了跳动时长,以 为单位。count 代表了在 length 毫秒中跳动的次数,系统将自动平均在 length 中。
BODY 身体
BODY 支持以下调用:
| 名称 | 描述 |
|---|---|
die() | 死亡 |
其中,die() 函数原型如下:
void* die(const* char cause)cause 支持以下常量:
| 常量 | 描述 |
|---|---|
BODYOLD_AGE | 老死 |
BODYUSED_BRAIN | 用脑过度 |
BODYHEART_STOP | 心脏停止 |
BODYHEART_EXPLODE | 心脏爆炸 |