Remove more (dead) Streaming code
This commit is contained in:
@@ -13,17 +13,12 @@
|
|||||||
-}
|
-}
|
||||||
module Dodge.Base.Collide (
|
module Dodge.Base.Collide (
|
||||||
collidePoint,
|
collidePoint,
|
||||||
collideSegCrs,
|
collidePointWallsFilter,
|
||||||
collidePointWallsFilterStream,
|
|
||||||
collidePointTestFilter,
|
collidePointTestFilter,
|
||||||
overlapSegWalls,
|
overlapSegWalls,
|
||||||
overlapSegCrs,
|
overlapSegCrs,
|
||||||
overlap1SegCrs,
|
|
||||||
bounceBall,
|
bounceBall,
|
||||||
bouncePoint,
|
bouncePoint,
|
||||||
sortStreamOn,
|
|
||||||
minStreamOn,
|
|
||||||
collideCircWallsStream,
|
|
||||||
circOnSomeWall,
|
circOnSomeWall,
|
||||||
circOnAnyCr,
|
circOnAnyCr,
|
||||||
overlapCircWalls,
|
overlapCircWalls,
|
||||||
@@ -49,16 +44,6 @@ import Dodge.Zoning
|
|||||||
import FoldableHelp
|
import FoldableHelp
|
||||||
import Geometry
|
import Geometry
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import qualified Streaming.Prelude as S
|
|
||||||
import StreamingHelp
|
|
||||||
|
|
||||||
--collidePoint :: Point2 -> Point2
|
|
||||||
-- -> StreamOf Wall
|
|
||||||
-- -> (Point2, Maybe Wall)
|
|
||||||
--{-# INLINE collidePoint #-}
|
|
||||||
--collidePoint sp ep = runIdentity . S.fold_ findPoint (ep, Nothing) id
|
|
||||||
-- where
|
|
||||||
-- findPoint (p,mwl) wl = maybe (p,mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
|
|
||||||
|
|
||||||
collidePoint ::
|
collidePoint ::
|
||||||
Point2 ->
|
Point2 ->
|
||||||
@@ -70,39 +55,15 @@ collidePoint sp ep = foldl' findPoint (ep, Nothing)
|
|||||||
where
|
where
|
||||||
findPoint (p, mwl) wl = maybe (p, mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
|
findPoint (p, mwl) wl = maybe (p, mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
|
||||||
|
|
||||||
overlap1SegCrs ::
|
overlapSegCrs ::
|
||||||
Point2 ->
|
Point2 ->
|
||||||
Point2 ->
|
Point2 ->
|
||||||
[Creature] ->
|
[Creature] ->
|
||||||
[(Point2, Creature)]
|
[(Point2, Creature)]
|
||||||
{-# INLINE overlap1SegCrs #-}
|
|
||||||
overlap1SegCrs sp ep =
|
|
||||||
mapMaybe
|
|
||||||
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep))
|
|
||||||
|
|
||||||
overlapSegCrs ::
|
|
||||||
Point2 ->
|
|
||||||
Point2 ->
|
|
||||||
StreamOf Creature ->
|
|
||||||
StreamOf ([Point2], Creature)
|
|
||||||
{-# INLINE overlapSegCrs #-}
|
{-# INLINE overlapSegCrs #-}
|
||||||
overlapSegCrs sp ep =
|
overlapSegCrs sp ep =
|
||||||
S.mapMaybe
|
mapMaybe
|
||||||
(\cr -> f cr $ intersectCircSeg (_crPos cr) (_crRad cr) sp ep)
|
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep))
|
||||||
where
|
|
||||||
f _ [] = Nothing
|
|
||||||
f cr ps = Just (ps, cr)
|
|
||||||
|
|
||||||
collideSegCrs ::
|
|
||||||
Point2 ->
|
|
||||||
Point2 ->
|
|
||||||
StreamOf Creature ->
|
|
||||||
(Point2, Maybe Creature)
|
|
||||||
{-# INLINE collideSegCrs #-}
|
|
||||||
collideSegCrs sp ep = runIdentity . S.fold_ findPoint (ep, Nothing) id
|
|
||||||
where
|
|
||||||
findPoint (p, mcr) cr =
|
|
||||||
maybe (p, mcr) (,Just cr) $ listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp p)
|
|
||||||
|
|
||||||
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
|
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
|
||||||
{-# INLINE doBounce #-}
|
{-# INLINE doBounce #-}
|
||||||
@@ -124,7 +85,7 @@ bounceBall x sp ep r = doBounce x sp ep . collideCircWalls sp ep r
|
|||||||
|
|
||||||
bouncePoint :: (Wall -> Bool) -> Float -> Point2 -> Point2 -> World -> Maybe (Point2, Point2)
|
bouncePoint :: (Wall -> Bool) -> Float -> Point2 -> Point2 -> World -> Maybe (Point2, Point2)
|
||||||
{-# INLINE bouncePoint #-}
|
{-# INLINE bouncePoint #-}
|
||||||
bouncePoint t x sp ep = doBounce x sp ep . collidePointWallsFilterStream t sp ep
|
bouncePoint t x sp ep = doBounce x sp ep . collidePointWallsFilter t sp ep
|
||||||
|
|
||||||
-- this COULD be written in terms of collidePointWallsFilterStream, TODO test
|
-- this COULD be written in terms of collidePointWallsFilterStream, TODO test
|
||||||
-- whether this is actually faster
|
-- whether this is actually faster
|
||||||
@@ -142,9 +103,9 @@ collidePointTestFilter t sp ep =
|
|||||||
-- . S.any_ (isJust . uncurry (intersectSegSeg sp ep) . _wlLine)
|
-- . S.any_ (isJust . uncurry (intersectSegSeg sp ep) . _wlLine)
|
||||||
-- . S.filter t
|
-- . S.filter t
|
||||||
|
|
||||||
collidePointWallsFilterStream :: (Wall -> Bool) -> Point2 -> Point2 -> World -> (Point2, Maybe Wall)
|
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> World -> (Point2, Maybe Wall)
|
||||||
{-# INLINE collidePointWallsFilterStream #-}
|
{-# INLINE collidePointWallsFilter #-}
|
||||||
collidePointWallsFilterStream t sp ep =
|
collidePointWallsFilter t sp ep =
|
||||||
collidePoint sp ep
|
collidePoint sp ep
|
||||||
. filter t
|
. filter t
|
||||||
. wlsNearSeg sp ep
|
. wlsNearSeg sp ep
|
||||||
@@ -225,31 +186,6 @@ collideCircWalls sp ep rad = foldl' findPoint (ep, Nothing)
|
|||||||
where
|
where
|
||||||
f = (+.+) (rad *.* normalizeV (vNormal $ a -.- b))
|
f = (+.+) (rad *.* normalizeV (vNormal $ a -.- b))
|
||||||
|
|
||||||
-- | note that this does not push the circle away from the wall at all
|
|
||||||
collideCircWallsStream ::
|
|
||||||
Point2 ->
|
|
||||||
Point2 ->
|
|
||||||
Float ->
|
|
||||||
StreamOf Wall ->
|
|
||||||
(Point2, Maybe Wall)
|
|
||||||
{-# INLINE collideCircWallsStream #-}
|
|
||||||
collideCircWallsStream sp ep rad = runIdentity . S.fold_ findPoint (ep, Nothing) id
|
|
||||||
where
|
|
||||||
findPoint (p, mwl) wl =
|
|
||||||
maybe (p, mwl) (,Just wl) . uncurry (intersectSegSeg sp p)
|
|
||||||
. shiftbyrad
|
|
||||||
. _wlLine
|
|
||||||
$ wl
|
|
||||||
shiftbyrad (a, b) =
|
|
||||||
bimap
|
|
||||||
f
|
|
||||||
f
|
|
||||||
( a +.+ rad *.* normalizeV (a -.- b)
|
|
||||||
, b +.+ rad *.* normalizeV (b -.- a)
|
|
||||||
)
|
|
||||||
where
|
|
||||||
f = (+.+) (rad *.* normalizeV (vNormal $ a -.- b))
|
|
||||||
|
|
||||||
overlapCircWallsClosest :: Point2 -> Float -> [Wall] -> Maybe (Point2, Wall)
|
overlapCircWallsClosest :: Point2 -> Float -> [Wall] -> Maybe (Point2, Wall)
|
||||||
{-# INLINE overlapCircWallsClosest #-}
|
{-# INLINE overlapCircWallsClosest #-}
|
||||||
overlapCircWallsClosest p r =
|
overlapCircWallsClosest p r =
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import Geometry
|
|||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import qualified ListHelp as List
|
import qualified ListHelp as List
|
||||||
import StreamingHelp
|
import Data.Bifunctor
|
||||||
|
|
||||||
updateBullet :: World -> Bullet -> (World, Maybe Bullet)
|
updateBullet :: World -> Bullet -> (World, Maybe Bullet)
|
||||||
updateBullet w bu = case _buDelayFraction bu of
|
updateBullet w bu = case _buDelayFraction bu of
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ unsafeBlinkAction cr w
|
|||||||
.:~ Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
|
.:~ Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
|
||||||
where
|
where
|
||||||
success = fromMaybe True $ do
|
success = fromMaybe True $ do
|
||||||
wl <- snd $ collidePointWallsFilterStream (const True) mwp cpos w
|
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
||||||
return (isLHS mwp `uncurry` _wlLine wl)
|
return (isLHS mwp `uncurry` _wlLine wl)
|
||||||
distR = 120
|
distR = 120
|
||||||
distortionBulge =
|
distortionBulge =
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import Dodge.Data.SoundOrigin
|
|||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import SDL (MouseButton, Scancode)
|
import SDL (MouseButton, Scancode)
|
||||||
import Sound.Data
|
import Sound.Data
|
||||||
import StreamingHelp
|
|
||||||
import System.Random
|
import System.Random
|
||||||
|
|
||||||
data World = World
|
data World = World
|
||||||
@@ -59,10 +58,4 @@ data WorldHammer
|
|||||||
| DoubleMouseHam
|
| DoubleMouseHam
|
||||||
deriving (Eq, Ord, Show, Read, Enum, Bounded)
|
deriving (Eq, Ord, Show, Read, Enum, Bounded)
|
||||||
|
|
||||||
type HitEffect' =
|
|
||||||
Flame ->
|
|
||||||
StreamOf (Point2, Either Creature Wall) ->
|
|
||||||
World ->
|
|
||||||
(World, Maybe Flame)
|
|
||||||
|
|
||||||
makeLenses ''World
|
makeLenses ''World
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Dodge.Data.Zoning where
|
module Dodge.Data.Zoning
|
||||||
|
where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ aTractorBeam _ cr w = w & cWorld . tractorBeams .:~ tractorBeamAt spos outpos di
|
|||||||
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
|
||||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
outpos = fst $ collidePointWallsFilterStream (const True) cpos xpos w
|
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
||||||
power = _attractionPower . _itParams $ _crInv cr IM.! crSel cr
|
power = _attractionPower . _itParams $ _crInv cr IM.! crSel cr
|
||||||
|
|
||||||
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ shootShatter :: Item -> Creature -> World -> World
|
|||||||
shootShatter it cr w =
|
shootShatter it cr w =
|
||||||
maybe w (uncurry $ shatterWall w sp ep) $
|
maybe w (uncurry $ shatterWall w sp ep) $
|
||||||
sequence $
|
sequence $
|
||||||
collidePointWallsFilterStream canshatter sp ep w
|
collidePointWallsFilter canshatter sp ep w
|
||||||
where
|
where
|
||||||
canshatter wl = case _wlOpacity wl of
|
canshatter wl = case _wlOpacity wl of
|
||||||
Opaque -> True
|
Opaque -> True
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
module Dodge.LoadSeed
|
module Dodge.LoadSeed where
|
||||||
where
|
|
||||||
|
import Data.Functor
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Text.Read
|
import Text.Read
|
||||||
|
|
||||||
loadSeed :: IO (Maybe Int)
|
loadSeed :: IO (Maybe Int)
|
||||||
loadSeed = maybeReadFile "saveSlot/seed" >>= (return . (>>= readMaybe))
|
loadSeed = maybeReadFile "saveSlot/seed" <&> (>>= readMaybe)
|
||||||
|
|
||||||
maybeReadFile :: String -> IO (Maybe String)
|
maybeReadFile :: String -> IO (Maybe String)
|
||||||
maybeReadFile fpath = do
|
maybeReadFile fpath = do
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ defaultArcStep itparams w (ArcStep p dir _) = do
|
|||||||
mwl =
|
mwl =
|
||||||
listToMaybe
|
listToMaybe
|
||||||
. sortOn (dist p . fst)
|
. sortOn (dist p . fst)
|
||||||
. mapMaybe (\q -> sequence $ collidePointWallsFilterStream (const True) p (center +.+ q) w)
|
. mapMaybe (\q -> sequence $ collidePointWallsFilter (const True) p (center +.+ q) w)
|
||||||
-- collidePointWallsWall and wlsnearpoint
|
-- collidePointWallsWall and wlsnearpoint
|
||||||
$ polyCirc 6 csize
|
$ polyCirc 6 csize
|
||||||
f (q, wl) = ArcStep q dir (WlID $ _wlID wl)
|
f (q, wl) = ArcStep q dir (WlID $ _wlID wl)
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ getViewpoints p w =
|
|||||||
gameRoomViewpoints :: Point2 -> GameRoom -> [Point2]
|
gameRoomViewpoints :: Point2 -> GameRoom -> [Point2]
|
||||||
{-# INLINE gameRoomViewpoints #-}
|
{-# INLINE gameRoomViewpoints #-}
|
||||||
gameRoomViewpoints p gr =
|
gameRoomViewpoints p gr =
|
||||||
(_grViewpoints gr)
|
_grViewpoints gr
|
||||||
<> map extend ((_grViewpointsEx gr) <> map addDir (_grLinkDirs gr))
|
<> map extend (_grViewpointsEx gr <> map addDir (_grLinkDirs gr))
|
||||||
where
|
where
|
||||||
extend outp = p +.+ maxViewDistance *.* squashNormalizeV (outp -.- p)
|
extend outp = p +.+ maxViewDistance *.* squashNormalizeV (outp -.- p)
|
||||||
addDir a = p +.+ unitVectorAtAngle a
|
addDir a = p +.+ unitVectorAtAngle a
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ crsHit sp ep w
|
|||||||
| sp == ep = mempty
|
| sp == ep = mempty
|
||||||
| otherwise =
|
| otherwise =
|
||||||
sortOn (dist sp . fst)
|
sortOn (dist sp . fst)
|
||||||
. overlap1SegCrs sp ep
|
. overlapSegCrs sp ep
|
||||||
. mapMaybe (\cid -> w ^? cWorld . creatures . ix cid)
|
. mapMaybe (\cid -> w ^? cWorld . creatures . ix cid)
|
||||||
. IS.toList
|
. IS.toList
|
||||||
. crixsNearSeg sp ep
|
. crixsNearSeg sp ep
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Dodge.Zone.Update (
|
module Dodge.Zone.Update (
|
||||||
updateZoning,
|
--updateZoning,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Data.Zoning
|
import Dodge.Data.Zoning
|
||||||
|
|||||||
Reference in New Issue
Block a user