Move wall destruction
This commit is contained in:
@@ -3,16 +3,12 @@
|
||||
module Dodge.Door (updateDoor) where
|
||||
|
||||
import Data.Foldable
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
import Dodge.Block.Debris
|
||||
import Dodge.Data.World
|
||||
import Dodge.Door.DoorLerp
|
||||
import Dodge.LightSource
|
||||
import Dodge.ShiftPoint
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Wall.Delete
|
||||
import Dodge.Wall.Move
|
||||
import Dodge.WorldBool
|
||||
import Dodge.Zoning.Base
|
||||
@@ -25,7 +21,6 @@ import Shape.Data
|
||||
|
||||
updateDoor :: Door -> World -> (S.Set Int2, World)
|
||||
updateDoor dr w
|
||||
| dr ^. drHP < 1 = destroyDoor dr w
|
||||
| DoorLerp x <- dr ^. drUpdate = doorLerp x dr w
|
||||
| otherwise =
|
||||
( mempty
|
||||
@@ -73,36 +68,3 @@ doorLerp speed dr w = fromMaybe (mempty, domounts (dr ^. drLerp) w) $ do
|
||||
soundContinue (WallSound drid) (fst $ doDoorLerp dr x) slideDoorS (Just 1)
|
||||
| otherwise = id
|
||||
|
||||
destroyDoor :: Door -> World -> (S.Set Int2, World)
|
||||
destroyDoor dr w =
|
||||
( is
|
||||
, w
|
||||
& makeDoorDebris dr
|
||||
& deleteWallIDs wlids
|
||||
& cWorld . lWorld . doors %~ IM.delete (_drID dr)
|
||||
-- & muchWlDustAt awl (0.5 * uncurry (+) (_drPos dr))
|
||||
-- & flip (foldl' (flip $ muchWlDustAt awl)) (map (pos +.+) ps)
|
||||
& stopPushing (dr ^. drPushes)
|
||||
& destroyMounts pa (dr ^. drMounts)
|
||||
)
|
||||
where
|
||||
pa = doDoorLerp dr (dr ^. drLerp)
|
||||
is = foldMap (S.fromList . uncurry (zoneOfSeg peZoneSize)) ps
|
||||
ps = (dr ^. drFootPrint) & each . each %~ shiftPointBy pa
|
||||
wlids = IM.keysSet $ _drFootPrint dr
|
||||
|
||||
destroyMounts :: Point2A -> [MountedObject] -> World -> World
|
||||
destroyMounts pa mos w = foldl' (flip $ destroyMount pa) w mos
|
||||
|
||||
destroyMount :: Point2A -> MountedObject -> World -> World
|
||||
destroyMount pa = \case
|
||||
MountedLight x _ _ -> destroyLSFlashAt $ x & _xy %~ shiftPointBy pa
|
||||
MountedSPic{} -> id -- make debris?
|
||||
|
||||
stopPushing :: Maybe Int -> World -> World
|
||||
stopPushing mdrid w = fromMaybe w $ do
|
||||
drid <- mdrid
|
||||
dr <- w ^? cWorld . lWorld . doors . ix drid
|
||||
return $
|
||||
w & cWorld . lWorld . doors . ix drid . drUpdate .~ DoorDoNothing
|
||||
& stopPushing (_drPushes dr)
|
||||
|
||||
Reference in New Issue
Block a user