diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index debee1ee3..9f0fafc79 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -957,6 +957,7 @@ data Machine = Machine { _mcID :: Int , _mcWallIDs :: IS.IntSet , _mcUpdate :: Machine -> World -> World + , _mcDeath :: Machine -> World -> World , _mcDraw :: Machine -> SPic , _mcPos :: Point2 , _mcDir :: Float diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 24a706d8e..d90c928da 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -208,6 +208,7 @@ defaultMachine = Machine { _mcID = 0 , _mcWallIDs = mempty , _mcUpdate = defaultMachineUpdate + , _mcDeath = \_ -> id , _mcDraw = const mempty , _mcPos = V2 0 0 , _mcDir = 0 diff --git a/src/Dodge/Floor.hs b/src/Dodge/Floor.hs index 238929304..3e1cc750a 100644 --- a/src/Dodge/Floor.hs +++ b/src/Dodge/Floor.hs @@ -42,6 +42,7 @@ import System.Random initialAnoTree :: Tree [Annotation] initialAnoTree = padSucWithDoors $ treeFromPost [[AnoApplyInt 0 startRoom] + , [PassthroughLockKeyLists 2 keyCardRunPastRand itemRooms] , [SpecificRoom $ warningRooms 7] , [SpecificRoom $ return (return . UseAll $ roomRectAutoLinks 400 400 & rmPmnts .++~ [spNoID anyUnusedSpot (PutCrit invisibleChaseCrit) diff --git a/src/Dodge/LockAndKey.hs b/src/Dodge/LockAndKey.hs index e089fe050..852a6cfe4 100644 --- a/src/Dodge/LockAndKey.hs +++ b/src/Dodge/LockAndKey.hs @@ -32,6 +32,10 @@ lockRoomKeyItems = ,(const $ lasTunnelRunPast 400, takeOne [FLATSHIELD,FORCEFIELDGUN]) ,(keyCardRoomRunPast 0, return (KEYCARD 0)) ] +keyCardRunPastRand :: RandomGen g => [ (Int -> State g (LabSubCompTree Room) , State g CombineType ) ] +keyCardRunPastRand = + [(keyCardRoomRunPast 0, return (KEYCARD 0)) + ] itemRooms :: RandomGen g => [(CombineType, State g (LabSubCompTree Room))] itemRooms = diff --git a/src/Dodge/Placement/Instance/Terminal.hs b/src/Dodge/Placement/Instance/Terminal.hs index 97937d235..f3ce29533 100644 --- a/src/Dodge/Placement/Instance/Terminal.hs +++ b/src/Dodge/Placement/Instance/Terminal.hs @@ -5,6 +5,7 @@ module Dodge.Placement.Instance.Terminal , simpleTermMessage , genTermMessage , topFlushStrings + , terminalColor ) where import Dodge.Data import Dodge.LevelGen.Data @@ -35,14 +36,14 @@ putTerminal' col mcf = ps0PushPS (PutButton termButton) }) $ const Nothing -putTerminal :: (World -> TerminalParams) -> Placement -putTerminal f = ps0PushPSw PutNothing $ \_ _ -> Just $ +putTerminal :: Color -> (World -> TerminalParams) -> Placement +putTerminal col f = ps0PushPSw PutNothing $ \_ _ -> Just $ ps0PushPS (PutButton $ termButton & btTerminalParams .~ f) - $ \pl -> Just $ pt0 (PutMachine terminalColor (reverse $ square 10) defaultMachine - { _mcDraw = noPic . terminalShape terminalColor + $ \pl -> Just $ pt0 (PutMachine col (reverse $ square 10) defaultMachine + { _mcDraw = noPic . terminalShape col , _mcHP = 100 - , _mcUpdate = machineAddSound fridgeHumS - $ machineUpdateDeathEff $ \mc -> (buttons . at (fromJust (_plMID pl)) .~ Nothing) + , _mcUpdate = machineAddSound fridgeHumS (\_ -> id) + , _mcDeath = \mc -> (buttons . at (fromJust (_plMID pl)) .~ Nothing) . makeExplosionAt (_mcPos mc) }) $ const Nothing diff --git a/src/Dodge/Room/LongDoor.hs b/src/Dodge/Room/LongDoor.hs index c74691f6e..7d66627c0 100644 --- a/src/Dodge/Room/LongDoor.hs +++ b/src/Dodge/Room/LongDoor.hs @@ -96,7 +96,7 @@ addButtonSlowDoor x h rm = do & rmPmnts .++~ [butDoor , theterminal] & rmBound .:~ openDoorBound where - theterminal = putTerminal (simpleTermMessage themessage) + theterminal = putTerminal terminalColor (simpleTermMessage themessage) & plSpot .~ rprBoolShift (isUnusedLnkType InLink) (shiftByV2 (V2 0 (-10))) themessage = ["WARNING:" diff --git a/src/Dodge/Room/SensorDoor.hs b/src/Dodge/Room/SensorDoor.hs index fbec68908..ded6b270e 100644 --- a/src/Dodge/Room/SensorDoor.hs +++ b/src/Dodge/Room/SensorDoor.hs @@ -83,7 +83,7 @@ sensInsideDoor senseType outplid rm = rm thinHighBar 0 (V2 20 (-1)) (V2 20 (-100)) <> thinHighBar 0 (V2 0 (-100)) (V2 20 (-100)) <> barPP 1.5 (V3 20 (-1) 0) (V3 20 (-1) 80)) - , putTerminal (const $ defaultTermParams & addInputLine [damageCodeCommand,quitCommand] + , putTerminal terminalColor (const $ defaultTermParams & addInputLine [damageCodeCommand,quitCommand] [helpCommand,commandsCommand] ) & plSpot .~ rprBoolShift isUnusedLnk (shiftInBy 10) diff --git a/src/Dodge/Room/Warning.hs b/src/Dodge/Room/Warning.hs index ae932d171..ee37395a8 100644 --- a/src/Dodge/Room/Warning.hs +++ b/src/Dodge/Room/Warning.hs @@ -52,7 +52,7 @@ addWarningTerminal outplid = (rmName .++~ "warningTerm-") where outplace = extTrigLitPos (atFstLnkOutShiftBy (\(p,a) -> (p +.+ rotateV a (V2 18.5 (-2.5)), a))) - (Just . set plSpot (rprShift moveToSideFirstOutLink) . putTerminal . termMessages) + (Just . set plSpot (rprShift moveToSideFirstOutLink) . putTerminal terminalColor . termMessages) termMessages trid _ = defaultTermParams & addInputLine [unlockCommand trid,quitCommand] [helpCommand,infoCommand theinfo,commandsCommand] diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 261fbc575..e97a306f9 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -8,6 +8,7 @@ import Dodge.Menu import Dodge.Block import Dodge.Distortion import Dodge.SoundLogic +import Dodge.Wall.Delete --import Dodge.Menu import Dodge.Base import Dodge.Zone @@ -71,7 +72,7 @@ functionalUpdate cfig w = checkEndGame . updateGusts . zoneClouds . updateMIM magnets _mgUpdate - . updateIMl _machines _mcUpdate + . updateIMl _machines mcChooseUpdate . updateIMl _creatures _crUpdate -- creatures should be updated early so that crOldPos is set before any position change . over creatures (fmap setOldPos) @@ -89,6 +90,13 @@ functionalUpdate cfig w = checkEndGame where (x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl +mcChooseUpdate :: Machine -> Machine -> World -> World +mcChooseUpdate mc mc' + | _mcHP mc > 0 = _mcUpdate mc mc' + | otherwise = (machines %~ IM.delete (_mcID mc)) + . deleteWallIDs (_mcWallIDs mc) + . _mcDeath mc mc' + setOldPos :: Creature -> Creature setOldPos cr = cr & crOldPos .~ _crPos cr