Use circles instead of points for zome wall zones
This commit is contained in:
@@ -287,7 +287,7 @@ circOnSomeWall :: Point2 -> Float -> World -> Bool
|
|||||||
{-# INLINE circOnSomeWall #-}
|
{-# INLINE circOnSomeWall #-}
|
||||||
circOnSomeWall p rad =
|
circOnSomeWall p rad =
|
||||||
any (uncurry (circOnSeg p rad) . _wlLine)
|
any (uncurry (circOnSeg p rad) . _wlLine)
|
||||||
. wlsNearPoint p
|
. wlsNearCirc p rad
|
||||||
|
|
||||||
circOnAnyCr :: Point2 -> Float -> World -> Bool
|
circOnAnyCr :: Point2 -> Float -> World -> Bool
|
||||||
{-# INLINE circOnAnyCr #-}
|
{-# INLINE circOnAnyCr #-}
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ drawPathBetween u = concat $ do
|
|||||||
drawWallsNearYou :: World -> Picture
|
drawWallsNearYou :: World -> Picture
|
||||||
drawWallsNearYou w = concat $ do
|
drawWallsNearYou w = concat $ do
|
||||||
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||||
return $ setLayer DebugLayer $ foldMap f $ wlsNearPoint p w
|
return $ setLayer DebugLayer $ foldMap f $ wlsNearCirc p 30 w
|
||||||
where
|
where
|
||||||
f wl = color violet $ thickLine 3 [a, b]
|
f wl = color violet $ thickLine 3 [a, b]
|
||||||
<> uncurryV translate (0.5 *^ (a + b)) (scale 0.05 0.05 . text $ show (_wlID wl))
|
<> uncurryV translate (0.5 *^ (a + b)) (scale 0.05 0.05 . text $ show (_wlID wl))
|
||||||
|
|||||||
+3
-1
@@ -912,7 +912,9 @@ simpleCrSprings w =
|
|||||||
|
|
||||||
-- note that this may in rare cases not push creatures away from each other
|
-- note that this may in rare cases not push creatures away from each other
|
||||||
crSpring :: Creature -> World -> World
|
crSpring :: Creature -> World -> World
|
||||||
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w
|
--crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearPoint (c ^. crPos . _xy) w
|
||||||
|
crSpring c w = foldl' (flip $ crCrSpring c) w $ crsNearCirc (c ^. crPos . _xy)
|
||||||
|
(crRad $ c ^. crType) w
|
||||||
|
|
||||||
crCrSpring :: Creature -> Creature -> World -> World
|
crCrSpring :: Creature -> Creature -> World -> World
|
||||||
crCrSpring c1 c2
|
crCrSpring c1 c2
|
||||||
|
|||||||
@@ -218,9 +218,10 @@ rotateToOverlappingWall w =
|
|||||||
maybe
|
maybe
|
||||||
id
|
id
|
||||||
(doWallRotate . snd)
|
(doWallRotate . snd)
|
||||||
(overlapCircWallsClosest p (crRad (cr ^. crType) + 10) (filter _wlRotateTo $ wlsNearPoint p w))
|
(overlapCircWallsClosest p r (filter _wlRotateTo $ wlsNearCirc p r w))
|
||||||
w
|
w
|
||||||
where
|
where
|
||||||
|
r = (crRad (cr ^. crType) + 10)
|
||||||
cr = you w
|
cr = you w
|
||||||
p = you w ^. crPos . _xy
|
p = you w ^. crPos . _xy
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import LensHelp
|
|||||||
import Linear
|
import Linear
|
||||||
|
|
||||||
cloudPoisonDamage :: Gas -> World -> World
|
cloudPoisonDamage :: Gas -> World -> World
|
||||||
|
-- should probably use crsNearCirc
|
||||||
cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w)
|
cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w)
|
||||||
where
|
where
|
||||||
doDam cr =
|
doDam cr =
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ crOnWall :: Creature -> World -> Bool
|
|||||||
crOnWall cr =
|
crOnWall cr =
|
||||||
any (uncurry (circOnSeg p r) . _wlLine)
|
any (uncurry (circOnSeg p r) . _wlLine)
|
||||||
. filter notff
|
. filter notff
|
||||||
. wlsNearPoint p
|
. wlsNearCirc p r
|
||||||
where
|
where
|
||||||
notff x = x ^. wlMaterial /= ForceField
|
notff x = x ^. wlMaterial /= ForceField
|
||||||
p = cr ^. crPos . _xy
|
p = cr ^. crPos . _xy
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import qualified IntMapHelp as IM
|
|||||||
|
|
||||||
zoneOfCirc :: Float -> Point2 -> Float -> [Int2]
|
zoneOfCirc :: Float -> Point2 -> Float -> [Int2]
|
||||||
{-# INLINE zoneOfCirc #-}
|
{-# INLINE zoneOfCirc #-}
|
||||||
zoneOfCirc zsize p r = zoneOfRect zsize (p +.+ V2 r r) (p -.- V2 r r)
|
zoneOfCirc zsize p r = zoneOfRect zsize (p + V2 r r) (p - V2 r r)
|
||||||
|
|
||||||
zoneOfRect :: Float -> Point2 -> Point2 -> [Int2]
|
zoneOfRect :: Float -> Point2 -> Point2 -> [Int2]
|
||||||
{-# INLINE zoneOfRect #-}
|
{-# INLINE zoneOfRect #-}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ crixsNearSeg :: Point2 -> Point2 -> World -> IS.IntSet
|
|||||||
crixsNearSeg = nearSeg crZoneSize _crZoning
|
crixsNearSeg = nearSeg crZoneSize _crZoning
|
||||||
|
|
||||||
crIXsNearCirc :: Point2 -> Float -> World -> IS.IntSet
|
crIXsNearCirc :: Point2 -> Float -> World -> IS.IntSet
|
||||||
crIXsNearCirc p r = crsNearRect (p +.+ V2 r r) (p -.- V2 r r)
|
crIXsNearCirc p r = crsNearRect (p + V2 r r) (p - V2 r r)
|
||||||
|
|
||||||
crsNearCirc :: Point2 -> Float -> World -> [Creature]
|
crsNearCirc :: Point2 -> Float -> World -> [Creature]
|
||||||
crsNearCirc p r w = mapMaybe (\cid -> w ^? cWorld . lWorld . creatures . ix cid) . IS.toList
|
crsNearCirc p r w = mapMaybe (\cid -> w ^? cWorld . lWorld . creatures . ix cid) . IS.toList
|
||||||
|
|||||||
Reference in New Issue
Block a user