// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { LocationSystem } from "../../systems/location/LocationSystem.sol"; import { LocationData } from "../index.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 LocationSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "LocationSystem" })) LocationSystemType constant locationSystem = LocationSystemType.wrap( 0x737965766566726f6e746965720000004c6f636174696f6e53797374656d0000 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title LocationSystemLib * @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 LocationSystemLib { error LocationSystemLib_CallingFromRootSystem(); function saveLocation(LocationSystemType self, uint256 smartObjectId, LocationData memory locationData) internal { return CallWrapper(self.toResourceId(), address(0)).saveLocation(smartObjectId, locationData); } function saveLocation(CallWrapper memory self, uint256 smartObjectId, LocationData memory locationData) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert LocationSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _saveLocation_uint256_LocationData.saveLocation, (smartObjectId, locationData) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function saveLocation(RootCallWrapper memory self, uint256 smartObjectId, LocationData memory locationData) internal { bytes memory systemCall = abi.encodeCall( _saveLocation_uint256_LocationData.saveLocation, (smartObjectId, locationData) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function callFrom(LocationSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(LocationSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(LocationSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(LocationSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(LocationSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (LocationSystemType) { return LocationSystemType.wrap(resourceId.unwrap()); } function getAddress(LocationSystemType 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 _saveLocation_uint256_LocationData { function saveLocation(uint256 smartObjectId, LocationData memory locationData) external; } using LocationSystemLib for LocationSystemType global; using LocationSystemLib for CallWrapper global; using LocationSystemLib for RootCallWrapper global;