Skip to content

THEjoezack/ShadowCaster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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