Make thingsHit use streaming

This commit is contained in:
2022-06-26 12:13:31 +01:00
parent f47059ae9b
commit 5ba0ca9f9c
8 changed files with 49 additions and 61 deletions
+5 -3
View File
@@ -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