diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 000000000..9eeb3e60b --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,68 @@ +name: build and publish + +on: + pull_request: + +jobs: + check_and_build: + runs-on: ubuntu-latest + permissions: + id-token: write + outputs: + s3_bucket_key: ${{ steps.publish_package.outputs.s3-bucket-key }} + steps: + - uses: actions/checkout@v3 + - name: Install + run: npm ci + - name: Build + run: npm run build && cp -r bin dist + - name: Publish + uses: menduz/oddish-action@master + id: publish_package + with: + registry-url: 'https://registry.npmjs.org' + access: public + ## use action runId instead of current date to generate snapshot numbers + deterministic-snapshot: true + + ## publish every package to s3 + s3-bucket: ${{ secrets.SDK_TEAM_S3_BUCKET }} + s3-bucket-key-prefix: '@dcl/${{ github.event.repository.name }}/branch/${{ github.head_ref }}' + s3-bucket-region: ${{ secrets.SDK_TEAM_AWS_REGION }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + AWS_DEFAULT_REGION: us-east-1 + AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }} + + notify_deployment: + needs: [check_and_build] + if: ${{ github.event.pull_request.number && !startsWith(github.head_ref, 'dependabot/') }} + runs-on: ubuntu-latest + name: Deployment Notification + steps: + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Test this pull request + + - name: Generate S3 URL + id: url-generator + run: echo "body=${{ secrets.SDK_TEAM_S3_BASE_URL }}/${{ needs.check_and_build.outputs.s3_bucket_key }}" >> $GITHUB_OUTPUT + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + # Test this pull request + - The package can be tested by running + ```bash + npm i "${{ steps.url-generator.outputs.body }}" + ``` + > Remember, if new assets are added in the PR, they won't be avaliable on the CDN until it gets merged. So this can be used to test changes on the `package's` JS or the `catalog.json`, but won't work to test newly added items. + edit-mode: replace diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..b9cd521b2 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "tabWidth": 2, + "semi": false, + "printWidth": 80 +} diff --git a/packs/smart_items/assets/barrel/data.json b/packs/smart_items/assets/barrel/data.json index 4711bc4ad..d27929f38 100644 --- a/packs/smart_items/assets/barrel/data.json +++ b/packs/smart_items/assets/barrel/data.json @@ -18,7 +18,8 @@ { "name": "Explode", "type": "batch", - "jsonPayload": "{ \"actions\": [\"Play Explosion Animation\", \"Damage\", \"Delay Remove\"] }" + "jsonPayload": "{ \"actions\": [\"Play Explosion Animation\", \"Damage\", \"Delay Remove\"] }", + "allowedInBasicView": true }, { "name": "Play Explosion Animation", @@ -28,12 +29,14 @@ { "name": "Damage", "type": "damage", - "jsonPayload": "{ \"radius\": 10, \"hits\": 30, \"layer\": \"all\" }" + "jsonPayload": "{ \"radius\": 10, \"hits\": 30, \"layer\": \"all\" }", + "basicViewId": "action-damage" }, { "name": "Remove", "type": "remove_entity", - "jsonPayload": "{ }" + "jsonPayload": "{ }", + "allowedInBasicView": true }, { "name": "Delay Remove", @@ -41,6 +44,18 @@ "jsonPayload": "{ \"actions\": [\"Remove\"], \"timeout\": 1 }" } ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Barrel", + "fields": [ + { + "name": "Damage", + "type": "asset-packs::Actions", + "basicViewId": "action-damage", + "layout": "{\"radius\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Explosion Radius\" }, \"hits\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Explosion Damage\" }, \"layer\": { \"field\": \"Dropdown\", \"label\": \"Damage Target\" }}" + } + ] } } -} \ No newline at end of file +} diff --git a/packs/smart_items/assets/first_aid/data.json b/packs/smart_items/assets/first_aid/data.json index 8fa19e613..faf6caefb 100644 --- a/packs/smart_items/assets/first_aid/data.json +++ b/packs/smart_items/assets/first_aid/data.json @@ -17,31 +17,48 @@ { "name": "Heal Player", "type": "heal_player", - "jsonPayload": "{ \"multiplier\": 100 }" + "jsonPayload": "{ \"multiplier\": 100 }", + "basicViewId": "action-heal-player" }, { "name": "Remove", "type": "remove_entity", - "jsonPayload": "{ }" + "jsonPayload": "{ }", + "allowedInBasicView": true + }, + { + "name": "Heal", + "type": "batch", + "jsonPayload": "{ \"actions\": [\"Heal Player\", \"Remove\"] }", + "allowedInBasicView": true } ] }, "asset-packs::Triggers": { "value": [ { - "type": "on_click", + "type": "on_input_action", "actions": [ { "id": "{self:asset-packs::Actions}", - "name": "Heal Player" - }, - { - "id": "{self:asset-packs::Actions}", - "name": "Remove" + "name": "Heal" } - ] + ], + "basicViewId": "trigger-when-clicked" + } + ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "First Aid", + "fields": [ + { + "name": "Healing Points", + "type": "asset-packs::Actions", + "basicViewId": "action-heal-player", + "layout": "{\"multiplier\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Healing Points Amount\" } }" } ] } } -} \ No newline at end of file +} diff --git a/packs/smart_items/assets/healing_pad/data.json b/packs/smart_items/assets/healing_pad/data.json index f4ecfa279..0d42e7ed0 100644 --- a/packs/smart_items/assets/healing_pad/data.json +++ b/packs/smart_items/assets/healing_pad/data.json @@ -22,17 +22,21 @@ { "name": "Heal Player", "type": "heal_player", - "jsonPayload": "{ \"multiplier\": 5 }" + "jsonPayload": "{ \"multiplier\": 5 }", + "basicViewId": "action-heal-player" }, { "name": "Start Healing", "type": "start_loop", - "jsonPayload": "{ \"actions\": [\"Heal Player\"], \"interval\": 0.5 }" + "jsonPayload": "{ \"actions\": [\"Heal Player\"], \"interval\": 0.5 }", + "basicViewId": "action-healing-interval", + "allowedInBasicView": true }, { "name": "Stop Healing", "type": "stop_loop", - "jsonPayload": "{ \"action\": \"Heal Player\" }" + "jsonPayload": "{ \"action\": \"Heal Player\" }", + "allowedInBasicView": true } ] }, @@ -49,7 +53,8 @@ "id": "{self:asset-packs::Actions}", "name": "Play Heal Sound" } - ] + ], + "basicViewId": "trigger-when-start-healing" }, { "type": "on_player_leaves_area", @@ -58,7 +63,26 @@ "id": "{self:asset-packs::Actions}", "name": "Stop Healing" } - ] + ], + "basicViewId": "trigger-when-stop-healing" + } + ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Healing Pad", + "fields": [ + { + "name": "Healing Points", + "type": "asset-packs::Actions", + "basicViewId": "action-heal-player", + "layout": "{\"multiplier\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Healing Points Amount\" } }" + }, + { + "name": "Interval Healing", + "type": "asset-packs::Actions", + "basicViewId": "action-healing-interval", + "layout": "{\"interval\": { \"field\": \"RangeField\", \"label\": \"Healing Interval\", \"step\": \"0.1\" } }" } ] } diff --git a/packs/smart_items/assets/health_bar/data.json b/packs/smart_items/assets/health_bar/data.json index 16a738a76..0f3a9efed 100644 --- a/packs/smart_items/assets/health_bar/data.json +++ b/packs/smart_items/assets/health_bar/data.json @@ -19,17 +19,20 @@ { "name": "Heal", "type": "increment_counter", - "jsonPayload": "{ \"amount\": 1 }" + "jsonPayload": "{ \"amount\": 1 }", + "allowedInBasicView": true }, { "name": "Damage", "type": "decrease_counter", - "jsonPayload": "{ \"amount\": 1 }" + "jsonPayload": "{ \"amount\": 1 }", + "allowedInBasicView": true }, { "name": "Reset", "type": "set_counter", - "jsonPayload": "{ \"counter\": 100 }" + "jsonPayload": "{ \"counter\": 100 }", + "allowedInBasicView": true }, { "name": "Remove", @@ -47,7 +50,8 @@ "id": "{self:asset-packs::Actions}", "name": "Damage" } - ] + ], + "basicViewId": "trigger-when-damaged" }, { "type": "on_heal_player", @@ -56,7 +60,8 @@ "id": "{self:asset-packs::Actions}", "name": "Heal" } - ] + ], + "basicViewId": "trigger-when-healed" }, { "type": "on_counter_change", @@ -72,7 +77,8 @@ "id": "{self:asset-packs::Actions}", "name": "Remove" } - ] + ], + "basicViewId": "trigger-when-health-reaches-zero" } ] }, @@ -84,6 +90,21 @@ "maxValue": 100, "primaryColor": "#00FF00", "secondaryColor:": "#FF0000" + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Health Bar", + "fields": [ + { + "name": "Health Points", + "type": "asset-packs::Counter" + }, + { + "name": "When Health Reaches Zero", + "type": "asset-packs::Triggers", + "basicViewId": "trigger-when-health-reaches-zero" + } + ] } } } \ No newline at end of file diff --git a/packs/smart_items/assets/respawn_pad/data.json b/packs/smart_items/assets/respawn_pad/data.json index 2d609649f..4b29ad6de 100644 --- a/packs/smart_items/assets/respawn_pad/data.json +++ b/packs/smart_items/assets/respawn_pad/data.json @@ -18,7 +18,8 @@ { "name": "Respawn Player", "type": "batch", - "jsonPayload": "{ \"actions\": [\"Move Player\", \"Play Spawn Sound\"] }" + "jsonPayload": "{ \"actions\": [\"Move Player\", \"Play Spawn Sound\"] }", + "allowedInBasicView": true }, { "name": "Move Player", @@ -31,6 +32,26 @@ "jsonPayload": "{ \"src\": \"{assetPath}/spawn.mp3\" }" } ] + }, + "asset-packs::Triggers": { + "value": [ + { + "type": "on_player_spawn", + "actions": [], + "basicViewId": "trigger-when-player-spawn" + } + ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Respawn Pad", + "fields": [ + { + "name": "When Player Spawns Here", + "type": "asset-packs::Triggers", + "basicViewId": "trigger-when-player-spawn" + } + ] } } -} \ No newline at end of file +} diff --git a/packs/smart_items/assets/robot/data.json b/packs/smart_items/assets/robot/data.json index 1fce34994..69587c332 100644 --- a/packs/smart_items/assets/robot/data.json +++ b/packs/smart_items/assets/robot/data.json @@ -16,12 +16,21 @@ { "name": "Die", "type": "batch", - "jsonPayload": "{ \"actions\": [\"Play Explosion Animation\", \"Stop Attack Loop\", \"Delay Remove\"] }" + "jsonPayload": "{ \"actions\": [\"Play Explosion Animation\", \"Stop Attack Loop\", \"Delay Remove\"] }", + "allowedInBasicView": true }, { "name": "Follow", "type": "follow_player", - "jsonPayload": "{ \"speed\": 1, \"minDistance\": 2, \"x\": true, \"y\": false, \"z\": true }" + "jsonPayload": "{ \"speed\": 1, \"minDistance\": 2, \"x\": true, \"y\": false, \"z\": true }", + "basicViewId": "action-follow-player", + "allowedInBasicView": true + }, + { + "name": "Stop Following Player", + "type": "stop_following_player", + "jsonPayload": "{ }", + "allowedInBasicView": true }, { "name": "Play Attack Animation", @@ -31,7 +40,9 @@ { "name": "Damage", "type": "damage", - "jsonPayload": "{ \"radius\": 3, \"hits\": 10, \"layer\": \"player\" }" + "jsonPayload": "{ \"radius\": 3, \"hits\": 10, \"layer\": \"player\" }", + "basicViewId": "action-damage", + "allowedInBasicView": true }, { "name": "Attack Loop", @@ -92,6 +103,24 @@ ] } ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Robot Enemy", + "fields": [ + { + "name": "Damage", + "type": "asset-packs::Actions", + "basicViewId": "action-damage", + "layout":"{\"radius\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Attack Radius\" }, \"hits\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Attack Damage Points\" }, \"layer\": { \"field\": \"Dropdown\", \"label\": \"Damage Target\" } }" + }, + { + "name": "Speed", + "type": "asset-packs::Actions", + "basicViewId": "action-follow-player", + "layout":"{\"speed\": { \"field\": \"TextField\", \"type\": \"number\" } }" + } + ] } } -} \ No newline at end of file +} diff --git a/packs/smart_items/assets/spikes/data.json b/packs/smart_items/assets/spikes/data.json index 598871cf1..76dc84635 100644 --- a/packs/smart_items/assets/spikes/data.json +++ b/packs/smart_items/assets/spikes/data.json @@ -22,17 +22,21 @@ { "name": "Damage", "type": "damage", - "jsonPayload": "{ \"radius\": 5, \"hits\": 15, \"layer\": \"player\" }" + "jsonPayload": "{ \"radius\": 5, \"hits\": 15, \"layer\": \"player\" }", + "basicViewId": "action-damage" }, { "name": "Start Damage", "type": "start_loop", - "jsonPayload": "{ \"actions\": [\"Damage Batch\"], \"interval\": 2 }" + "jsonPayload": "{ \"actions\": [\"Damage Batch\"], \"interval\": 2 }", + "basicViewId": "action-damage-interval", + "allowedInBasicView": true }, { "name": "Stop Damage", "type": "stop_loop", - "jsonPayload": "{ \"action\": \"Damage Batch\" }" + "jsonPayload": "{ \"action\": \"Damage Batch\" }", + "allowedInBasicView": true }, { "name": "Damage Batch", @@ -62,6 +66,24 @@ ] } ] + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Spikes", + "fields": [ + { + "name": "Damage", + "type": "asset-packs::Actions", + "basicViewId": "action-damage", + "layout":"{\"hits\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Damage Points\" }, \"layer\": { \"field\": \"Dropdown\", \"label\": \"Damage Target\" }}" + }, + { + "name": "Interval Damage", + "type": "asset-packs::Actions", + "basicViewId": "action-damage-interval", + "layout": "{\"interval\": { \"field\": \"RangeField\", \"label\": \"Damage Interval\", \"step\": \"0.1\" } }" + } + ] } } } \ No newline at end of file diff --git a/packs/smart_items/assets/sword/data.json b/packs/smart_items/assets/sword/data.json index 4cd97ec93..426cba388 100644 --- a/packs/smart_items/assets/sword/data.json +++ b/packs/smart_items/assets/sword/data.json @@ -17,7 +17,8 @@ { "name": "Pick Up", "type": "batch", - "jsonPayload": "{ \"actions\": [\"Set Ready\"] }" + "jsonPayload": "{ \"actions\": [\"Set Ready\"] }", + "allowedInBasicView": true }, { "name": "Set Ready", @@ -37,7 +38,8 @@ { "name": "Damage", "type": "damage", - "jsonPayload": "{ \"radius\": 3, \"hits\": 10, \"layer\": \"non_player\" }" + "jsonPayload": "{ \"radius\": 3, \"hits\": 10, \"layer\": \"non_player\" }", + "basicViewId": "action-damage" }, { "name": "Set Cooling Down", @@ -47,7 +49,9 @@ { "name": "Start Cool Down Delay", "type": "start_delay", - "jsonPayload": "{ \"actions\": [\"Set Ready\"], \"timeout\": 0.5 }" + "jsonPayload": "{ \"actions\": [\"Set Ready\"], \"timeout\": 0.5 }", + "basicViewId": "action-cool-down-delay", + "allowedInBasicView": true }, { "name": "Cool Down", @@ -114,6 +118,24 @@ "Cooling Down" ], "defaultValue": "Idle" + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Sword", + "fields": [ + { + "name": "Damage", + "type": "asset-packs::Actions", + "basicViewId": "action-damage", + "layout":"{\"radius\": { \"field\": \"TextField\", \"type\": \"number\" }, \"hits\": { \"field\": \"TextField\", \"type\": \"number\", \"label\": \"Damage Points\" }, \"layer\": { \"field\": \"Dropdown\", \"label\": \"Damage Target\" }}" + }, + { + "name": "Attack Cooldown", + "type": "asset-packs::Actions", + "basicViewId": "action-cool-down-delay", + "layout": "{\"timeout\": { \"field\": \"RangeField\", \"label\": \"Attack Cooldown\", \"step\": \"0.1\" } }" + } + ] } } } \ No newline at end of file diff --git a/packs/smart_items/assets/wooden_wall/data.json b/packs/smart_items/assets/wooden_wall/data.json index 11515257e..eee3fad24 100644 --- a/packs/smart_items/assets/wooden_wall/data.json +++ b/packs/smart_items/assets/wooden_wall/data.json @@ -30,9 +30,21 @@ "jsonPayload": "{ \"src\": \"{assetPath}/fall.mp3\" }" }, { - "name": "Decrease Counter", + "name": "Damage", "type": "decrease_counter", - "jsonPayload": "{ \"amount\": 1 }" + "jsonPayload": "{ \"amount\": 1 }", + "allowedInBasicView": true + }, + { + "name": "Destroy", + "type": "set_counter", + "jsonPayload": "{ \"counter\": 0 }", + "allowedInBasicView": true + }, + { + "name": "Destroy Batch", + "type": "batch", + "jsonPayload": "{ \"actions\": [\"Play Fall Animation\", \"Play Fall Sound\"] }" } ] }, @@ -50,9 +62,10 @@ "actions": [ { "id": "{self:asset-packs::Actions}", - "name": "Decrease Counter" + "name": "Damage" } - ] + ], + "basicViewId": "trigger-when-damaged" }, { "type": "on_counter_change", @@ -82,11 +95,7 @@ "actions": [ { "id": "{self:asset-packs::Actions}", - "name": "Play Fall Animation" - }, - { - "id": "{self:asset-packs::Actions}", - "name": "Play Fall Sound" + "name": "Destroy Batch" } ] } @@ -95,6 +104,16 @@ "asset-packs::Counter": { "id": "{self}", "value": 30 + }, + "inspector::Config": { + "isBasicViewEnabled": true, + "componentName": "Wooden Wall", + "fields": [ + { + "name": "Item Health Points", + "type": "asset-packs::Counter" + } + ] } } } \ No newline at end of file diff --git a/src/actions.ts b/src/actions.ts index 0b4e03f14..f6f258406 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1076,6 +1076,8 @@ export function createActionsSystem(engine: IEngine) { ) { const here = getWorldPosition(entity) void movePlayerTo({ newRelativePosition: here }) + const triggerEvents = getTriggerEvents(entity) + triggerEvents.emit(TriggerType.ON_PLAYER_SPAWN) } // PLACE_ON_PLAYER diff --git a/src/definitions.ts b/src/definitions.ts index 9c29613f3..cff4a7b2c 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -255,6 +255,7 @@ export function createComponents(engine: IEngine) { type: Schemas.String, jsonPayload: Schemas.String, allowedInBasicView: Schemas.Optional(Schemas.Boolean), + basicViewId: Schemas.Optional(Schemas.String), }), ), }) diff --git a/src/enums.ts b/src/enums.ts index 43557f140..b32927d25 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -102,6 +102,7 @@ export enum TriggerType { ON_GLOBAL_SECONDARY = 'on_global_secondary', ON_TICK = 'on_tick', ON_HEAL_PLAYER = 'on_heal_player', + ON_PLAYER_SPAWN = 'on_player_spawn', } export enum TriggerConditionType {