{"id":13568151,"url":"https://github.com/BenMakesGames/FoV","last_synced_at":"2025-04-04T04:30:44.885Z","repository":{"id":153234297,"uuid":"628018947","full_name":"BenMakesGames/FoV","owner":"BenMakesGames","description":"A collection of field-of-view/line-of-sight algorithms designed for tile-based games.","archived":false,"fork":false,"pushed_at":"2024-02-03T05:20:23.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-19T00:52:46.658Z","etag":null,"topics":["field-of-view","fov","fov-algorithms","line-of-sight","los","los-algorithms","tile-based","tile-based-game"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenMakesGames.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-04-14T18:06:00.000Z","updated_at":"2023-04-20T16:24:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"1e3135a9-de6a-44e5-bc13-2588e3074f51","html_url":"https://github.com/BenMakesGames/FoV","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenMakesGames%2FFoV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenMakesGames%2FFoV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenMakesGames%2FFoV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenMakesGames%2FFoV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenMakesGames","download_url":"https://codeload.github.com/BenMakesGames/FoV/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123071,"owners_count":20887259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["field-of-view","fov","fov-algorithms","line-of-sight","los","los-algorithms","tile-based","tile-based-game"],"created_at":"2024-08-01T14:00:20.771Z","updated_at":"2025-04-04T04:30:44.250Z","avatar_url":"https://github.com/BenMakesGames.png","language":"C#","funding_links":["https://ko-fi.com/A0A12KQ16"],"categories":["C# #"],"sub_categories":[],"readme":"# What Is It?\n\n`BenMakesGames.FoV` is a collection of field-of-view algorithms designed for square tile grids. It features the following algorithms:\n\n* Diamond-wall\n* Milazzo's Beveled-wall\n* Raycasting\n* Shadowcasting\n\nField-of-view/line-of-sight is useful for roguelikes, and other tactical, tile-based games where vision plays an important role.\n\n[![Buy Me a Coffee at ko-fi.com](https://raw.githubusercontent.com/BenMakesGames/AssetsForNuGet/main/buymeacoffee.png)](https://ko-fi.com/A0A12KQ16)\n\n# How to Use\n\n## Install\n\n```powershell\ndotnet add package BenMakesGames.FoV \n```\n\n## Create a Map\n\nYour map must implement `IFoVMap`, which requires a `Width` and `Height` property, and a method that returns whether or not a given tile is opaque:\n\nFor example:\n\n```c#\npublic sealed class MyMap: IFoVMap\n{\n    public int Width { get; }\n    public int Height { get; }\n\n    // store your tiles however you want; here's one possibility:\n    public MyTile[] Tiles { get; }\n\n    // BlocksLight is required by IFoVMap; here's one possible implementation:\n    bool BlocksLight(int x, int y)\n    {\n        if(x \u003c 0 || x \u003e= Width || y \u003c 0 || y \u003e= Height)\n            return true;\n\n        return Tiles[x + y * Width].IsOpaque;\n    }\n\n    ...\n}\n```\n\nAnother common implementation is to use a `Dictionary\u003c(int X, int Y), MyTile\u003e` collection to store the map.\n\n## Call One of the FoV Algorithms\n\nAll of the algorithms have the same signature:\n\n```c#\nHashSet\u003c(int X, int Y)\u003e Compute(IFoVMap map, (int X, int Y) origin, int radius)\n```\n\nThey take a map, origin point, and sight radius, and returns a set of points that are visible from the origin.\n\nBasic usage:\n\n```c#\nvar visibleTiles = DiamondWallsFoV.Compute(Map, (Player.X, Player.Y), Player.SightRadius);\n\nfor(int y = 0; y \u003c Map.Height; y++)\n{\n    for(int x = 0; x \u003c Map.Width; x++)\n    {\n        if(visibleTiles.Contains((x, y)))\n        {\n            // tile is visible; draw it!\n        }\n        else\n        {\n            // don't draw the tile, or draw it as a fog of war tile\n        }\n    }\n}\n```\n\nWhen implementing field-of-view in your game, you should only compute a new field of view when the player moves, or the map changes (such as a door opening or closing).\n\n### Available Algorithms, and Their Features\n\n* `DiamondWallsFoV`\n  * Relatively fast algorithm. Compared to other algorithms, reveals more tiles in a given sight radius.\n* `MilazzoFoV`\n  * Medium speed; designed to have intuitive lines of sight, especially for maps which contain many single-tile walls/pillars.\n* `RayCastFoV`\n  * Slowest algorithm, with occasionally unintuitive lines of sight. Not generally recommended; included for historical reasons.\n* `ShadowCastFoV`\n  * The fastest algorithm of the bunch, especially when used in large, open spaces with large sight radii.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBenMakesGames%2FFoV","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBenMakesGames%2FFoV","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBenMakesGames%2FFoV/lists"}