Check wall collisions when expanding

This commit is contained in:
2021-11-18 21:15:50 +00:00
parent a546d070f0
commit 15f2c419d2
7 changed files with 58 additions and 36 deletions
+19 -15
View File
@@ -8,7 +8,7 @@ module Dodge.Creature.Action
, dropUnselected
, startReloadingWeapon
, blinkAction
, sizeSelf
, maybeSizeSelf
, crAutoReload
, copyItemToFloor
, youDropItem
@@ -17,6 +17,7 @@ module Dodge.Creature.Action
where
import Dodge.Path
import Dodge.Default
import Dodge.WallCreatureCollisions
import Dodge.Creature.Stance.Data
import Dodge.WorldEvent.Shockwave
import Dodge.Data
@@ -199,7 +200,7 @@ blinkShockwave i p = makeShockwaveAt [i] p 60 1 2 cyan
setMinInvSize :: Int -> Creature -> World -> World
setMinInvSize n cr = creatures . ix (_crID cr) . crInv %~ f
where
f inv = IM.unionWith (\x _ -> x) inv $ IM.fromList $ [0..n-1] <&> (, NoItem)
f inv = IM.unionWith const inv $ IM.fromList $ [0..n-1] <&> (, NoItem)
stripNoItems :: Creature -> World -> World
stripNoItems cr = creatures . ix (_crID cr) . crInv %~ IM.mapMaybe f
@@ -269,21 +270,24 @@ pickUpItem cid flit w = case maybeInvSlot of
Nothing -> w'
Just j -> w' & itemPositions . ix j .~ InInv 0 invid
sizeSelf :: Float -> Creature -> World -> World
sizeSelf x cr w = w
& soundMultiFrom [TeleSound 0,TeleSound 1] cpos teleS Nothing
& over distortions (distortionBulge :)
-- & inverseShockwaveAt cpos 40 0 2
& creatures . ix cid %~
( (crRad .~ 10 * x)
. (crMvType . mvSpeed .~ yourDefaultSpeed * x)
. (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x))
)
maybeSizeSelf :: Float -> Creature -> World -> Maybe World
maybeSizeSelf x cr w
| _crPos cr1 == _crPos cr2 = Just $ w
& soundMultiFrom [TeleSound 0,TeleSound 1] cpos teleS Nothing
& over distortions (distortionBulge :)
& creatures . ix cid %~
( (crRad .~ 10 * x)
. (crMvType . mvSpeed .~ yourDefaultSpeed * x)
. (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x))
)
| otherwise = Nothing
where
cr1 = colCrWall w (cr {_crRad = 10* x})
cr2 = colCrWall w cr1
distR = 120
distortionBulge
| _crRad cr < 10 * x
= RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
| otherwise = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 0.1
| _crRad cr < 10*x = raddist 1.9
| otherwise = raddist 0.1
raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR)
cid = _crID cr
cpos = _crPos cr