Make thingsHit use streaming
This commit is contained in:
@@ -8,17 +8,19 @@ import Dodge.WorldEvent
|
||||
import Geometry
|
||||
|
||||
--import Data.Maybe
|
||||
import Data.List
|
||||
--import Data.List
|
||||
import Data.Bifunctor
|
||||
import Data.Tuple
|
||||
import Streaming
|
||||
import qualified Streaming.Prelude as S
|
||||
|
||||
-- not sure why we need to keep a list of seen walls, but seems to loop
|
||||
-- infinitely when removed
|
||||
-- this needs to be tested with both reflections and refractions
|
||||
reflectLaserAlong :: Float -> [Wall] -> Point2 -> Point2 -> World
|
||||
-> (Maybe (Point2,Either Creature Wall),[Point2])
|
||||
reflectLaserAlong phasev seenWl sp ep w = case find (notseen seenWl)
|
||||
$ thingsHitExceptCrLongLine Nothing sp ep w of
|
||||
reflectLaserAlong phasev seenWl sp ep w = case runIdentity . S.head_ . S.dropWhile (notseen seenWl)
|
||||
$ thingsHitExceptCr Nothing sp ep w of
|
||||
Just (p,Right wl)
|
||||
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev (wl:seenWl) p
|
||||
(p +.+ 800 *.* unitVectorAtAngle (reflDirWall sp p wl)) w
|
||||
|
||||
Reference in New Issue
Block a user