EasyBox3Lib~ Thing

一个(或一组)物品

Constructor

new Thing(id, stackSize, data)

定义一个(或一组)物品

Parameters:
NameTypeDefaultDescription
idstring

物品的id。应该是已经注册的物品id。如果data不为空对象时,最大为1

stackSizenumber1

该物品的堆叠数量,最大为该物品的最大堆叠数量

dataobject

该物品的数据

Members

id :string

物品id

Type:
  • string

stackSize :number

物品堆叠数量,如果有数据将不能再堆叠

Type:
  • number

name :string

该物品显示名称

Type:
  • string

data :object

物品数据

Type:
  • object

_wearing :boolean

该物品是否处于穿戴状态

Type:
  • boolean

item

该物品的类型

staticData

该物品的静态数据

tags

该物品的标签

maxStackSize

该物品的最大堆叠数量

stackable

该物品是否可堆叠

wearable

该物品的穿戴部件 如果为false,则该部件不可穿戴

wearing

该物品是否处于穿戴状态

wearing

设置物品穿戴状态

id :string

物品id

Type:
  • string

stackSize :number

物品堆叠数量,如果有数据将不能再堆叠

Type:
  • number

name :string

该物品显示名称

Type:
  • string

data :object

物品数据

Type:
  • object

_wearing :boolean

该物品是否处于穿戴状态

Type:
  • boolean

item

该物品的类型

staticData

该物品的静态数据

tags

该物品的标签

maxStackSize

该物品的最大堆叠数量

stackable

该物品是否可堆叠

wearable

该物品的穿戴部件 如果为false,则该部件不可穿戴

wearing

该物品是否处于穿戴状态

wearing

设置物品穿戴状态

Methods

(async) updateWear(entity)

对实体更新穿戴状态
更新后的实体会显示穿戴部件

Parameters:
NameTypeDescription
entityBox3Entity

要更新的实体

testSelector(selectorString) → {boolean}

测试该物品是否满足选择器的条件

Parameters:
NameTypeDescription
selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) setData(thing, data) → {Thing}

为一个物品设置data

Parameters:
NameTypeDescription
thingThing

要设置的物品

dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

setData(data) → {Thing}

为该物品设置data

Parameters:
NameTypeDescription
dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

(static) testSelector(thing, selectorString) → {boolean}

测试物品是否满足选择器的条件

Parameters:
NameTypeDescription
thingThing | object

要测试的物品

selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) from(source) → {Thing|null|undefined}

从一个object中生成一个Thing
这个object必须包含idstackingNumberdata属性
可以用此方法复制物品

Parameters:
NameTypeDescription
sourceobject

源对象

Returns:
Type: 
Thing | null | undefined

createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}

为该物品创建对应的实体

Parameters:
NameTypeDefaultDescription
positionBox3Vector3

实体位置

meshScaleBox3Vector3

实体尺寸

allowedPickupsbooleantrue

是否允许拾取

Returns:
Type: 
Box3Entity

toString() → {ThingString}

将物品转换为字符串

Returns:
Type: 
ThingString

(static) fromString(string)

从字符串中获取物品数据

Parameters:
NameTypeDescription
stringThingString

物品数据的字符串

(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}

打开物品对话框

Parameters:
NameTypeDescription
entityBox3Entity

打开对话框的实体

contentstring | ThingDialogCallback

对话框正文内容。如果为空,则读取对应Item的内容

optionsArray.<string>

对话框选项

otherOptionsBox3SelectDialogParams

可选,对话框的其他选项

Returns:

对话框选择结果

Type: 
Box3DialogSelectResponse

(async) use(entity) → {void}

使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品

Parameters:
NameTypeDescription
entityBox3Entity

使用物品的玩家

Returns:
Type: 
void

(async) updateWear(entity)

对实体更新穿戴状态
更新后的实体会显示穿戴部件

Parameters:
NameTypeDescription
entityBox3Entity

要更新的实体

testSelector(selectorString) → {boolean}

测试该物品是否满足选择器的条件

Parameters:
NameTypeDescription
selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) setData(thing, data) → {Thing}

为一个物品设置data

Parameters:
NameTypeDescription
thingThing

要设置的物品

dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

setData(data) → {Thing}

为该物品设置data

Parameters:
NameTypeDescription
dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

(static) testSelector(thing, selectorString) → {boolean}

测试物品是否满足选择器的条件

Parameters:
NameTypeDescription
thingThing | object

要测试的物品

selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) from(source) → {Thing|null|undefined}

从一个object中生成一个Thing
这个object必须包含idstackingNumberdata属性
可以用此方法复制物品

Parameters:
NameTypeDescription
sourceobject

源对象

Returns:
Type: 
Thing | null | undefined

createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}

为该物品创建对应的实体

Parameters:
NameTypeDefaultDescription
positionBox3Vector3

实体位置

meshScaleBox3Vector3

实体尺寸

allowedPickupsbooleantrue

是否允许拾取

Returns:
Type: 
Box3Entity

toString() → {ThingString}

将物品转换为字符串

Returns:
Type: 
ThingString

(static) fromString(string)

从字符串中获取物品数据

Parameters:
NameTypeDescription
stringThingString

物品数据的字符串

(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}

打开物品对话框

Parameters:
NameTypeDescription
entityBox3Entity

打开对话框的实体

contentstring | ThingDialogCallback

对话框正文内容。如果为空,则读取对应Item的内容

optionsArray.<string>

对话框选项

otherOptionsBox3SelectDialogParams

可选,对话框的其他选项

Returns:

对话框选择结果

Type: 
Box3DialogSelectResponse

(async) use(entity) → {void}

使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品

Parameters:
NameTypeDescription
entityBox3Entity

使用物品的玩家

Returns:
Type: 
void

EasyBox3Lib~ Thing

一个(或一组)物品

Constructor

new Thing(id, stackSize, data)

定义一个(或一组)物品

Parameters:
NameTypeDefaultDescription
idstring

物品的id。应该是已经注册的物品id。如果data不为空对象时,最大为1

stackSizenumber1

该物品的堆叠数量,最大为该物品的最大堆叠数量

dataobject

该物品的数据

Members

id :string

物品id

Type:
  • string

stackSize :number

物品堆叠数量,如果有数据将不能再堆叠

Type:
  • number

name :string

该物品显示名称

Type:
  • string

data :object

物品数据

Type:
  • object

_wearing :boolean

该物品是否处于穿戴状态

Type:
  • boolean

item

该物品的类型

staticData

该物品的静态数据

tags

该物品的标签

maxStackSize

该物品的最大堆叠数量

stackable

该物品是否可堆叠

wearable

该物品的穿戴部件 如果为false,则该部件不可穿戴

wearing

该物品是否处于穿戴状态

wearing

设置物品穿戴状态

id :string

物品id

Type:
  • string

stackSize :number

物品堆叠数量,如果有数据将不能再堆叠

Type:
  • number

name :string

该物品显示名称

Type:
  • string

data :object

物品数据

Type:
  • object

_wearing :boolean

该物品是否处于穿戴状态

Type:
  • boolean

item

该物品的类型

staticData

该物品的静态数据

tags

该物品的标签

maxStackSize

该物品的最大堆叠数量

stackable

该物品是否可堆叠

wearable

该物品的穿戴部件 如果为false,则该部件不可穿戴

wearing

该物品是否处于穿戴状态

wearing

设置物品穿戴状态

Methods

(async) updateWear(entity)

对实体更新穿戴状态
更新后的实体会显示穿戴部件

Parameters:
NameTypeDescription
entityBox3Entity

要更新的实体

testSelector(selectorString) → {boolean}

测试该物品是否满足选择器的条件

Parameters:
NameTypeDescription
selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) setData(thing, data) → {Thing}

为一个物品设置data

Parameters:
NameTypeDescription
thingThing

要设置的物品

dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

setData(data) → {Thing}

为该物品设置data

Parameters:
NameTypeDescription
dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

(static) testSelector(thing, selectorString) → {boolean}

测试物品是否满足选择器的条件

Parameters:
NameTypeDescription
thingThing | object

要测试的物品

selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) from(source) → {Thing|null|undefined}

从一个object中生成一个Thing
这个object必须包含idstackingNumberdata属性
可以用此方法复制物品

Parameters:
NameTypeDescription
sourceobject

源对象

Returns:
Type: 
Thing | null | undefined

createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}

为该物品创建对应的实体

Parameters:
NameTypeDefaultDescription
positionBox3Vector3

实体位置

meshScaleBox3Vector3

实体尺寸

allowedPickupsbooleantrue

是否允许拾取

Returns:
Type: 
Box3Entity

toString() → {ThingString}

将物品转换为字符串

Returns:
Type: 
ThingString

(static) fromString(string)

从字符串中获取物品数据

Parameters:
NameTypeDescription
stringThingString

物品数据的字符串

(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}

打开物品对话框

Parameters:
NameTypeDescription
entityBox3Entity

打开对话框的实体

contentstring | ThingDialogCallback

对话框正文内容。如果为空,则读取对应Item的内容

optionsArray.<string>

对话框选项

otherOptionsBox3SelectDialogParams

可选,对话框的其他选项

Returns:

对话框选择结果

Type: 
Box3DialogSelectResponse

(async) use(entity) → {void}

使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品

Parameters:
NameTypeDescription
entityBox3Entity

使用物品的玩家

Returns:
Type: 
void

(async) updateWear(entity)

对实体更新穿戴状态
更新后的实体会显示穿戴部件

Parameters:
NameTypeDescription
entityBox3Entity

要更新的实体

testSelector(selectorString) → {boolean}

测试该物品是否满足选择器的条件

Parameters:
NameTypeDescription
selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) setData(thing, data) → {Thing}

为一个物品设置data

Parameters:
NameTypeDescription
thingThing

要设置的物品

dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

setData(data) → {Thing}

为该物品设置data

Parameters:
NameTypeDescription
dataobject

要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略

Returns:
Type: 
Thing

(static) testSelector(thing, selectorString) → {boolean}

测试物品是否满足选择器的条件

Parameters:
NameTypeDescription
thingThing | object

要测试的物品

selectorStringItemSelectorString

选择器

Returns:
Type: 
boolean

(static) from(source) → {Thing|null|undefined}

从一个object中生成一个Thing
这个object必须包含idstackingNumberdata属性
可以用此方法复制物品

Parameters:
NameTypeDescription
sourceobject

源对象

Returns:
Type: 
Thing | null | undefined

createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}

为该物品创建对应的实体

Parameters:
NameTypeDefaultDescription
positionBox3Vector3

实体位置

meshScaleBox3Vector3

实体尺寸

allowedPickupsbooleantrue

是否允许拾取

Returns:
Type: 
Box3Entity

toString() → {ThingString}

将物品转换为字符串

Returns:
Type: 
ThingString

(static) fromString(string)

从字符串中获取物品数据

Parameters:
NameTypeDescription
stringThingString

物品数据的字符串

(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}

打开物品对话框

Parameters:
NameTypeDescription
entityBox3Entity

打开对话框的实体

contentstring | ThingDialogCallback

对话框正文内容。如果为空,则读取对应Item的内容

optionsArray.<string>

对话框选项

otherOptionsBox3SelectDialogParams

可选,对话框的其他选项

Returns:

对话框选择结果

Type: 
Box3DialogSelectResponse

(async) use(entity) → {void}

使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品

Parameters:
NameTypeDescription
entityBox3Entity

使用物品的玩家

Returns:
Type: 
void