Cleanup
This commit is contained in:
@@ -11,7 +11,6 @@ module Dodge.WorldEvent.ThingsHit
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
--import Dodge.Zone.Data
|
||||
import Geometry
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -22,27 +21,25 @@ thingsHit
|
||||
:: Point2 -- ^ Line start point
|
||||
-> Point2 -- ^ Line end point
|
||||
-> World
|
||||
-> [(Point2, Either3 Creature Wall ForceField)]
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
thingsHit sp ep w
|
||||
| sp == ep = []
|
||||
| otherwise = sortOn (dist sp . fst) (crs ++ wls ++ ffs)
|
||||
| otherwise = sortOn (dist sp . fst) (crs ++ wls)
|
||||
where
|
||||
hitCrs = IM.elems
|
||||
$ IM.filter (\cr -> circOnSeg sp ep (_crPos cr) (_crRad cr))
|
||||
$ _creatures w
|
||||
-- $ creaturesAlongLine sp ep w
|
||||
crPs = map (\cr -> ssaTriPoint ep (_crPos cr) sp (_crRad cr)) hitCrs
|
||||
crs = zip crPs (map E3x1 hitCrs)
|
||||
crs = zip crPs (map Left hitCrs)
|
||||
hitWls = wallsOnLine sp ep (IM.unions [f b $ f a $ _znObjects $ _wallsZone w | a<-[x-1,x,x+1]
|
||||
, b<-[y-1,y,y+1]])
|
||||
(x,y) = zoneOfPoint (0.5 *.* (sp +.+ ep))
|
||||
f i m = case IM.lookup i m of
|
||||
Just val -> val
|
||||
_ -> IM.empty
|
||||
wls = zip (map (fromJust . hitPoint) hitWls) (map E3x2 hitWls)
|
||||
wls = zip (map (fromJust . hitPoint) hitWls) (map Right hitWls)
|
||||
hitPoint w' = uncurry (intersectSegSeg sp ep) (_wlLine w')
|
||||
hitFFs = mapMaybe (collidePointFF sp ep (_randGen w)) (IM.elems $ _forceFields w)
|
||||
ffs = map (\(p,(_,i)) -> (p, E3x3 $ _forceFields w IM.! i)) hitFFs
|
||||
{- List objects that appear on a line.
|
||||
Can filter out a creature. -}
|
||||
thingsHitExceptCr
|
||||
@@ -50,11 +47,11 @@ thingsHitExceptCr
|
||||
-> Point2 -- ^ Line start point
|
||||
-> Point2 -- ^ Line end point
|
||||
-> World
|
||||
-> [(Point2, Either3 Creature Wall ForceField)]
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
thingsHitExceptCr Nothing sp ep = thingsHit sp ep
|
||||
thingsHitExceptCr (Just cid) sp ep = filter crNotCid . thingsHit sp ep
|
||||
where
|
||||
crNotCid (_,E3x1 cr) = _crID cr /= cid
|
||||
crNotCid (_,Left cr) = _crID cr /= cid
|
||||
crNotCid _ = True
|
||||
|
||||
thingsHitExceptCrLongLine
|
||||
@@ -62,26 +59,24 @@ thingsHitExceptCrLongLine
|
||||
-> Point2
|
||||
-> Point2
|
||||
-> World
|
||||
-> [(Point2, Either3 Creature Wall ForceField)]
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
thingsHitExceptCrLongLine Nothing sp ep = thingsHitLongLine sp ep
|
||||
thingsHitExceptCrLongLine (Just cid) sp ep = filter crNotCid . thingsHitLongLine sp ep
|
||||
where
|
||||
crNotCid (_,E3x1 cr) = _crID cr /= cid
|
||||
crNotCid (_,Left cr) = _crID cr /= cid
|
||||
crNotCid _ = True
|
||||
|
||||
thingsHitLongLine :: Point2 -> Point2 -> World -> [(Point2, Either3 Creature Wall ForceField)]
|
||||
thingsHitLongLine :: Point2 -> Point2 -> World -> [(Point2, Either Creature Wall)]
|
||||
thingsHitLongLine sp ep w
|
||||
| sp == ep = []
|
||||
| otherwise = sortOn (dist sp . fst) (crs ++ wls ++ ffs)
|
||||
| otherwise = sortOn (dist sp . fst) (crs ++ wls)
|
||||
where
|
||||
crs = zip crPs (map E3x1 hitCrs)
|
||||
crs = zip crPs (map Left hitCrs)
|
||||
hitCrs = IM.elems
|
||||
. IM.filter (\cr -> circOnSeg sp ep (_crPos cr) (_crRad cr))
|
||||
$ _creatures w
|
||||
-- $ creaturesAlongLine sp ep w
|
||||
crPs = map (\cr -> ssaTriPoint ep (_crPos cr) sp (_crRad cr)) hitCrs
|
||||
wls = zip (map (fromJust . hitPoint) hitWls) (map E3x2 hitWls)
|
||||
wls = zip (map (fromJust . hitPoint) hitWls) (map Right hitWls)
|
||||
hitWls = wallsOnLine sp ep $ wallsAlongLine sp ep w
|
||||
hitPoint wl = uncurry (intersectSegSeg sp ep) (_wlLine wl)
|
||||
hitFFs = mapMaybe (collidePointFF sp ep (_randGen w)) (IM.elems $ _forceFields w)
|
||||
ffs = map (\(p,(_,i)) -> (p, E3x3 $ _forceFields w IM.! i)) hitFFs
|
||||
|
||||
Reference in New Issue
Block a user