forked from latticexyz/mudbasics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request latticexyz#1 from marvinmarnold/marvinmarnold/beat…
…s-components feat: SoundUriComponent and UploadSoundSystem
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"components": ["PositionComponent", "CarriedByComponent"], | ||
"components": ["PositionComponent", "CarriedByComponent", "SoundUriComponent"], | ||
"systems": [ | ||
{ "name": "ComponentDevSystem", "writeAccess": ["*"] }, | ||
{ "name": "MoveSystem", "writeAccess": ["PositionComponent"] }, | ||
{ "name": "CatchSystem", "writeAccess": ["PositionComponent", "CarriedByComponent"] } | ||
{ "name": "CatchSystem", "writeAccess": ["PositionComponent", "CarriedByComponent"] }, | ||
{ "name": "UploadSoundSystem", "writeAccess": ["SoundUriComponent"] } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity >=0.8.0; | ||
import "std-contracts/components/StringComponent.sol"; | ||
|
||
uint256 constant ID = uint256(keccak256("component.SoundUri")); | ||
|
||
contract SoundUriComponent is StringComponent { | ||
constructor(address world) StringComponent(world, ID) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
import "solecs/System.sol"; | ||
import { IWorld } from "solecs/interfaces/IWorld.sol"; | ||
import { getAddressById } from "solecs/utils.sol"; | ||
|
||
import { SoundUriComponent, ID as SoundUriComponentID } from "../components/SoundUriComponent.sol"; | ||
|
||
uint256 constant ID = uint256(keccak256("system.UploadSound")); | ||
|
||
contract UploadSoundSystem is System { | ||
constructor(IWorld _world, address _components) System(_world, _components) {} | ||
|
||
function execute(bytes memory arguments) public returns (bytes memory) { | ||
(uint256 entity, string memory targetSoundUri) = abi.decode(arguments, (uint256, string)); | ||
|
||
SoundUriComponent soundComponent = SoundUriComponent(getAddressById(components, SoundUriComponentID)); | ||
soundComponent.set(entity, targetSoundUri); | ||
} | ||
|
||
function executeTyped(uint256 entity, string memory targetSound) public returns (bytes memory) { | ||
return execute(abi.encode(entity, targetSound)); | ||
} | ||
} |