sapdon 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/doc/BlockAPI.md +145 -0
- package/doc/api.md +1 -1
- package/doc/hello_sapdon/a9aad643f5609da73404d1f7f35fd5d0.png +0 -0
- package/doc/hello_sapdon/sapdon/344/275/277/347/224/250/346/225/231/347/250/213.md +159 -0
- package/examples/guidebook/build.config +33 -0
- package/examples/guidebook/dev/guidebook_BP/items/sapdon_test_guidebook.json +19 -0
- package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20 → guidebook/dev/guidebook_BP}/manifest.json +63 -59
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/cropComponent.js +50 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/custom_components/registry.js +20 -0
- package/examples/guidebook/dev/guidebook_BP/scripts/index.js +3 -0
- package/examples/guidebook/dev/guidebook_RP/blocks.json +3 -0
- package/examples/guidebook/dev/guidebook_RP/manifest.json +44 -0
- package/examples/guidebook/dev/guidebook_RP/models/blocks/crop.geo.json +48 -0
- package/examples/{masterball/dev/masterball_RP/masterball_RP_1_20_20.zip → guidebook/dev/guidebook_RP/pack_icon.png} +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/blocks/test_log_oak.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/blocks/test_log_top.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/flipbook_textures.json +1 -0
- package/examples/guidebook/dev/guidebook_RP/textures/item_texture.json +9 -0
- package/examples/guidebook/dev/guidebook_RP/textures/items/masterball.png +0 -0
- package/examples/guidebook/dev/guidebook_RP/textures/terrain_texture.json +14 -0
- package/examples/guidebook/dev/guidebook_RP/ui/_ui_defs.json +6 -0
- package/examples/guidebook/dev/guidebook_RP/ui/guidebook.json +581 -0
- package/examples/guidebook/dev/guidebook_RP/ui/server_form.json +91 -0
- package/examples/guidebook/main.mjs +66 -0
- package/examples/guidebook/mod.info +7 -0
- package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20.zip → guidebook/pack_icon.png} +0 -0
- package/examples/guidebook/res/models/blocks/crop.geo.json +48 -0
- package/examples/guidebook/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/guidebook/res/textures/blocks/test_log_top.png +0 -0
- package/examples/guidebook/res/textures/items/masterball.png +0 -0
- package/examples/guidebook/scripts/custom_components/cropComponent.js +50 -0
- package/examples/guidebook/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/guidebook/scripts/custom_components/registry.js +20 -0
- package/examples/guidebook/scripts/index.js +3 -0
- package/examples/hello_sapdon/build.config +29 -0
- package/examples/hello_sapdon/main.mjs +3 -0
- package/examples/hello_sapdon/mod.info +7 -0
- package/examples/hello_sapdon/pack_icon.png +0 -0
- package/examples/hello_sapdon/res/models/blocks/crop.geo.json +48 -0
- package/examples/hello_sapdon/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/hello_sapdon/res/textures/blocks/test_log_top.png +0 -0
- package/examples/hello_sapdon/res/textures/items/masterball.png +0 -0
- package/examples/hello_sapdon/scripts/custom_components/cropComponent.js +50 -0
- package/examples/hello_sapdon/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/hello_sapdon/scripts/custom_components/registry.js +25 -0
- package/examples/hello_sapdon/scripts/index.js +0 -0
- package/examples/masterball/build.config +1 -0
- package/examples/masterball/dev/masterball_1_20_30.mcaddon +0 -0
- package/examples/masterball/dev/masterball_BP/entities/sapdon_projectile_masterball.json +56 -55
- package/examples/masterball/dev/masterball_BP/manifest.json +59 -59
- package/examples/masterball/dev/masterball_BP/pack_icon.png +0 -0
- package/examples/masterball/dev/masterball_BP/recipes/masterball.json +25 -0
- package/examples/masterball/dev/masterball_BP_1_20_30.mcpack +0 -0
- package/examples/masterball/dev/masterball_RP/attachables/sapdon_caught_masterball.json +19 -0
- package/examples/masterball/dev/masterball_RP/manifest.json +43 -43
- package/examples/masterball/dev/masterball_RP/pack_icon.png +0 -0
- package/examples/masterball/dev/masterball_RP/textures/flipbook_textures.json +1 -0
- package/examples/masterball/dev/masterball_RP/ui/_ui_defs.json +3 -0
- package/examples/masterball/dev/masterball_RP_1_20_30.mcpack +0 -0
- package/examples/masterball/main.mjs +18 -1
- package/examples/masterball/pack_icon.png +0 -0
- package/examples/mob_chest/build.config +29 -0
- package/examples/mob_chest/dev/mob_chest_BP/blocks/mob_chest_chest.json +56 -0
- package/examples/mob_chest/dev/mob_chest_BP/entities/mob_chest_chest_entity.json +79 -0
- package/examples/mob_chest/dev/mob_chest_BP/manifest.json +64 -0
- package/examples/mob_chest/dev/mob_chest_BP/pack_icon.png +0 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/block/block_with_entity.js +46 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/block/cropComponent.js +50 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/custom_components/registry.js +25 -0
- package/examples/mob_chest/dev/mob_chest_BP/scripts/index.js +4 -0
- package/examples/mob_chest/dev/mob_chest_RP/animation_controllers/mob_chest.animation_controllers.json +30 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/animation_item.animation.json +34 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/large_item.animation.json +27 -0
- package/examples/mob_chest/dev/mob_chest_RP/animations/mob_chest.animation.json +64 -0
- package/examples/mob_chest/dev/mob_chest_RP/blocks.json +13 -0
- package/examples/mob_chest/dev/mob_chest_RP/entity/mob_chest_chest_entity.json +32 -0
- package/examples/mob_chest/dev/mob_chest_RP/manifest.json +44 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/crop.geo.json +48 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/cube.geo.json +35 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/blocks/empty.geo.json +35 -0
- package/examples/mob_chest/dev/mob_chest_RP/models/entity/mob_chest.geo.json +98 -0
- package/examples/mob_chest/dev/mob_chest_RP/pack_icon.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/double_normal.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/none.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/entity/normal.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/test_log_oak.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/blocks/test_log_top.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/flipbook_textures.json +1 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/item_texture.json +9 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/items/masterball.png +0 -0
- package/examples/mob_chest/dev/mob_chest_RP/textures/terrain_texture.json +23 -0
- package/examples/mob_chest/dev/mob_chest_RP/ui/_ui_defs.json +3 -0
- package/examples/mob_chest/main.mjs +31 -0
- package/examples/mob_chest/mod.info +7 -0
- package/examples/mob_chest/pack_icon.png +0 -0
- package/examples/mob_chest/res/animation_controllers/mob_chest.animation_controllers.json +30 -0
- package/examples/mob_chest/res/animations/animation_item.animation.json +34 -0
- package/examples/mob_chest/res/animations/large_item.animation.json +27 -0
- package/examples/mob_chest/res/animations/mob_chest.animation.json +64 -0
- package/examples/mob_chest/res/models/blocks/crop.geo.json +48 -0
- package/examples/mob_chest/res/models/blocks/cube.geo.json +35 -0
- package/examples/mob_chest/res/models/blocks/empty.geo.json +35 -0
- package/examples/mob_chest/res/models/entity/mob_chest.geo.json +98 -0
- package/examples/mob_chest/res/textures/blocks/entity/double_normal.png +0 -0
- package/examples/mob_chest/res/textures/blocks/entity/none.png +0 -0
- package/examples/mob_chest/res/textures/blocks/entity/normal.png +0 -0
- package/examples/mob_chest/res/textures/blocks/test_log_oak.png +0 -0
- package/examples/mob_chest/res/textures/blocks/test_log_top.png +0 -0
- package/examples/mob_chest/res/textures/items/masterball.png +0 -0
- package/examples/mob_chest/resource/cube.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.geo.bbmodel +1 -0
- package/examples/mob_chest/resource/flipbook_item.geo.json +3124 -0
- package/examples/mob_chest/resource/mob_chest.bbmodel +1 -0
- package/examples/mob_chest/scripts/custom_components/block/block_with_entity.js +46 -0
- package/examples/mob_chest/scripts/custom_components/block/cropComponent.js +50 -0
- package/examples/mob_chest/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/mob_chest/scripts/custom_components/registry.js +25 -0
- package/examples/mob_chest/scripts/index.js +4 -0
- package/examples/test/build.config +29 -0
- package/examples/test/dev/test_BP/blocks/sapdon_ore_cinnabar.json +15 -15
- package/examples/test/dev/test_BP/blocks/sapdon_test_block.json +15 -15
- package/examples/test/dev/test_BP/blocks/sapdon_test_crop.json +191 -191
- package/examples/test/dev/test_BP/blocks/sapdon_wire.json +102 -102
- package/examples/test/dev/test_BP/entities/sapdon_test_projectile.json +56 -55
- package/examples/test/dev/test_BP/feature_rules/ore_cinnabar_orefeatre_rule.json +52 -52
- package/examples/test/dev/test_BP/feature_rules/overworld_underground_titanite_ore_feature.json +52 -52
- package/examples/test/dev/test_BP/features/ore_cinnabar_ore_feature.json +16 -16
- package/examples/test/dev/test_BP/features/titanite_ore_feature.json +22 -22
- package/examples/test/dev/test_BP/items/sapdon_chest.json +22 -22
- package/examples/test/dev/test_BP/items/sapdon_test_book.json +19 -0
- package/examples/test/dev/test_BP/items/sapdon_test_food.json +25 -25
- package/examples/test/dev/test_BP/items/sapdon_test_item.json +30 -30
- package/examples/test/dev/test_BP/manifest.json +63 -59
- package/examples/test/dev/test_BP/recipes/sapdon_test_furnace.json +12 -12
- package/examples/test/dev/test_BP/scripts/custom_components/cropComponent.js +1 -10
- package/examples/test/dev/test_BP/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/test/dev/test_BP/scripts/custom_components/registry.js +20 -0
- package/examples/test/dev/test_BP/scripts/index.js +4 -3
- package/examples/test/dev/test_RP/attachables/sapdon_chest.json +24 -24
- package/examples/test/dev/test_RP/blocks.json +42 -42
- package/examples/test/dev/test_RP/entity/sapdon_test_projectile.json +27 -27
- package/examples/test/dev/test_RP/manifest.json +43 -43
- package/examples/test/dev/test_RP/models/blocks/arcane_workbench.geo.json +105 -105
- package/examples/test/dev/test_RP/models/blocks/jar_normal.geo.json +46 -46
- package/examples/test/dev/test_RP/models/blocks/jar_normal_0.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_1.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_2.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/jar_normal_3.geo.json +58 -58
- package/examples/test/dev/test_RP/models/blocks/wire.geo.json +153 -153
- package/examples/test/dev/test_RP/textures/item_texture.json +788 -788
- package/examples/test/dev/test_RP/textures/items/seals/seal_breaker.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_butcher.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_empty.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_empty_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_fill.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_fill_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_guard.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_guard_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_harvest.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_lumber.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_pickup.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_pickup_advanced.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_provider.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/seals/seal_use.png.mcmeta +5 -5
- package/examples/test/dev/test_RP/textures/items/wand/cap_thaumium.png.mcmeta +11 -11
- package/examples/test/dev/test_RP/textures/items/wand/cap_void.png.mcmeta +11 -11
- package/examples/test/dev/test_RP/textures/items/wand/focus_pech.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_portablehole.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_primal.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_shard.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/focus_warding.png.mcmeta +2 -2
- package/examples/test/dev/test_RP/textures/items/wand/rod_primal_mat.png.mcmeta +44 -44
- package/examples/test/dev/test_RP/textures/terrain_texture.json +136 -136
- package/examples/test/dev/test_RP/ui/_ui_defs.json +6 -0
- package/examples/test/dev/test_RP/ui/guidebook.json +446 -0
- package/examples/test/dev/test_RP/ui/server_form.json +91 -0
- package/examples/test/main.mjs +46 -1
- package/examples/test/res/models/blocks/arcane_workbench.geo.json +105 -105
- package/examples/test/res/models/blocks/jar_normal.geo.json +46 -46
- package/examples/test/res/models/blocks/jar_normal_0.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_1.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_2.geo.json +58 -58
- package/examples/test/res/models/blocks/jar_normal_3.geo.json +58 -58
- package/examples/test/res/models/blocks/wire.geo.json +153 -153
- package/examples/test/res/textures/items/seals/seal_breaker.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_butcher.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_empty.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_empty_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_fill.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_fill_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_guard.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_guard_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_harvest.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_lumber.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_pickup.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_pickup_advanced.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_provider.png.mcmeta +5 -5
- package/examples/test/res/textures/items/seals/seal_use.png.mcmeta +5 -5
- package/examples/test/res/textures/items/wand/cap_thaumium.png.mcmeta +11 -11
- package/examples/test/res/textures/items/wand/cap_void.png.mcmeta +11 -11
- package/examples/test/res/textures/items/wand/focus_pech.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_portablehole.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_primal.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_shard.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/focus_warding.png.mcmeta +2 -2
- package/examples/test/res/textures/items/wand/rod_primal_mat.png.mcmeta +44 -44
- package/examples/test/scripts/custom_components/cropComponent.js +1 -10
- package/examples/test/scripts/custom_components/items/gui_book.js +37 -0
- package/examples/test/scripts/custom_components/registry.js +20 -0
- package/examples/test/scripts/index.js +4 -3
- package/log.md +8 -0
- package/package.json +4 -1
- package/src/cli/build.js +210 -210
- package/src/cli/load.js +116 -112
- package/src/cli/tools/textureSet.js +114 -114
- package/src/cli/utils.js +82 -82
- package/src/core/addon/controllers/animation_controller.js +80 -0
- package/src/core/addon/entity/entity.js +52 -51
- package/src/core/block/GeometryBlock.js +8 -0
- package/src/core/block/OreBlock.js +1 -0
- package/src/core/block/TileBlock.js +117 -0
- package/src/core/block/block.js +106 -106
- package/src/core/block/blockComponent.js +557 -557
- package/src/core/block/cropBlock.js +1 -1
- package/src/core/entity/BasicEntity.js +195 -166
- package/src/core/entity/bundles/BasicBundle.js +51 -0
- package/src/core/factory/BlockFactory.js +166 -158
- package/src/core/factory/EntityFactory.js +82 -82
- package/src/core/factory/ItemFactory.js +120 -95
- package/src/core/factory/RecipeFactory.js +46 -46
- package/src/core/index.js +2 -1
- package/src/core/item/Item.js +96 -96
- package/src/core/item/ItemComponents.js +251 -235
- package/src/core/item/armor.js +117 -89
- package/src/core/item/attachable.js +33 -33
- package/src/core/item/food.js +61 -61
- package/src/core/registry.js +16 -16
- package/src/core/ui/Properties/{Grid.js → GridProp.js} +2 -2
- package/src/core/ui/Properties/Sound.js +72 -0
- package/src/core/ui/elements/Button.js +111 -0
- package/src/core/ui/elements/CollectionPanel.js +61 -0
- package/src/core/ui/elements/Grid.js +24 -0
- package/src/core/ui/elements/Image.js +4 -0
- package/src/core/ui/elements/Label.js +10 -2
- package/src/core/ui/elements/Panel.js +7 -0
- package/src/core/ui/elements/ScrollingPanel.js +68 -0
- package/src/core/ui/elements/StackPanel.js +40 -0
- package/src/core/ui/elements/UIElement.js +43 -2
- package/src/core/ui/registry/UISystemRegistry.js +35 -0
- package/src/core/ui/systems/UISystem.js +9 -5
- package/src/core/ui/systems/guidebook.js +299 -0
- package/src/core/ui/systems/server_form.js +94 -83
- package/src/templates/test_sapdon/build.config +28 -28
- package/src/templates/test_sapdon/res/animations/animation_item.animation.json +34 -0
- package/src/templates/test_sapdon/res/animations/large_item.animation.json +27 -0
- package/src/templates/test_sapdon/res/models/entity/animation/animation_item.geo.json +26 -0
- package/src/templates/test_sapdon/res/models/entity/animation/large_item.geo.json +28 -0
- package/src/templates/test_sapdon/res/textures/blocks/none.png +0 -0
- package/src/templates/test_sapdon/scripts/custom_components/cropComponent.js +50 -0
- package/src/templates/test_sapdon/scripts/custom_components/items/gui_book.js +37 -0
- package/src/templates/test_sapdon/scripts/custom_components/registry.js +25 -0
- package/examples/masterball/dev/masterball[1.20.20+].mcaddon.zip +0 -0
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/entities/sapdon_projectile_masterball.json +0 -56
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/items/sapdon_caught_masterball.json +0 -32
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/items/sapdon_uncaught_masterball.json +0 -31
- package/examples/masterball/dev/masterball_BP/masterball_BP_1_20_20/scripts/index.js +0 -159
- package/examples/test/dev/test_BP/biomes/test_biome.json +0 -48
- package/examples/test/dev/test_BP/blocks/sapdon_block.json +0 -111
- package/examples/test/dev/test_BP/entities/sapdon_body.json +0 -118
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_ctrl1.json +0 -55
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_ctrl2.json +0 -61
- package/examples/test/dev/test_BP/entities/sapdon_test_entity_header.json +0 -408
- package/examples/test/dev/test_RP/entity/sapdon_body.json +0 -44
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_ctrl1.json +0 -38
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_ctrl2.json +0 -38
- package/examples/test/dev/test_RP/entity/sapdon_test_entity_header.json +0 -44
- package/src/cli/build.config +0 -4
- package/src/core/ui/registry/ServerUISystem.js +0 -19
- /package/examples/{masterball/dev/masterball_BP/masterball_BP_1_20_20 → guidebook/dev/guidebook_BP}/pack_icon.png +0 -0
package/src/core/item/armor.js
CHANGED
|
@@ -1,89 +1,117 @@
|
|
|
1
|
-
import { Attachable } from "./Attachable.js";
|
|
2
|
-
import { Item } from "./
|
|
3
|
-
import { ItemComponent } from "./ItemComponents.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// 定义 Armor 基类
|
|
7
|
-
export class Armor {
|
|
8
|
-
constructor(identifier, category, item_texture, texture_path, options = {}) {
|
|
9
|
-
this.identifier = identifier;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
1
|
+
import { Attachable } from "./Attachable.js";
|
|
2
|
+
import { Item } from "./Item.js";
|
|
3
|
+
import { ItemComponent } from "./ItemComponents.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// 定义 Armor 基类
|
|
7
|
+
export class Armor {
|
|
8
|
+
constructor(identifier, category, item_texture, texture_path, options = {}) {
|
|
9
|
+
this.identifier = identifier;
|
|
10
|
+
//默认分组
|
|
11
|
+
options["group"]= "minecraft:itemGroup.name.chestplate";
|
|
12
|
+
// 创建物品
|
|
13
|
+
this.item = new Item(identifier, category, item_texture, options);
|
|
14
|
+
// 创建附加物
|
|
15
|
+
this.attachable = new Attachable(identifier);
|
|
16
|
+
|
|
17
|
+
// 配置附加物
|
|
18
|
+
this.attachable
|
|
19
|
+
.addTexture("default", texture_path) // 添加默认纹理
|
|
20
|
+
.addMaterial("default", "armor") // 添加默认材质
|
|
21
|
+
.addMaterial("enchanted", "armor_enchanted") // 添加附魔材质
|
|
22
|
+
.addTexture("default",texture_path)
|
|
23
|
+
.addTexture("enchanted", "textures/misc/enchanted_actor_glint") // 添加附魔纹理
|
|
24
|
+
.addRenderController("controller.render.armor") // 添加渲染控制器
|
|
25
|
+
//默认类型 胸甲
|
|
26
|
+
.addGeometry("default", "geometry.player.armor.chestplate") // 添加几何模型
|
|
27
|
+
.setScript("parent_setup", "v.chest_layer_visible = 0.0;"); // 设置脚本
|
|
28
|
+
}
|
|
29
|
+
setArrachableGeometry(key, geometry){
|
|
30
|
+
this.attachable.addGeometry(key,geometry);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 扩展 Armor 类,实现胸甲
|
|
36
|
+
export class Chestplate extends Armor {
|
|
37
|
+
constructor(identifier, item_texture, texture_path, options = {}) {
|
|
38
|
+
super(identifier, "equipment", item_texture, texture_path, options);
|
|
39
|
+
|
|
40
|
+
options["group"]= "minecraft:itemGroup.name.chestplate";
|
|
41
|
+
|
|
42
|
+
//头盔专属
|
|
43
|
+
this.attachable.addGeometry("default", "geometry.player.armor.chestplate") // 添加几何模型
|
|
44
|
+
.setScript("parent_setup", "v.chest_layer_visible = 0.0;"); // 设置脚本
|
|
45
|
+
|
|
46
|
+
// 自定义胸甲物品
|
|
47
|
+
this.item.addComponent(
|
|
48
|
+
ItemComponent.combineComponents(
|
|
49
|
+
ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
|
|
50
|
+
ItemComponent.setWearable(5, "slot.armor.chest") // 设置为可穿戴,并指定装备槽
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 扩展 Armor 类,实现靴子
|
|
57
|
+
export class Boot extends Armor {
|
|
58
|
+
constructor(identifier, item_texture, texture_path, options = {}) {
|
|
59
|
+
super(identifier, "equipment", item_texture, texture_path, options);
|
|
60
|
+
|
|
61
|
+
options["group"]= "minecraft:itemGroup.name.boots";
|
|
62
|
+
|
|
63
|
+
//头盔专属
|
|
64
|
+
this.attachable.addGeometry("default", "geometry.player.armor.boots") // 添加几何模型
|
|
65
|
+
.setScript("parent_setup", "v.boot_layer_visible = 0.0;"); // 设置脚本
|
|
66
|
+
|
|
67
|
+
// 自定义靴子物品
|
|
68
|
+
this.item.addComponent(
|
|
69
|
+
ItemComponent.combineComponents(
|
|
70
|
+
ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
|
|
71
|
+
ItemComponent.setWearable(4, "slot.armor.feet") // 设置为可穿戴,并指定装备槽
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 扩展 Armor 类,实现裤子
|
|
78
|
+
export class Leggings extends Armor {
|
|
79
|
+
constructor(identifier, item_texture, texture_path, options = {}) {
|
|
80
|
+
super(identifier, "equipment", item_texture, texture_path, options);
|
|
81
|
+
|
|
82
|
+
options["group"]= "minecraft:itemGroup.name.leggings";
|
|
83
|
+
|
|
84
|
+
//头盔专属
|
|
85
|
+
this.attachable.addGeometry("default", "geometry.player.armor.leggings") // 添加几何模型
|
|
86
|
+
.setScript("parent_setup", "v.leg_layer_visible = 0.0;"); // 设置脚本
|
|
87
|
+
|
|
88
|
+
// 自定义裤子物品
|
|
89
|
+
this.item.addComponent(
|
|
90
|
+
ItemComponent.combineComponents(
|
|
91
|
+
ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
|
|
92
|
+
ItemComponent.setWearable(6, "slot.armor.legs") // 设置为可穿戴,并指定装备槽
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 扩展 Armor 类,实现头盔
|
|
99
|
+
export class Helmet extends Armor {
|
|
100
|
+
constructor(identifier, item_texture, texture_path, options = {}) {
|
|
101
|
+
super(identifier, "equipment", item_texture, texture_path, options);
|
|
102
|
+
|
|
103
|
+
options["group"]= "minecraft:itemGroup.name.helmet";
|
|
104
|
+
|
|
105
|
+
//头盔专属
|
|
106
|
+
this.attachable.addGeometry("default", "geometry.player.armor.helmet") // 添加几何模型
|
|
107
|
+
.setScript("parent_setup", "v.helmet_layer_visible = 0.0;"); // 设置脚本
|
|
108
|
+
|
|
109
|
+
// 自定义头盔物品
|
|
110
|
+
this.item.addComponent(
|
|
111
|
+
ItemComponent.combineComponents(
|
|
112
|
+
ItemComponent.setMaxStackSize(1), // 设置最大堆叠数量
|
|
113
|
+
ItemComponent.setWearable(3, "slot.armor.head") // 设置为可穿戴,并指定装备槽
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { AddonAttachable, AddonAttachableDefinition, AddonAttachableDescription } from "../addon/item/attachable.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export class Attachable extends AddonAttachableDescription{
|
|
5
|
-
constructor(identifier){
|
|
6
|
-
super(identifier);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
getId() {
|
|
10
|
-
return this.identifier;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
toJson() {
|
|
14
|
-
const entity = new AddonAttachable(
|
|
15
|
-
"1.8.0",
|
|
16
|
-
new AddonAttachableDefinition(this)
|
|
17
|
-
);
|
|
18
|
-
return entity.toJson();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/*
|
|
23
|
-
const attachable = new Attachable("test")
|
|
24
|
-
attachable.addMaterial("default", "armor")
|
|
25
|
-
attachable.addMaterial("enchanted","armor_enchanted")
|
|
26
|
-
attachable.addTexture("default","textures/models/armor/custom_main")
|
|
27
|
-
attachable.addTexture("enchanted", "textures/misc/enchanted_actor_glint")
|
|
28
|
-
attachable.addGeometry("default", "geometry.player.armor.chestplate")
|
|
29
|
-
attachable.addRenderController("controller.render.armor")
|
|
30
|
-
attachable.setScript("parent_setup","v.chest_layer_visible = 0.0;")
|
|
31
|
-
|
|
32
|
-
console.log(JSON.stringify(attachable.toJson(),null,2))
|
|
33
|
-
debugger
|
|
1
|
+
import { AddonAttachable, AddonAttachableDefinition, AddonAttachableDescription } from "../addon/item/attachable.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class Attachable extends AddonAttachableDescription{
|
|
5
|
+
constructor(identifier){
|
|
6
|
+
super(identifier);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getId() {
|
|
10
|
+
return this.identifier;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
toJson() {
|
|
14
|
+
const entity = new AddonAttachable(
|
|
15
|
+
"1.8.0",
|
|
16
|
+
new AddonAttachableDefinition(this)
|
|
17
|
+
);
|
|
18
|
+
return entity.toJson();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
const attachable = new Attachable("test")
|
|
24
|
+
attachable.addMaterial("default", "armor")
|
|
25
|
+
attachable.addMaterial("enchanted","armor_enchanted")
|
|
26
|
+
attachable.addTexture("default","textures/models/armor/custom_main")
|
|
27
|
+
attachable.addTexture("enchanted", "textures/misc/enchanted_actor_glint")
|
|
28
|
+
attachable.addGeometry("default", "geometry.player.armor.chestplate")
|
|
29
|
+
attachable.addRenderController("controller.render.armor")
|
|
30
|
+
attachable.setScript("parent_setup","v.chest_layer_visible = 0.0;")
|
|
31
|
+
|
|
32
|
+
console.log(JSON.stringify(attachable.toJson(),null,2))
|
|
33
|
+
debugger
|
|
34
34
|
*/
|
package/src/core/item/food.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { ItemComponent } from "./ItemComponents.js";
|
|
2
|
-
import { Item } from "./
|
|
3
|
-
|
|
4
|
-
export class Food extends Item {
|
|
5
|
-
/**
|
|
6
|
-
* 物品类
|
|
7
|
-
* @param {string} identifier 物品唯一标识符
|
|
8
|
-
* @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
|
|
9
|
-
* @param {string} texture 物品纹理
|
|
10
|
-
* @param {Object} options 可选参数
|
|
11
|
-
* @param {string} options.group 分组
|
|
12
|
-
* @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
|
|
13
|
-
* @param {string} options.animation 使用动画,默认为 "eat"
|
|
14
|
-
* @param {boolean} options.canAlwaysEat 是否总是可以食用,默认为 false
|
|
15
|
-
* @param {number} options.nutrition 营养价值,默认为 0
|
|
16
|
-
* @param {number} options.saturationModifier 饱和度修正值,默认为 1
|
|
17
|
-
*/
|
|
18
|
-
constructor(identifier, category, texture, options = {}) {
|
|
19
|
-
// 继承父类
|
|
20
|
-
super(identifier, category, texture, options);
|
|
21
|
-
|
|
22
|
-
// 解构 options 并设置默认值
|
|
23
|
-
const {
|
|
24
|
-
animation = "eat",
|
|
25
|
-
movement = 1,
|
|
26
|
-
useDuration = 1,
|
|
27
|
-
canAlwaysEat = false,
|
|
28
|
-
nutrition = 0,
|
|
29
|
-
saturationModifier = 1,
|
|
30
|
-
} = options;
|
|
31
|
-
|
|
32
|
-
// 参数验证
|
|
33
|
-
if (typeof nutrition !== "number" || nutrition < 0) {
|
|
34
|
-
throw new Error('nutrition 必须是一个非负数');
|
|
35
|
-
}
|
|
36
|
-
if (typeof saturationModifier !== "number" || saturationModifier <= 0) {
|
|
37
|
-
throw new Error('saturationModifier 必须是一个正数');
|
|
38
|
-
}
|
|
39
|
-
if (typeof animation !== "string") {
|
|
40
|
-
throw new Error('animation 必须是字符串类型');
|
|
41
|
-
}
|
|
42
|
-
if (typeof canAlwaysEat !== "boolean") {
|
|
43
|
-
throw new Error('canAlwaysEat 必须是布尔类型');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 添加组件
|
|
47
|
-
this.addComponent(
|
|
48
|
-
ItemComponent.combineComponents(
|
|
49
|
-
ItemComponent.setUseModifiers(
|
|
50
|
-
movement,
|
|
51
|
-
useDuration
|
|
52
|
-
),
|
|
53
|
-
ItemComponent.setFoodComponent(
|
|
54
|
-
canAlwaysEat,
|
|
55
|
-
nutrition,
|
|
56
|
-
saturationModifier
|
|
57
|
-
),
|
|
58
|
-
ItemComponent.setUseAnimation(animation)
|
|
59
|
-
)
|
|
60
|
-
);
|
|
61
|
-
}
|
|
1
|
+
import { ItemComponent } from "./ItemComponents.js";
|
|
2
|
+
import { Item } from "./Item.js";
|
|
3
|
+
|
|
4
|
+
export class Food extends Item {
|
|
5
|
+
/**
|
|
6
|
+
* 物品类
|
|
7
|
+
* @param {string} identifier 物品唯一标识符
|
|
8
|
+
* @param {string} category 菜单栏分类 可选:"construction", "nature", "equipment", "items", and "none"
|
|
9
|
+
* @param {string} texture 物品纹理
|
|
10
|
+
* @param {Object} options 可选参数
|
|
11
|
+
* @param {string} options.group 分组
|
|
12
|
+
* @param {boolean} options.hide_in_command 是否在命令中隐藏,默认为 false
|
|
13
|
+
* @param {string} options.animation 使用动画,默认为 "eat"
|
|
14
|
+
* @param {boolean} options.canAlwaysEat 是否总是可以食用,默认为 false
|
|
15
|
+
* @param {number} options.nutrition 营养价值,默认为 0
|
|
16
|
+
* @param {number} options.saturationModifier 饱和度修正值,默认为 1
|
|
17
|
+
*/
|
|
18
|
+
constructor(identifier, category, texture, options = {}) {
|
|
19
|
+
// 继承父类
|
|
20
|
+
super(identifier, category, texture, options);
|
|
21
|
+
|
|
22
|
+
// 解构 options 并设置默认值
|
|
23
|
+
const {
|
|
24
|
+
animation = "eat",
|
|
25
|
+
movement = 1,
|
|
26
|
+
useDuration = 1,
|
|
27
|
+
canAlwaysEat = false,
|
|
28
|
+
nutrition = 0,
|
|
29
|
+
saturationModifier = 1,
|
|
30
|
+
} = options;
|
|
31
|
+
|
|
32
|
+
// 参数验证
|
|
33
|
+
if (typeof nutrition !== "number" || nutrition < 0) {
|
|
34
|
+
throw new Error('nutrition 必须是一个非负数');
|
|
35
|
+
}
|
|
36
|
+
if (typeof saturationModifier !== "number" || saturationModifier <= 0) {
|
|
37
|
+
throw new Error('saturationModifier 必须是一个正数');
|
|
38
|
+
}
|
|
39
|
+
if (typeof animation !== "string") {
|
|
40
|
+
throw new Error('animation 必须是字符串类型');
|
|
41
|
+
}
|
|
42
|
+
if (typeof canAlwaysEat !== "boolean") {
|
|
43
|
+
throw new Error('canAlwaysEat 必须是布尔类型');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 添加组件
|
|
47
|
+
this.addComponent(
|
|
48
|
+
ItemComponent.combineComponents(
|
|
49
|
+
ItemComponent.setUseModifiers(
|
|
50
|
+
movement,
|
|
51
|
+
useDuration
|
|
52
|
+
),
|
|
53
|
+
ItemComponent.setFoodComponent(
|
|
54
|
+
canAlwaysEat,
|
|
55
|
+
nutrition,
|
|
56
|
+
saturationModifier
|
|
57
|
+
),
|
|
58
|
+
ItemComponent.setUseAnimation(animation)
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
62
|
}
|
package/src/core/registry.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export class GRegistry {
|
|
3
|
-
static dataList = [];
|
|
4
|
-
/**
|
|
5
|
-
* 生成注册器
|
|
6
|
-
* @param {string} name 文件名字
|
|
7
|
-
* @param {string} root 根目录,如 "behavior"、"resource" 等
|
|
8
|
-
* @param {string} path 数据的路径,如 "blocks/"、"items/"、"recipes/" 等
|
|
9
|
-
* @param {string} data 实例 必须包含 toJson 方法
|
|
10
|
-
*/
|
|
11
|
-
static register(name, root, path, data){
|
|
12
|
-
GRegistry.dataList.push({name, root, path, data});
|
|
13
|
-
}
|
|
14
|
-
static getDataList(){
|
|
15
|
-
return [...GRegistry.dataList];
|
|
16
|
-
}
|
|
1
|
+
|
|
2
|
+
export class GRegistry {
|
|
3
|
+
static dataList = [];
|
|
4
|
+
/**
|
|
5
|
+
* 生成注册器
|
|
6
|
+
* @param {string} name 文件名字
|
|
7
|
+
* @param {string} root 根目录,如 "behavior"、"resource" 等
|
|
8
|
+
* @param {string} path 数据的路径,如 "blocks/"、"items/"、"recipes/" 等
|
|
9
|
+
* @param {string} data 实例 必须包含 toJson 方法
|
|
10
|
+
*/
|
|
11
|
+
static register(name, root, path, data){
|
|
12
|
+
GRegistry.dataList.push({name, root, path, data});
|
|
13
|
+
}
|
|
14
|
+
static getDataList(){
|
|
15
|
+
return [...GRegistry.dataList];
|
|
16
|
+
}
|
|
17
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Grid 类
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 该类表示一个网格控件属性,用于管理网格布局及其相关属性。
|
|
5
5
|
*
|
|
6
6
|
* 属性:
|
|
7
7
|
* - grid_dimensions: Vector [columns, rows] - 网格的列数和行数
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - precached_grid_item_count: int - 预缓存的网格项目数量
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export class
|
|
16
|
+
export class GridProp {
|
|
17
17
|
constructor() {
|
|
18
18
|
/*
|
|
19
19
|
this.grid_dimensions = null;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sound 类
|
|
3
|
+
*
|
|
4
|
+
* 该类表示一个声音控件,用于管理声音播放及其相关属性。
|
|
5
|
+
*
|
|
6
|
+
* 属性:
|
|
7
|
+
* - sound_name: string - 声音名称(定义在 RP/sounds/sound_definitions.json 文件中)
|
|
8
|
+
* - sound_volume: float - 声音音量(默认值:1.0)
|
|
9
|
+
* - sound_pitch: float - 声音音调(默认值:1.0)
|
|
10
|
+
* - sounds: Array of sound objects - 触发事件时播放的声音数组
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export class Sound {
|
|
14
|
+
constructor() {
|
|
15
|
+
/*
|
|
16
|
+
this.sound_name = '';
|
|
17
|
+
this.sound_volume = 1.0;
|
|
18
|
+
this.sound_pitch = 1.0;
|
|
19
|
+
this.sounds = [];
|
|
20
|
+
*/
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 设置声音名称。
|
|
25
|
+
* @param {string} name - 声音名称(定义在 RP/sounds/sound_definitions.json 文件中)
|
|
26
|
+
* @returns {Sound} 返回当前实例以支持链式调用
|
|
27
|
+
*/
|
|
28
|
+
setSoundName(name) {
|
|
29
|
+
this.sound_name = name;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 设置声音音量。
|
|
35
|
+
* @param {number} volume - 音量(范围:0.0 到 1.0,默认值:1.0)
|
|
36
|
+
* @returns {Sound} 返回当前实例以支持链式调用
|
|
37
|
+
*/
|
|
38
|
+
setSoundVolume(volume = 1.0) {
|
|
39
|
+
this.sound_volume = volume;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 设置声音音调。
|
|
45
|
+
* @param {number} pitch - 音调(默认值:1.0)
|
|
46
|
+
* @returns {Sound} 返回当前实例以支持链式调用
|
|
47
|
+
*/
|
|
48
|
+
setSoundPitch(pitch = 1.0) {
|
|
49
|
+
this.sound_pitch = pitch;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 设置触发事件时播放的声音数组。
|
|
55
|
+
* @param {object[]} sounds - 声音对象数组
|
|
56
|
+
* @returns {Sound} 返回当前实例以支持链式调用
|
|
57
|
+
*/
|
|
58
|
+
setSounds(sounds) {
|
|
59
|
+
this.sounds = sounds;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 添加一个声音对象到声音数组。
|
|
65
|
+
* @param {object} sound - 声音对象
|
|
66
|
+
* @returns {Sound} 返回当前实例以支持链式调用
|
|
67
|
+
*/
|
|
68
|
+
addSound(sound) {
|
|
69
|
+
this.sounds.push(sound);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button
|
|
3
|
+
Property Name Type Default Value Description
|
|
4
|
+
default_control string Name of the child control that will be displayed only in the default state
|
|
5
|
+
hover_control string Name of the child control that will be displayed only in the hover state
|
|
6
|
+
pressed_control string Name of the child control that will be displayed only in the pressed state
|
|
7
|
+
locked_control string Name of the child control that will be displayed only in the locked state
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Control } from "../Properties/Control.js";
|
|
11
|
+
import { DataBinding } from "../Properties/DataBinding.js";
|
|
12
|
+
import { Factory } from "../Properties/Factory.js";
|
|
13
|
+
import { Input } from "../Properties/Input.js";
|
|
14
|
+
import { Layout } from "../Properties/Layout.js";
|
|
15
|
+
import { Sound } from "../Properties/Sound.js";
|
|
16
|
+
import { UIElement } from "./UIElement.js";
|
|
17
|
+
|
|
18
|
+
export class Button extends UIElement{
|
|
19
|
+
constructor(id,template){
|
|
20
|
+
super(id,"button",template);
|
|
21
|
+
this.input = new Input();
|
|
22
|
+
this.sound = new Sound();
|
|
23
|
+
this.control = new Control();
|
|
24
|
+
this.layout = new Layout();
|
|
25
|
+
this.dataBinding = new DataBinding();
|
|
26
|
+
this.factory = new Factory();
|
|
27
|
+
}
|
|
28
|
+
setDefaultControl(default_control){
|
|
29
|
+
this.addProp("default_control",default_control);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
setHoverControl(hover_control){
|
|
33
|
+
this.addProp("hover_control",hover_control);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setPressedControl(pressed_control){
|
|
37
|
+
this.addProp("pressed_control",pressed_control);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
setLockedControl(locked_control){
|
|
41
|
+
this.addProp("locked_control",locked_control);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setInput(input){
|
|
46
|
+
if(!(input instanceof Input)) new Error("需求Input类");
|
|
47
|
+
this.input = input;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setSound(sound){
|
|
52
|
+
if(!(sound instanceof Sound)) new Error("需求Sound类");
|
|
53
|
+
this.sound = sound;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setLayout(layout){
|
|
58
|
+
if(!(layout instanceof Layout)) new Error("参数需要Layout类")
|
|
59
|
+
this.layout = layout;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
serialize(){
|
|
64
|
+
//序列化
|
|
65
|
+
|
|
66
|
+
// 复制Layout的属性
|
|
67
|
+
for (const key in this.layout) {
|
|
68
|
+
if (this.layout.hasOwnProperty(key)) {
|
|
69
|
+
this.properties.set(key, this.layout[key]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 复制input的属性
|
|
74
|
+
for (const key in this.input) {
|
|
75
|
+
if (this.input.hasOwnProperty(key)) {
|
|
76
|
+
this.properties.set(key, this.input[key]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 复制sound的属性
|
|
81
|
+
for (const key in this.sound) {
|
|
82
|
+
if (this.sound.hasOwnProperty(key)) {
|
|
83
|
+
this.properties.set(key, this.sound[key]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 复制DataBinding的属性
|
|
88
|
+
for (const key in this.dataBinding) {
|
|
89
|
+
if (this.dataBinding.hasOwnProperty(key)) {
|
|
90
|
+
this.properties.set(key, this.dataBinding[key]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 复制Factory的属性
|
|
95
|
+
for (const key in this.factory) {
|
|
96
|
+
if (this.factory.hasOwnProperty(key)) {
|
|
97
|
+
this.properties.set(key, this.factory[key]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 复制Control的属性
|
|
102
|
+
for (const key in this.control) {
|
|
103
|
+
if (this.control.hasOwnProperty(key)) {
|
|
104
|
+
this.properties.set(key, this.control[key]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 调用父类的serialize方法
|
|
109
|
+
return super.serialize();
|
|
110
|
+
}
|
|
111
|
+
}
|