// SPDX-License-Identifier: MIT pragma solidity >=0.8.24; /* Autogenerated file. Do not edit manually. */ import { SmartTurretSystem } from "../../systems/smart-turret/SmartTurretSystem.sol"; import { CreateAndAnchorParams } from "../../systems/deployable/types.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; import { TargetPriority, Turret, SmartTurretTarget, AggressionParams } from "../../systems/smart-turret/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 { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; type SmartTurretSystemType is bytes32; // equivalent to WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "evefrontier", name: "SmartTurretSyste" })) SmartTurretSystemType constant smartTurretSystem = SmartTurretSystemType.wrap( 0x737965766566726f6e74696572000000536d6172745475727265745379737465 ); struct CallWrapper { ResourceId systemId; address from; } struct RootCallWrapper { ResourceId systemId; address from; } /** * @title SmartTurretSystemLib * @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 SmartTurretSystemLib { error SmartTurretSystemLib_CallingFromRootSystem(); function createAndAnchorTurret( SmartTurretSystemType self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { return CallWrapper(self.toResourceId(), address(0)).createAndAnchorTurret(params, networkNodeId); } function configureTurret(SmartTurretSystemType self, uint256 smartObjectId, ResourceId systemId) internal { return CallWrapper(self.toResourceId(), address(0)).configureTurret(smartObjectId, systemId); } function inProximity( SmartTurretSystemType self, uint256 smartObjectId, TargetPriority[] memory priorityQueue, Turret memory turret, SmartTurretTarget memory turretTarget ) internal returns (TargetPriority[] memory updatedPriorityQueue) { return CallWrapper(self.toResourceId(), address(0)).inProximity(smartObjectId, priorityQueue, turret, turretTarget); } function aggression( SmartTurretSystemType self, AggressionParams memory params ) internal returns (TargetPriority[] memory updatedPriorityQueue) { return CallWrapper(self.toResourceId(), address(0)).aggression(params); } function createAndAnchorTurret( CallWrapper memory self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartTurretSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _createAndAnchorTurret_CreateAndAnchorParams_uint256.createAndAnchorTurret, (params, networkNodeId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function configureTurret(CallWrapper memory self, uint256 smartObjectId, ResourceId systemId) internal { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartTurretSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _configureTurret_uint256_ResourceId.configureTurret, (smartObjectId, systemId) ); self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); } function inProximity( CallWrapper memory self, uint256 smartObjectId, TargetPriority[] memory priorityQueue, Turret memory turret, SmartTurretTarget memory turretTarget ) internal returns (TargetPriority[] memory updatedPriorityQueue) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartTurretSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall( _inProximity_uint256_TargetPriorityArray_Turret_SmartTurretTarget.inProximity, (smartObjectId, priorityQueue, turret, turretTarget) ); bytes memory result = self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); return abi.decode(result, (TargetPriority[])); } function aggression( CallWrapper memory self, AggressionParams memory params ) internal returns (TargetPriority[] memory updatedPriorityQueue) { // if the contract calling this function is a root system, it should use `callAsRoot` if (address(_world()) == address(this)) revert SmartTurretSystemLib_CallingFromRootSystem(); bytes memory systemCall = abi.encodeCall(_aggression_AggressionParams.aggression, (params)); bytes memory result = self.from == address(0) ? _world().call(self.systemId, systemCall) : _world().callFrom(self.from, self.systemId, systemCall); return abi.decode(result, (TargetPriority[])); } function createAndAnchorTurret( RootCallWrapper memory self, CreateAndAnchorParams memory params, uint256 networkNodeId ) internal { bytes memory systemCall = abi.encodeCall( _createAndAnchorTurret_CreateAndAnchorParams_uint256.createAndAnchorTurret, (params, networkNodeId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function configureTurret(RootCallWrapper memory self, uint256 smartObjectId, ResourceId systemId) internal { bytes memory systemCall = abi.encodeCall( _configureTurret_uint256_ResourceId.configureTurret, (smartObjectId, systemId) ); SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); } function inProximity( RootCallWrapper memory self, uint256 smartObjectId, TargetPriority[] memory priorityQueue, Turret memory turret, SmartTurretTarget memory turretTarget ) internal returns (TargetPriority[] memory updatedPriorityQueue) { bytes memory systemCall = abi.encodeCall( _inProximity_uint256_TargetPriorityArray_Turret_SmartTurretTarget.inProximity, (smartObjectId, priorityQueue, turret, turretTarget) ); bytes memory result = SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); return abi.decode(result, (TargetPriority[])); } function aggression( RootCallWrapper memory self, AggressionParams memory params ) internal returns (TargetPriority[] memory updatedPriorityQueue) { bytes memory systemCall = abi.encodeCall(_aggression_AggressionParams.aggression, (params)); bytes memory result = SystemCall.callWithHooksOrRevert(self.from, self.systemId, systemCall, msg.value); return abi.decode(result, (TargetPriority[])); } function callFrom(SmartTurretSystemType self, address from) internal pure returns (CallWrapper memory) { return CallWrapper(self.toResourceId(), from); } function callAsRoot(SmartTurretSystemType self) internal view returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), msg.sender); } function callAsRootFrom(SmartTurretSystemType self, address from) internal pure returns (RootCallWrapper memory) { return RootCallWrapper(self.toResourceId(), from); } function toResourceId(SmartTurretSystemType self) internal pure returns (ResourceId) { return ResourceId.wrap(SmartTurretSystemType.unwrap(self)); } function fromResourceId(ResourceId resourceId) internal pure returns (SmartTurretSystemType) { return SmartTurretSystemType.wrap(resourceId.unwrap()); } function getAddress(SmartTurretSystemType 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 _createAndAnchorTurret_CreateAndAnchorParams_uint256 { function createAndAnchorTurret(CreateAndAnchorParams memory params, uint256 networkNodeId) external; } interface _configureTurret_uint256_ResourceId { function configureTurret(uint256 smartObjectId, ResourceId systemId) external; } interface _inProximity_uint256_TargetPriorityArray_Turret_SmartTurretTarget { function inProximity( uint256 smartObjectId, TargetPriority[] memory priorityQueue, Turret memory turret, SmartTurretTarget memory turretTarget ) external; } interface _aggression_AggressionParams { function aggression(AggressionParams memory params) external; } using SmartTurretSystemLib for SmartTurretSystemType global; using SmartTurretSystemLib for CallWrapper global; using SmartTurretSystemLib for RootCallWrapper global;