// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { SmartCharacterSystem } from "../../systems/smart-character/SmartCharacterSystem.sol"; import { EntityRecordParams, EntityMetadataParams } from "../../systems/entity-record/types.sol"; import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol"; import { IWorldCall } from "@latticexyz/world/src/IWorldKernel.sol"; import { SystemCall } from "@latticexyz/world/src/SystemCall.sol"; import { Systems } from "@latticexyz/world/src/codegen/tables/Systems.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; type SmartCharacterSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "SmartCharacterSy" })) SmartCharacterSystemType constant smartCharacterSystem = SmartCharacterSystemType.wrap( 0x737965766566726f6e74696572000000536d6172744368617261637465725379 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title SmartCharacterSystemLib * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) * @dev This library is automatically generated from the corresponding system contract. Do not edit manually. */ library SmartCharacterSystemLib { error SmartCharacterSystemLib_CallingFromRootSystem(); error SmartCharacter_AlreadyCreated(address account, uint256 smartObjectId); error SmartCharacterDoesNotExist(uint256 smartObjectId); error SmartCharacter_InvalidTenantId(uint256 smartObjectId, bytes32 tenantId); error SmartCharacter_InvalidTypeId(uint256 smartObjectId, uint256 typeId); error SmartCharacter_InvalidObjectId(uint256 smartObjectId); function createCharacter( SmartCharacterSystemType self, uint256 smartObjectId, address owner, uint256 tribeId, EntityRecordParams memory entityRecordParams, EntityMetadataParams memory entityRecordMetadata ) internal { return CallWrapper(self.toResourceId(), address(0)).createCharacter( smartObjectId, owner, tribeId, entityRecordParams, entityRecordMetadata ); } function updateTribeId(SmartCharacterSystemType self, uint256 smartObjectId, uint256 tribeId) internal { return CallWrapper(self.toResourceId(), address(0)).updateTribeId(smartObjectId, tribeId); } function removeCharacter(SmartCharacterSystemType self, uint256 smartObjectId) internal { return CallWrapper(self.toResourceId(), address(0)).removeCharacter(smartObjectId); } function getSmartCharacterClassId(SmartCharacterSystemType self) internal view returns (uint256) { return CallWrapper(self.toResourceId(), address(0)).getSmartCharacterClassId(); } function createCharacter( CallWrapper memory self, uint256 smartObjectId, address owner, uint256 tribeId, EntityRecordParams memory entityRecordParams, EntityMetadataParams memory entityRecordMetadata ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartCharacterSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createCharacter_uint256_address_uint256_EntityRecordParams_EntityMetadataParams.createCharacter, (smartObjectId, owner, tribeId, entityRecordParams, entityRecordMetadata) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function updateTribeId(CallWrapper memory self, uint256 smartObjectId, uint256 tribeId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartCharacterSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_updateTribeId_uint256_uint256.updateTribeId, (smartObjectId, tribeId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function removeCharacter(CallWrapper memory self, uint256 smartObjectId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartCharacterSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_removeCharacter_uint256.removeCharacter, (smartObjectId)); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function getSmartCharacterClassId(CallWrapper memory self) internal view returns (uint256) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartCharacterSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_getSmartCharacterClassId.getSmartCharacterClassId, ()); bytes memory worldCall = self.from == address(0) ? abi.encodeCall(IWorldCall.call, (self.systemId, systemCall)) : abi.encodeCall(IWorldCall.callFrom, (self.from, self.systemId, systemCall)); (bool success, bytes memory returnData) = address(_world()).staticcall(worldCall); if (!success) revertWithBytes(returnData); bytes memory result = abi.decode(returnData, (bytes)); return abi.decode(result, (uint256)); } function createCharacter( RootCallWrapper memory self, uint256 smartObjectId, address owner, uint256 tribeId, EntityRecordParams memory entityRecordParams, EntityMetadataParams memory entityRecordMetadata ) internal { bytes memory systemCall = abi.encodeCall( _createCharacter_uint256_address_uint256_EntityRecordParams_EntityMetadataParams.createCharacter, (smartObjectId, owner, tribeId, entityRecordParams, entityRecordMetadata) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function updateTribeId(RootCallWrapper memory self, uint256 smartObjectId, uint256 tribeId) internal { bytes memory systemCall = abi.encodeCall(_updateTribeId_uint256_uint256.updateTribeId, (smartObjectId, tribeId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function removeCharacter(RootCallWrapper memory self, uint256 smartObjectId) internal { bytes memory systemCall = abi.encodeCall(_removeCharacter_uint256.removeCharacter, (smartObjectId)); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function getSmartCharacterClassId(RootCallWrapper memory self) internal view returns (uint256) { bytes memory systemCall = abi.encodeCall(_getSmartCharacterClassId.getSmartCharacterClassId, ()); bytes memory result = SystemCall.staticcallOrRevert(self.from, self.systemId, systemCall); return abi.decode(result, (uint256)); } function callFrom(SmartCharacterSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(SmartCharacterSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(SmartCharacterSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(SmartCharacterSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(SmartCharacterSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (SmartCharacterSystemType) { return SmartCharacterSystemType.wrap(resourceId.unwrap()); } function getAddress(SmartCharacterSystemType self) internal view returns (address) { return Systems.getSystem(self.toResourceId()); } function _world() private view returns (IWorldCall) { return IWorldCall(StoreSwitch.getStoreAddress()); } } /** * System Function Interfaces * * We generate an interface for each system function, which is then used for encoding system calls. * This is necessary to handle function overloading correctly (which abi.encodeCall cannot). * * Each interface is uniquely named based on the function name and parameters to prevent collisions. */ interface _createCharacter_uint256_address_uint256_EntityRecordParams_EntityMetadataParams { function createCharacter( uint256 smartObjectId, address owner, uint256 tribeId, EntityRecordParams memory entityRecordParams, EntityMetadataParams memory entityRecordMetadata ) external; } interface _updateTribeId_uint256_uint256 { function updateTribeId(uint256 smartObjectId, uint256 tribeId) external; } interface _removeCharacter_uint256 { function removeCharacter(uint256 smartObjectId) external; } interface _getSmartCharacterClassId { function getSmartCharacterClassId() external; } using SmartCharacterSystemLib for SmartCharacterSystemType global; using SmartCharacterSystemLib for CallWrapper global; using SmartCharacterSystemLib for RootCallWrapper global;