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 #-}
|
||||
circOnSomeWall p rad =
|
||||
any (uncurry (circOnSeg p rad) . _wlLine)
|
||||
. wlsNearPoint p
|
||||
. wlsNearCirc p rad
|
||||
|
||||
circOnAnyCr :: Point2 -> Float -> World -> Bool
|
||||
{-# INLINE circOnAnyCr #-}
|
||||
|
||||
@@ -223,7 +223,7 @@ drawPathBetween u = concat $ do
|
||||
drawWallsNearYou :: World -> Picture
|
||||
drawWallsNearYou w = concat $ do
|
||||
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
|
||||
f wl = color violet $ thickLine 3 [a, b]
|
||||
<> 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
|
||||
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 c1 c2
|
||||
|
||||
@@ -218,9 +218,10 @@ rotateToOverlappingWall w =
|
||||
maybe
|
||||
id
|
||||
(doWallRotate . snd)
|
||||
(overlapCircWallsClosest p (crRad (cr ^. crType) + 10) (filter _wlRotateTo $ wlsNearPoint p w))
|
||||
(overlapCircWallsClosest p r (filter _wlRotateTo $ wlsNearCirc p r w))
|
||||
w
|
||||
where
|
||||
r = (crRad (cr ^. crType) + 10)
|
||||
cr = you w
|
||||
p = you w ^. crPos . _xy
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import LensHelp
|
||||
import Linear
|
||||
|
||||
cloudPoisonDamage :: Gas -> World -> World
|
||||
-- should probably use crsNearCirc
|
||||
cloudPoisonDamage c w = foldl' (flip doDam) w (filter f $ crsNearPoint clpos w)
|
||||
where
|
||||
doDam cr =
|
||||
|
||||
@@ -90,7 +90,7 @@ crOnWall :: Creature -> World -> Bool
|
||||
crOnWall cr =
|
||||
any (uncurry (circOnSeg p r) . _wlLine)
|
||||
. filter notff
|
||||
. wlsNearPoint p
|
||||
. wlsNearCirc p r
|
||||
where
|
||||
notff x = x ^. wlMaterial /= ForceField
|
||||
p = cr ^. crPos . _xy
|
||||
|
||||
@@ -25,7 +25,7 @@ import qualified IntMapHelp as IM
|
||||
|
||||
zoneOfCirc :: Float -> Point2 -> Float -> [Int2]
|
||||
{-# 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]
|
||||
{-# INLINE zoneOfRect #-}
|
||||
|
||||
@@ -31,7 +31,7 @@ crixsNearSeg :: Point2 -> Point2 -> World -> IS.IntSet
|
||||
crixsNearSeg = nearSeg crZoneSize _crZoning
|
||||
|
||||
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 p r w = mapMaybe (\cid -> w ^? cWorld . lWorld . creatures . ix cid) . IS.toList
|
||||
|
||||
Reference in New Issue
Block a user