Constructor
new Thing(id, stackSize, data)
定义一个(或一组)物品
| Name | Type | Default | Description |
|---|---|---|---|
id | string | 物品的id。应该是已经注册的物品id。如果 | |
stackSize | number | 1 | 该物品的堆叠数量,最大为该物品的最大堆叠数量 |
data | object | 该物品的数据 |
- Source
Members
id :string
物品id
- string
- Source
stackSize :number
物品堆叠数量,如果有数据将不能再堆叠
- number
- Source
name :string
该物品显示名称
- string
- Source
data :object
物品数据
- object
- Source
_wearing :boolean
该物品是否处于穿戴状态
- boolean
- Source
item
该物品的类型
- Source
staticData
该物品的静态数据
- Source
tags
该物品的标签
- Source
maxStackSize
该物品的最大堆叠数量
- Source
stackable
该物品是否可堆叠
- Source
wearable
该物品的穿戴部件 如果为false,则该部件不可穿戴
- Source
wearing
该物品是否处于穿戴状态
- Source
wearing
设置物品穿戴状态
- Source
id :string
物品id
- string
- Source
stackSize :number
物品堆叠数量,如果有数据将不能再堆叠
- number
- Source
name :string
该物品显示名称
- string
- Source
data :object
物品数据
- object
- Source
_wearing :boolean
该物品是否处于穿戴状态
- boolean
- Source
item
该物品的类型
- Source
staticData
该物品的静态数据
- Source
tags
该物品的标签
- Source
maxStackSize
该物品的最大堆叠数量
- Source
stackable
该物品是否可堆叠
- Source
wearable
该物品的穿戴部件 如果为false,则该部件不可穿戴
- Source
wearing
该物品是否处于穿戴状态
- Source
wearing
设置物品穿戴状态
- Source
Methods
(async) updateWear(entity)
对实体更新穿戴状态
更新后的实体会显示穿戴部件
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 要更新的实体 |
- Source
testSelector(selectorString) → {boolean}
测试该物品是否满足选择器的条件
| Name | Type | Description |
|---|---|---|
selectorString | ItemSelectorString | 选择器 |
- Source
- Type:
- boolean
(static) setData(thing, data) → {Thing}
为一个物品设置data
| Name | Type | Description |
|---|---|---|
thing | Thing | 要设置的物品 |
data | object | 要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略 |
- Source
- Type:
- Thing
setData(data) → {Thing}
为该物品设置data
| Name | Type | Description |
|---|---|---|
data | object | 要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略 |
- Source
- Type:
- Thing
(static) testSelector(thing, selectorString) → {boolean}
测试物品是否满足选择器的条件
| Name | Type | Description |
|---|---|---|
thing | Thing | | 要测试的物品 |
selectorString | ItemSelectorString | 选择器 |
- Source
- Type:
- boolean
(static) from(source) → {Thing|null|undefined}
从一个object中生成一个Thing
这个object必须包含id、stackingNumber、data属性
可以用此方法复制物品
| Name | Type | Description |
|---|---|---|
source | object | 源对象 |
- Source
- Type:
- Thing |
null | undefined
createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}
为该物品创建对应的实体
| Name | Type | Default | Description |
|---|---|---|---|
position | Box3Vector3 | 实体位置 | |
meshScale | Box3Vector3 | 实体尺寸 | |
allowedPickups | boolean | true | 是否允许拾取 |
- Source
- Type:
- Box3Entity
toString() → {ThingString}
将物品转换为字符串
- Source
- Type:
- ThingString
(static) fromString(string)
从字符串中获取物品数据
| Name | Type | Description |
|---|---|---|
string | ThingString | 物品数据的字符串 |
- Source
(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}
打开物品对话框
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 打开对话框的实体 |
content | string | | 对话框正文内容。如果为空,则读取对应 |
options | Array.<string> | 对话框选项 |
otherOptions | Box3SelectDialogParams | 可选,对话框的其他选项 |
- Source
对话框选择结果
- Type:
- Box3DialogSelectResponse
(async) use(entity) → {void}
使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 使用物品的玩家 |
- Source
- Type:
- void
(async) updateWear(entity)
对实体更新穿戴状态
更新后的实体会显示穿戴部件
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 要更新的实体 |
- Source
testSelector(selectorString) → {boolean}
测试该物品是否满足选择器的条件
| Name | Type | Description |
|---|---|---|
selectorString | ItemSelectorString | 选择器 |
- Source
- Type:
- boolean
(static) setData(thing, data) → {Thing}
为一个物品设置data
| Name | Type | Description |
|---|---|---|
thing | Thing | 要设置的物品 |
data | object | 要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略 |
- Source
- Type:
- Thing
setData(data) → {Thing}
为该物品设置data
| Name | Type | Description |
|---|---|---|
data | object | 要设置的数据。如果数据中包含该种物品中没有的键值对或者数据类型不符,将被忽略 |
- Source
- Type:
- Thing
(static) testSelector(thing, selectorString) → {boolean}
测试物品是否满足选择器的条件
| Name | Type | Description |
|---|---|---|
thing | Thing | | 要测试的物品 |
selectorString | ItemSelectorString | 选择器 |
- Source
- Type:
- boolean
(static) from(source) → {Thing|null|undefined}
从一个object中生成一个Thing
这个object必须包含id、stackingNumber、data属性
可以用此方法复制物品
| Name | Type | Description |
|---|---|---|
source | object | 源对象 |
- Source
- Type:
- Thing |
null | undefined
createThingEntity(position, meshScale, allowedPickups) → {Box3Entity}
为该物品创建对应的实体
| Name | Type | Default | Description |
|---|---|---|---|
position | Box3Vector3 | 实体位置 | |
meshScale | Box3Vector3 | 实体尺寸 | |
allowedPickups | boolean | true | 是否允许拾取 |
- Source
- Type:
- Box3Entity
toString() → {ThingString}
将物品转换为字符串
- Source
- Type:
- ThingString
(static) fromString(string)
从字符串中获取物品数据
| Name | Type | Description |
|---|---|---|
string | ThingString | 物品数据的字符串 |
- Source
(async) dialog(entity, content, options, otherOptions) → {Box3DialogSelectResponse}
打开物品对话框
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 打开对话框的实体 |
content | string | | 对话框正文内容。如果为空,则读取对应 |
options | Array.<string> | 对话框选项 |
otherOptions | Box3SelectDialogParams | 可选,对话框的其他选项 |
- Source
对话框选择结果
- Type:
- Box3DialogSelectResponse
(async) use(entity) → {void}
使用/穿戴/卸下物品
需要自行使用takeOut取出ThingStorage(如果有)的物品
| Name | Type | Description |
|---|---|---|
entity | Box3Entity | 使用物品的玩家 |
- Source
- Type:
- void