{"id":"elentium/pathfindingplus","name":"pathfindingplus","scope":"elentium","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.0.1","latest":"0.0.1","versions":["0.0.1"],"license":"Apache-2.0","licenseRating":"safe","licenseCaveats":["Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved.","License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"6c913cdbef4e40bb7d8c115c05b4d27eb55f4bbe4a3ef50789dbe58fa22af506","likes":0,"downloads":0,"install":"forest install elentium/pathfindingplus","url":"https://forest.dev/p/roblox/elentium/pathfindingplus","files":"https://api.forest.dev/ai/package/roblox/elentium/pathfindingplus/files","readme":"# PathfindingPlus\n<p align=\"center\">\n  <a href=\"LICENSE\"><img src=\"https://img.shields.io/badge/License-Apache%202.0-blue?style=flat-square\" alt=\"License\" /></a>\n  <a href=\"https://wally.run/package/elentium/pathfindingplus\"><img src=\"https://img.shields.io/badge/📦_Wally-elentium%2Fpathfindingplus-00b4ab?style=flat-square\" alt=\"Wally\" /></a>\n</p>\n\n<p align=\"center\">\n  <strong>A Powerful Pathfinding Library</strong>\n</p>\n\nPathfindingPlus is a powerful PathfindingService wrapper designed for smart pathfinding with intelligent caching and optimization.\n\n## Features\n\n- **Smart Caching**: Caches path computation results and reusable Path objects to minimize redundant calculations\n- **Raycast Optimization**: Automatically checks if a direct path is clear before computing a full path\n- **Performance Oriented**: Designed for games with static maps that require frequent path computations\n- **Simple API**: Single main method (`CalculatePath`) for all pathfinding needs\n- **Automatic Cleanup**: Built-in cache expiration and cleanup system\n\n## Notes\n\n- The library is designed to handle scalable path computations with a single main method (`CalculatePath`)\n- It is optimized for static maps. Due to its caching system, it may not be ideal for dynamic maps with sudden environment changes\n- Best suited for games with static maps that require a lot of path computing\n\n## Installation\n\nAdd PathfindingPlus to your `wally.toml`:\n\n```toml\n[dependencies]\nPathfindingPlus = \"elentium/pathfindingplus@0.0.1\"\n```\n\nThen run `wally install`.\n\n## Usage\n\n```lua\nlocal PathfindingPlus = require(path.to.PathfindingPlus)\n\n-- Basic usage\nlocal success, result = PathfindingPlus.CalculatePath(\n    Vector3.new(0, 0, 0),  -- Start position\n    Vector3.new(100, 0, 100)  -- End position\n)\n\nif success then\n    if type(result) == \"vector\" then\n        -- Direct path is clear, result is the end position\n        print(\"Direct path available:\", result)\n    else\n        -- Path computed, result is an array of PathWaypoints\n        for _, waypoint in result do\n            print(\"Waypoint:\", waypoint.Position)\n        end\n    end\nend\n\n-- With agent parameters\nlocal success, waypoints = PathfindingPlus.CalculatePath(\n    startPosition,\n    endPosition,\n    {\n        AgentRadius = 2,\n        AgentHeight = 5,\n        AgentCanJump = true,\n        AgentCanClimb = true,\n        WaypointSpacing = 4,\n        Costs = {\n            Water = 10,\n            Lava = 20\n        }\n    }\n)\n\n-- With raycast parameters for optimization\nlocal raycastParams = RaycastParams.new()\nraycastParams.FilterType = Enum.RaycastFilterType.Blacklist\nraycastParams.FilterDescendantsInstances = {character}\n\nlocal success, result = PathfindingPlus.CalculatePath(\n    startPosition,\n    endPosition,\n    nil,  -- No agent parameters\n    raycastParams\n)\n```\n\n## How the Library Works\n\nPathfindingPlus uses a multi-layered caching system to optimize pathfinding performance:\n\n1. **Operation Cache**: Stores the results of path computations (either direct paths or waypoint arrays) to avoid recalculating identical paths\n2. **Free Path Cache**: Reuses Path objects with the same agent parameters, reducing object creation overhead\n3. **Automatic Cleanup**: Periodically removes expired cache entries based on configurable lifetimes\n4. **Raycast Optimization**: Before computing a full path, checks if a direct raycast is clear, avoiding unnecessary path computations\n\nThe library is designed to handle high-frequency pathfinding requests efficiently, making it ideal for games with many NPCs or agents that need to navigate static environments.\n\n## API\n\n### `CalculatePath<T>(Start, End, AgentParameters?, Params?) -> (boolean, (T | {PathWaypoint})?)`\n\nCalculates a path between two points using a three-step optimization process:\n\n1. **Cache Check**: Checks if the operation result is already cached. If found, returns the cached result immediately\n2. **Raycast Check**: Attempts to raycast in the direction to check if the path is clear. If clear, returns the end position directly\n3. **Path Computation**: If the path is not clear, acquires a Path object (from cache if available), computes the path, caches the result, and returns the waypoints\n\n**Parameters:**\n- `Start: Vector3 | vector` - The start position of the path\n- `End: Vector3 | vector` - The end position of the path\n- `AgentParameters: AgentParameters?` - Optional agent parameters (AgentRadius, AgentHeight, AgentCanJump, AgentCanClimb, WaypointSpacing, Costs)\n- `Params: RaycastParams?` - Optional raycast parameters for the direct path check\n\n**Returns:**\n- `boolean` - Whether the path calculation was successful\n- `((vector | Vector3) | {PathWaypoint})?` - The result: either the end position (if direct path is clear) or an array of PathWaypoints\n\n### `ClearOperationsCache() -> ()`\n\nClears the operations cache, removing all cached path computation results.\n\n### `ClearFreePathsCache() -> ()`\n\nClears the free paths cache, removing all cached Path objects.\n\n## Configuration\n\nThe library uses the following default constants (defined in the source code):\n\n- `MAX_OPERATIONS_CACHE_COUNT`: 100 - Maximum number of cached path results\n- `MAX_FREE_PATHS_COUNT`: 50 - Maximum number of cached Path objects\n- `OPERATION_CACHE_LIFETIME`: 30 seconds - How long operation results are cached\n- `FREE_PATH_LIFETIME`: 30 seconds - How long Path objects are cached\n- `CACHE_CLEANUP_INTERVAL`: 5 seconds - How often cache cleanup runs\n\nThese can be modified in the source code if needed for your specific use case.","readmeTruncated":false}