Remove Smoke datatype

This commit is contained in:
jgk
2021-03-24 00:00:13 +01:00
parent b7ec173d0e
commit 1a91d29896
8 changed files with 7 additions and 113 deletions
+4 -23
View File
@@ -58,18 +58,12 @@ halfHeight w = _windowY w / 2
hasLOS :: Point2 -> Point2 -> World -> Bool
{-# INLINE hasLOS #-}
hasLOS p1 p2 w = (not $ collidePointWallsSimple p1 p2 nearbyWalls)
&& (not $ collidePointSmoke p1 p2 nearbySmoke)
where nearbyWalls = wallsAlongLine p1 p2 w
nearbySmoke = _smoke w -- smokeAlongLine p1 p2 w
smokeLOS :: Point2 -> Point2 -> World -> Bool
smokeLOS p1 p2 w = not $ collidePointSmoke p1 p2 nearbySmoke
where nearbySmoke = _smoke w
hasLOSIndirect :: Point2 -> Point2 -> World -> Bool
hasLOSIndirect p1 p2 w = case collidePointIndirect p1 p2 $ wallsAlongLine p1 p2 w
of Just _ -> False
Nothing -> True && smokeLOS p1 p2 w
Nothing -> True
isWalkable :: Point2 -> Point2 -> World -> Bool
isWalkable p1 p2 w = not $ collidePointWalkable p1 p2 nearbyWalls
@@ -129,24 +123,21 @@ canWalk i j w = not $ collidePointWalkable ipos jpos $ wallsAlongLine ipos jpos
canSeeIndirect :: Int -> Int -> World -> Bool
canSeeIndirect i j w = case collidePointIndirect ipos jpos $ wallsAlongLine ipos jpos w
of Just _ -> False
Nothing -> True && smokeLOS ipos jpos w
Nothing -> True
where ipos = _crPos (_creatures w IM.! i)
jpos = _crPos (_creatures w IM.! j)
canSeeFire :: Point2 -> Point2 -> World -> Bool
canSeeFire p p' w = (not $ collidePointFireVision p p' $ wallsAlongLine p p' w)
&& smokeLOS p p' w
canSeeFireVision :: Int -> Int -> World -> Bool
canSeeFireVision i j w = (not $ collidePointFireVision ipos jpos $ wallsAlongLine ipos jpos w)
&& smokeLOS ipos jpos w
where ipos = _crPos (_creatures w IM.! i)
jpos = _crPos (_creatures w IM.! j)
canSeeFireVisionAny :: Int -> Int -> World -> Bool
canSeeFireVisionAny i j w = (not $ and $ fmap ($ (wallsAlongLine (_crPos icr) (_crPos jcr) w) )
canSeeFireVisionAny i j w = not $ and $ fmap ($ (wallsAlongLine (_crPos icr) (_crPos jcr) w) )
$ zipWith collidePointFireVision ips jps
) && smokeLOS (_crPos icr) (_crPos jcr) w
where icr = _creatures w IM.! i
jcr = _creatures w IM.! j
ips = map (\p -> (_crPos icr +.+ _crRad icr *.* p)) [(1,0),(0,1),(-1,0),(0,-1)]
@@ -154,9 +145,8 @@ canSeeFireVisionAny i j w = (not $ and $ fmap ($ (wallsAlongLine (_crPos icr) (_
canSeeFireVisionAll :: Int -> Int -> World -> Bool
canSeeFireVisionAll i j w = (not $ or $ fmap ($ (wallsAlongLine (_crPos icr) (_crPos jcr) w) )
canSeeFireVisionAll i j w = not $ or $ fmap ($ (wallsAlongLine (_crPos icr) (_crPos jcr) w) )
$ zipWith collidePointFireVision ips jps
) && smokeLOS (_crPos icr) (_crPos jcr) w
where icr = _creatures w IM.! i
jcr = _creatures w IM.! j
ips = map (\p -> (_crPos icr +.+ _crRad icr *.* p)) [(1,0),(0,1),(-1,0),(0,-1)]
@@ -424,15 +414,6 @@ collidePointFireVision p1 p2 ws = any ( isJust
Just _ -> not $ _wlIsSeeThrough wl
Nothing -> True
collidePointSmoke :: Point2 -> Point2 -> [Smoke] -> Bool
collidePointSmoke a b = any $ isJust . uncurry (intersectSegSeg' a b) . smokePerpLine a b
smokePerpLine :: Point2 -> Point2 -> Smoke -> (Point2,Point2)
smokePerpLine a b sm = (p +.+ orth, p -.- orth)
where
p = _smPos sm
orth = _smRad sm *.* safeNormalizeV (vNormal (a -.- b))
-- shit this is ugly
lineOfThickness :: Float -> [Point2] -> Picture
lineOfThickness t = pictures . f