Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 1.66 KB

README.md

File metadata and controls

31 lines (25 loc) · 1.66 KB

ShadowCaster

This is a copy of the ShadowCasting code from the MSDN Developer Blog of Eric Lippert.

Read more about it in his series of posts on blogs.msdn.microsoft.com:

Availabe via nuget:

Install-Package ShadowCaster

Usage Example:

var cellsInFieldOfView = new List<Cell>(); // will hold our Cell which ARE visible in the field of view

ShadowCaster.ComputeFieldOfViewWithShadowCasting(
  5, // x position of the object doing the viewing
  6, // x position of the object doing the viewing
  4, // The sight radius, represents how far the position can see
  (x,y) => { return myMap.getCell(x,y).IsWall(); }, // Func that returns whether the cell can be seen through
  (x,y) => { cellsInFieldOfView.Add(myMap.getCell(x,y)); } // Action that specifies what to do with each item that IS in the field of view
);

// Note: myMap and Cell objects are just examples of the types of classes you might use