Cleanup, split CWorld into separate file

This commit is contained in:
2022-07-26 21:19:12 +01:00
parent c2707719fb
commit 6554d219dc
27 changed files with 1049 additions and 911 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ updateRenderSplit u = do
playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound) playSoundUnlessRewinding :: Universe -> IO (M.Map SoundOrigin Sound)
playSoundUnlessRewinding u playSoundUnlessRewinding u
| _timeFlow (_cWorld w) == RewindingNow = return M.empty | _timeFlow w == RewindingNow = return M.empty
| otherwise = playSoundAndUpdate (_soundData $ _preloadData u) (_playingSounds w) (_toPlaySounds w) | otherwise = playSoundAndUpdate (_soundData $ _preloadData u) (_playingSounds w) (_toPlaySounds w)
where where
w = _uvWorld u w = _uvWorld u
+3 -3
View File
@@ -8,7 +8,7 @@ import Control.Lens
doButtonEvent :: ButtonEvent -> Button -> World -> World doButtonEvent :: ButtonEvent -> Button -> World -> World
doButtonEvent be = case be of doButtonEvent be = case be of
ButtonDoNothing -> const id ButtonDoNothing -> const id
ButtonPress newstate newevent thesound f -> \b -> doWorldEffect f ButtonPress newstate newevent thesound f -> \b -> doWdWd f
. set (cWorld . buttons . ix (_btID b) . btState) newstate . set (cWorld . buttons . ix (_btID b) . btState) newstate
. set (cWorld . buttons . ix (_btID b) . btEvent) newevent . set (cWorld . buttons . ix (_btID b) . btEvent) newevent
. soundStart (LeverSound 0) (_btPos b) thesound Nothing . soundStart (LeverSound 0) (_btPos b) thesound Nothing
@@ -18,9 +18,9 @@ doButtonEvent be = case be of
flipSwitch :: WdWd -> WdWd -> Button -> World -> World flipSwitch :: WdWd -> WdWd -> Button -> World -> World
flipSwitch oneff offeff bt flipSwitch oneff offeff bt
| _btState bt == BtOff = doWorldEffect oneff . dosound | _btState bt == BtOff = doWdWd oneff . dosound
. over (cWorld . buttons . ix (_btID bt)) turnon . over (cWorld . buttons . ix (_btID bt)) turnon
| otherwise = doWorldEffect offeff . dosound | otherwise = doWdWd offeff . dosound
. over (cWorld . buttons . ix (_btID bt)) turnoff . over (cWorld . buttons . ix (_btID bt)) turnoff
where where
turnon = (btState .~ BtOn ) . (btText .~ "SWITCH\\") turnon = (btState .~ BtOn ) . (btText .~ "SWITCH\\")
+7 -42
View File
@@ -128,7 +128,6 @@ inventoryX c = case c of
[ blinkGun [ blinkGun
, unsafeBlinkGun , unsafeBlinkGun
, autoDetector WALLDETECTOR , autoDetector WALLDETECTOR
-- , effectGun "GIBBER" addCrGibs
] ]
'E' -> 'E' ->
[ makeTypeCraftNum 3 PIPE [ makeTypeCraftNum 3 PIPE
@@ -176,8 +175,7 @@ inventoryX c = case c of
[ lasGun [ lasGun
, lasGun , lasGun
, dualBeam , dualBeam
, -- , lasWidePulse , makeTypeCraftNum 10 TRANSFORMER
makeTypeCraftNum 10 TRANSFORMER
] ]
'K' -> 'K' ->
[ autoRifle [ autoRifle
@@ -216,27 +214,11 @@ testInventory =
, makeTypeCraft INCENDIARYMODULE , makeTypeCraft INCENDIARYMODULE
, makeTypeCraft STATICMODULE , makeTypeCraft STATICMODULE
, makeTypeCraft CONCUSSMODULE , makeTypeCraft CONCUSSMODULE
, -- , bounceModule , teleportModule
-- , medkit 50 & itConsumption . itAmount .~ 3 , makeTypeCraftNum 10 HARDWARE
teleportModule
, -- , makeTypeCraftNum 1 LIGHTER
-- , makeTypeCraftNum 15 TUBE
-- , makeTypeCraftNum 9 TRANSFORMER
-- , makeTypeCraftNum 5 CREATURESENSOR
-- , makeTypeCraftNum 9 PRISM
-- , makeTypeCraftNum 3 DRUM
-- , makeTypeCraftNum 3 PUMP
-- , makeTypeCraftNum 3 BATTERY
-- , makeTypeCraftNum 1 MAGNET
-- , makeTypeCraftNum 1 TRANSMITTER
makeTypeCraftNum 10 HARDWARE
, makeTypeCraftNum 3 SPRING , makeTypeCraftNum 3 SPRING
, makeTypeCraftNum 10 CAN , makeTypeCraftNum 10 CAN
, -- , makeTypeCraftNum 3 TIN , makeTypeCraftNum 3 PLANK
makeTypeCraftNum 3 PLANK
-- , makeTypeCraftNum 1 MOTOR
-- , makeTypeCraftNum 5 MICROCHIP
-- , makeTypeCraftNum 5 AIUNIT
] ]
stackedInventory :: IM.IntMap Item stackedInventory :: IM.IntMap Item
@@ -244,8 +226,7 @@ stackedInventory =
IM.fromList $ IM.fromList $
zip zip
[0 ..] [0 ..]
[ --sonicGun [ burstRifle
burstRifle
, pipe , pipe
, rewindGun , rewindGun
, tractorGun , tractorGun
@@ -254,28 +235,12 @@ stackedInventory =
, teslaGun , teslaGun
, blinkGun , blinkGun
, miniGunX 3 , miniGunX 3
, -- ,multGun , boosterGun
boosterGun
, remoteLauncher , remoteLauncher
, flatShield , flatShield
, -- ,grenade , spawnGun (lamp 5)
spawnGun (lamp 5)
, lasGun , lasGun
, flameThrower , flameThrower
, poisonSprayer , poisonSprayer
, launcher , launcher
-- ,droneLauncher
--,lasGun
--,grenade
--,ltAutoGun,flamer,multGun,spreadGun,remoteLauncher
--,longGun
--,hvAutoGun
--,teslaGun
--,latchkey 0
--,miniGun
--,medkit 50
--,bezierGun
] ]
--smokeGenGun :: Item
--smokeGenGun = effectGun "smoke" $ const spawnSmokeAtCursor
+169 -161
View File
@@ -1,61 +1,51 @@
--{-# LANGUAGE TupleSections #-} --{-# LANGUAGE TupleSections #-}
{- | Actions performed by creatures within the world
-}
module Dodge.Creature.Action
( performActions
, stripNoItems
, setMinInvSize
, dropUnselected
, dropExcept
, dropItem
-- , startReloadingWeapon
, blinkAction
, blinkActionFail
, unsafeBlinkAction
, sizeSelf
-- , crAutoReload
, copyInvItemToFloor
, youDropItem
, pickUpItem
, pickUpItemID
)
where
import Dodge.FloatFunction
import Dodge.Inventory.Add
import Dodge.CreatureEffect
--import Dodge.ShortShow
import Dodge.Path
import Dodge.Default
import Dodge.WallCreatureCollisions
import Dodge.Creature.Stance.Data
import Dodge.WorldEvent.Shockwave
import Dodge.Data
import Dodge.Base
--import Dodge.Zone
import Dodge.SoundLogic
--import Dodge.WorldEvent
import Dodge.Inventory
import Dodge.FloorItem
--import Dodge.LightSources
import Geometry
import Picture
import qualified IntMapHelp as IM
import LensHelp
--import Control.Monad -- | Actions performed by creatures within the world
--import Control.Applicative module Dodge.Creature.Action (
import Data.Maybe performActions,
stripNoItems,
setMinInvSize,
dropUnselected,
dropExcept,
dropItem,
blinkAction,
blinkActionFail,
unsafeBlinkAction,
sizeSelf,
copyInvItemToFloor,
youDropItem,
pickUpItem,
pickUpItemID,
) where
import Data.Bifunctor import Data.Bifunctor
import Data.List (findIndex) import Data.List (findIndex)
--import qualified Data.Map as M import Data.Maybe
import Dodge.Base
import Dodge.CreatureEffect
import Dodge.Data
import Dodge.Default
import Dodge.FloatFunction
import Dodge.FloorItem
import Dodge.Inventory
import Dodge.Inventory.Add
import Dodge.Path
import Dodge.SoundLogic
import Dodge.WallCreatureCollisions
import Dodge.WorldEvent.Shockwave
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import Picture
performActions :: World -> Creature -> Creature performActions :: World -> Creature -> Creature
performActions w cr = cr performActions w cr =
& crActionPlan . apImpulse .~ concat iss cr
& crActionPlan . apAction .~ catMaybes mayas & crActionPlan . apImpulse .~ concat iss
& crActionPlan . apAction .~ catMaybes mayas
where where
(iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction (iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction
type OutAction = ( [Impulse] , Maybe Action ) type OutAction = ([Impulse], Maybe Action)
performAimAt :: Creature -> World -> Int -> Point2 -> OutAction performAimAt :: Creature -> World -> Int -> Point2 -> OutAction
performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos) performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
@@ -66,22 +56,24 @@ performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
aimSp = case cr ^? crMvType . mvAimSpeed of aimSp = case cr ^? crMvType . mvAimSpeed of
Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos) Just f -> doFloatFloat f $ safeAngleVV (unitVectorAtAngle cdir) (tpos - cpos)
Nothing -> error "creature without aiming type" Nothing -> error "creature without aiming type"
tpos | canSee' = _crPos (_creatures (_cWorld w) IM.! tcid) tpos
| otherwise = p | canSee' = _crPos (_creatures (_cWorld w) IM.! tcid)
| otherwise = p
performPathTo :: Creature -> World -> Point2 -> OutAction performPathTo :: Creature -> World -> Point2 -> OutAction
performPathTo cr w p performPathTo cr w p
| dist cpos p <= _crRad cr = ([], Nothing) | dist cpos p <= _crRad cr = ([], Nothing)
| isWalkable cpos p w = ([MvTurnToward p,MvForward,RandomTurn jit] , Just (PathTo p)) | isWalkable cpos p w = ([MvTurnToward p, MvForward, RandomTurn jit], Just (PathTo p))
| otherwise = case pointTowardsImpulse p cpos w of | otherwise = case pointTowardsImpulse p cpos w of
Just q -> ([MvTurnToward q Just q ->
,MvForward (
,RandomTurn jit [ MvTurnToward q
-- ,ArbitraryImpulseEffect . const , MvForward
-- $ debugPicture .~ drawPathList cpos p w , RandomTurn jit
] ]
, Just (PathTo p)) , Just (PathTo p)
_ -> ([],Nothing) )
_ -> ([], Nothing)
where where
cpos = _crPos cr cpos = _crPos cr
jit = _mvTurnJit $ _crMvType cr jit = _mvTurnJit $ _crMvType cr
@@ -89,7 +81,7 @@ performPathTo cr w p
performTurnToA :: Creature -> Point2 -> OutAction performTurnToA :: Creature -> Point2 -> OutAction
performTurnToA cr p performTurnToA cr p
| angleVV cdirv dirv < 0.1 = ([], Nothing) | angleVV cdirv dirv < 0.1 = ([], Nothing)
| otherwise = ([MvTurnToward p,RandomTurn jit] , Just (TurnToPoint p)) | otherwise = ([MvTurnToward p, RandomTurn jit], Just (TurnToPoint p))
where where
cpos = _crPos cr cpos = _crPos cr
cdirv = unitVectorAtAngle (_crDir cr) cdirv = unitVectorAtAngle (_crDir cr)
@@ -98,29 +90,29 @@ performTurnToA cr p
{- | Performing an action means that a creature has some impulses for a frame, and {- | Performing an action means that a creature has some impulses for a frame, and
updates or deletes the action itself. updates or deletes the action itself.
-- doAction -} -}
performAction :: Creature -> World -> Action -> OutAction performAction :: Creature -> World -> Action -> OutAction
performAction cr w ac = case ac of performAction cr w ac = case ac of
ActionNothing -> ([],Nothing) ActionNothing -> ([], Nothing)
LabelAction str subAc -> second (fmap (LabelAction str)) $ performAction cr w subAc LabelAction str subAc -> second (fmap (LabelAction str)) $ performAction cr w subAc
AimAt tcid p -> performAimAt cr w tcid p AimAt tcid p -> performAimAt cr w tcid p
WaitThen 0 newAc -> ([] , Just newAc) WaitThen 0 newAc -> ([], Just newAc)
WaitThen t newAc -> ([] , Just (WaitThen (t-1) newAc)) WaitThen t newAc -> ([], Just (WaitThen (t -1) newAc))
ImpulsesList (xs:xss) -> (xs, Just $ ImpulsesList xss) ImpulsesList (xs : xss) -> (xs, Just $ ImpulsesList xss)
ImpulsesList _ -> ([], Nothing) ImpulsesList _ -> ([], Nothing)
DoImpulses imps -> (imps, Nothing) DoImpulses imps -> (imps, Nothing)
DoActionThen fsta afta -> case performAction cr w fsta of DoActionThen fsta afta -> case performAction cr w fsta of
(imps , Just nxta) -> (imps, Just (DoActionThen nxta afta)) (imps, Just nxta) -> (imps, Just (DoActionThen nxta afta))
(imps , Nothing ) -> (imps, Just afta) (imps, Nothing) -> (imps, Just afta)
DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act DoActionWhile f act -> performAction cr w $ DoActionWhilePartial act f act
DoActionWhilePartial partAc f resetAc DoActionWhilePartial partAc f resetAc
| doWdCrBl f w cr -> case performAction cr w partAc of | doWdCrBl f w cr -> case performAction cr w partAc of
(imps, Just nxta) -> (imps, Just $ DoActionWhilePartial nxta f resetAc) (imps, Just nxta) -> (imps, Just $ DoActionWhilePartial nxta f resetAc)
(imps, Nothing) -> (imps, Just $ DoActionWhilePartial resetAc f resetAc) (imps, Nothing) -> (imps, Just $ DoActionWhilePartial resetAc f resetAc)
| otherwise -> performAction cr w partAc | otherwise -> performAction cr w partAc
DoActionIf f ifa DoActionIf f ifa
| doWdCrBl f w cr -> performAction cr w ifa | doWdCrBl f w cr -> performAction cr w ifa
| otherwise -> ([],Nothing) | otherwise -> ([], Nothing)
DoActionIfElse ifa f elsea DoActionIfElse ifa f elsea
| doWdCrBl f w cr -> performAction cr w ifa | doWdCrBl f w cr -> performAction cr w ifa
| otherwise -> performAction cr w elsea | otherwise -> performAction cr w elsea
@@ -130,103 +122,109 @@ performAction cr w ac = case ac of
DoActions [] -> ([], Nothing) DoActions [] -> ([], Nothing)
DoActions acs -> DoActions acs ->
let (imps, newAcs) = unzip $ map (performAction cr w) acs let (imps, newAcs) = unzip $ map (performAction cr w) acs
in (concat imps, Just . DoActions $ catMaybes newAcs) in (concat imps, Just . DoActions $ catMaybes newAcs)
StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing) StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing)
PathTo p -> performPathTo cr w p PathTo p -> performPathTo cr w p
TurnToPoint p -> performTurnToA cr p TurnToPoint p -> performTurnToA cr p
LeadTarget p -> case cr ^? crIntention . targetCr . _Just of LeadTarget p -> case cr ^? crIntention . targetCr . _Just of
Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing) Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing)
_ -> ([], Nothing) _ -> ([], Nothing)
UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just
UseSelf f -> performAction cr w $ doCrAc f cr UseSelf f -> performAction cr w $ doCrAc f cr
UseAheadPos f -> performAction cr w (doP2Ac f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr))) UseAheadPos f -> performAction cr w (doP2Ac f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
UseMvTargetPos f -> performAction cr w $ doMP2Ac f $ _mvToPoint $ _crIntention cr UseMvTargetPos f -> performAction cr w $ doMP2Ac f $ _mvToPoint $ _crIntention cr
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w) ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
(imp, Just nxtac) -> (sideImp ++ imp, Just $ DoImpulsesAlongside sideImp nxtac) (imp, Just nxtac) -> (sideImp ++ imp, Just $ DoImpulsesAlongside sideImp nxtac)
(imp, _) -> (sideImp ++ imp, Nothing) (imp, _) -> (sideImp ++ imp, Nothing)
DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac DoReplicate t nxtac -> performAction cr w $ DoReplicatePartial nxtac t nxtac
DoReplicatePartial _ 0 pac -> performAction cr w pac DoReplicatePartial _ 0 pac -> performAction cr w pac
DoReplicatePartial startac t partac -> case performAction cr w partac of DoReplicatePartial startac t partac -> case performAction cr w partac of
(imps , Just nextac) -> (imps, Just $ DoReplicatePartial startac t nextac) (imps, Just nextac) -> (imps, Just $ DoReplicatePartial startac t nextac)
(imps , _) -> (imps, Just $ DoReplicatePartial startac (t-1) startac) (imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac)
NoAction -> ([],Nothing) NoAction -> ([], Nothing)
{- | Like a blink action, but no ingoing distortion -} -- | Like a blink action, but no ingoing distortion
blinkActionFail blinkActionFail ::
:: Creature Creature ->
-> World World ->
-> World World
blinkActionFail cr w = w blinkActionFail cr w =
& soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleS Nothing w
& cWorld . distortions .:~ distortionBulge & soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& cWorld . creatures . ix cid . crPos .~ p3 & cWorld . distortions .:~ distortionBulge
& inverseShockwaveAt cpos 40 2 2 & cWorld . creatures . ix cid . crPos .~ p3
& inverseShockwaveAt cpos 40 2 2
where where
distR = 120 distR = 120
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
cid = _crID cr cid = _crID cr
p1 = mouseWorldPos w p1 = mouseWorldPos w
cpos = _crPos cr cpos = _crPos cr
p2 = bouncePoint (const True) 1 cpos p1 w p2 = bouncePoint (const True) 1 cpos p1 w
r = 1.5 * _crRad cr r = 1.5 * _crRad cr
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2 p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
{- | Teleport a creature to the mouse position -} -- | Teleport a creature to the mouse position
blinkAction :: Creature -> World -> World blinkAction :: Creature -> World -> World
blinkAction cr w = w blinkAction cr w =
& soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleS Nothing w
& cWorld . distortions .++~ distortionBulge & soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& cWorld . creatures . ix cid . crPos .~ p3 & cWorld . distortions .++~ distortionBulge
& blinkShockwave cid p3 & cWorld . creatures . ix cid . crPos .~ p3
& inverseShockwaveAt cpos 40 2 2 & blinkShockwave cid p3
& inverseShockwaveAt cpos 40 2 2
where where
distR = 120 distR = 120
distortionBulge = distortionBulge =
[RadialDistortion p3 (p3 +.+ V2 distR 0) (p3 +.+ V2 0 distR) 0.1 [ RadialDistortion p3 (p3 +.+ V2 distR 0) (p3 +.+ V2 0 distR) 0.1
,RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 , RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
] ]
cid = _crID cr cid = _crID cr
p1 = mouseWorldPos w p1 = mouseWorldPos w
cpos = _crPos cr cpos = _crPos cr
p2 = bouncePoint (const True) 1 cpos p1 w p2 = bouncePoint (const True) 1 cpos p1 w
r = 1.5 * _crRad cr r = 1.5 * _crRad cr
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2 p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
{- | Teleport a creature to the mouse position. {- | Teleport a creature to the mouse position.
Can go through walls, if ending up in wall does big damage. -} Can go through walls, if ending up in wall does big damage.
unsafeBlinkAction -}
:: Creature unsafeBlinkAction ::
-> World Creature ->
-> World World ->
World
unsafeBlinkAction cr w unsafeBlinkAction cr w
| success = soundMultiFrom [TeleSound 0,TeleSound 1] mwp teleS Nothing | success =
. (cWorld . distortions .++~ distortionBulge) soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing
. set (cWorld . creatures . ix cid . crPos) mwp . (cWorld . distortions .++~ distortionBulge)
. blinkShockwave cid mwp . set (cWorld . creatures . ix cid . crPos) mwp
$ inverseShockwaveAt cpos 40 2 2 w . blinkShockwave cid mwp
| otherwise = w $ inverseShockwaveAt cpos 40 2 2 w
& blinkActionFail cr | otherwise =
& cWorld . creatures . ix cid . crState . csDamage .:~ w
Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect & blinkActionFail cr
& cWorld . creatures . ix cid . crState . csDamage
.:~ Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
where where
success = fromMaybe True $ do success = fromMaybe True $ do
wl <- snd $ collidePointWallsFilterStream (const True) mwp cpos w wl <- snd $ collidePointWallsFilterStream (const True) mwp cpos w
return (isLHS mwp `uncurry` _wlLine wl) return (isLHS mwp `uncurry` _wlLine wl)
distR = 120 distR = 120
distortionBulge = distortionBulge =
[RadialDistortion mwp (mwp +.+ V2 distR 0) (mwp +.+ V2 0 distR) 0.1 [ RadialDistortion mwp (mwp +.+ V2 distR 0) (mwp +.+ V2 0 distR) 0.1
,RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9 , RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
] ]
cid = _crID cr cid = _crID cr
mwp = mouseWorldPos w mwp = mouseWorldPos w
cpos = _crPos cr cpos = _crPos cr
blinkShockwave blinkShockwave ::
:: Int -- ^ Blinking creature ID. -- | Blinking creature ID.
-> Point2 Int ->
-> World Point2 ->
-> World World ->
World
blinkShockwave i p = makeShockwaveAt [i] p 60 1 2 cyan blinkShockwave i p = makeShockwaveAt [i] p 60 1 2 cyan
setMinInvSize :: Int -> Creature -> World -> World setMinInvSize :: Int -> Creature -> World -> World
@@ -234,32 +232,38 @@ setMinInvSize n cr = cWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
-- maybe this should be removed... -- maybe this should be removed...
stripNoItems :: Creature -> World -> World stripNoItems :: Creature -> World -> World
stripNoItems cr = organiseInvKeys (_crID cr) . stripNoItems cr =
( cWorld . creatures . ix (_crID cr) . crInv %~ IM.mapMaybe Just ) organiseInvKeys (_crID cr)
. (cWorld . creatures . ix (_crID cr) . crInv %~ IM.mapMaybe Just)
organiseInvKeys :: Int -> World -> World organiseInvKeys :: Int -> World -> World
organiseInvKeys cid w = w & cWorld . creatures . ix cid %~ organiseInvKeys cid w =
( ( crInvSel . iselPos .~ newSelKey ) w & cWorld . creatures . ix cid
. ( crInv .~ newInv ) %~ ( (crInvSel . iselPos .~ newSelKey)
. ( crInvSel . iselAction .~ NoInvSelAction) ) . (crInv .~ newInv)
. (crInvSel . iselAction .~ NoInvSelAction)
)
where where
cr = _creatures (_cWorld w) IM.! cid cr = _creatures (_cWorld w) IM.! cid
pairs = IM.toList (_crInv cr) pairs = IM.toList (_crInv cr)
newSelKey = fromMaybe 0 $ findIndex ( (== crSel cr) . fst) pairs newSelKey = fromMaybe 0 $ findIndex ((== crSel cr) . fst) pairs
newInv = IM.fromAscList $ zip [0..] $ map snd pairs newInv = IM.fromAscList $ zip [0 ..] $ map snd pairs
dropUnselected :: Creature -> World -> World dropUnselected :: Creature -> World -> World
dropUnselected cr w = foldr (dropItem cr) w . IM.keys dropUnselected cr w =
$ crSel cr `IM.delete` _crInv cr foldr (dropItem cr) w . IM.keys $
crSel cr `IM.delete` _crInv cr
dropExcept :: Creature -> Int -> World -> World dropExcept :: Creature -> Int -> World -> World
dropExcept cr invid w = foldr (dropItem cr) w . IM.keys dropExcept cr invid w =
$ invid `IM.delete` _crInv cr foldr (dropItem cr) w . IM.keys $
invid `IM.delete` _crInv cr
dropItem :: Creature -> Int -> World -> World dropItem :: Creature -> Int -> World -> World
dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . mayberemoveequip dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . mayberemoveequip
where where
cid = _crID cr cid = _crID cr
-- the following should be done in rmInvItem -- the following should be done in rmInvItem
-- mayberemoveequip = case _crLeftInvSel cr of -- mayberemoveequip = case _crLeftInvSel cr of
-- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing -- Just i | i == invid -> creatures . ix cid . crLeftInvSel .~ Nothing
@@ -270,48 +274,52 @@ youDropItem w
| _crInvLock (you w) = w | _crInvLock (you w) = w
| otherwise = youDropItem' w | otherwise = youDropItem' w
{- | Get your creature to drop the item under the cursor. -} -- | Get your creature to drop the item under the cursor.
youDropItem' :: World -> World youDropItem' :: World -> World
youDropItem' w = case yourItem w ^? _Just . itCurseStatus of youDropItem' w = case yourItem w ^? _Just . itCurseStatus of
Just Uncursed -> w Just Uncursed ->
& dropItem cr (crSel cr) w
& soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing & dropItem cr (crSel cr)
& soundStart (CrSound (_crID cr)) (_crPos cr) whiteNoiseFadeOutS Nothing
_ -> w _ -> w
where where
cr = you w cr = you w
{- | Copy an inventory item to the floor. -} -- | Copy an inventory item to the floor.
copyInvItemToFloor :: Creature -> Int -> World -> World copyInvItemToFloor :: Creature -> Int -> World -> World
copyInvItemToFloor cr i = copyItemToFloor (_crPos cr) copyInvItemToFloor cr i =
$ _crInv cr IM.! i copyItemToFloor (_crPos cr) $
& itIsHeld .~ False _crInv cr IM.! i
& itIsHeld .~ False
sizeSelf :: Float -> Creature -> World -> Maybe World sizeSelf :: Float -> Creature -> World -> Maybe World
sizeSelf x cr w sizeSelf x cr w
-- | _crPos cr1 == _crPos cr2 = Just $ w | not (crOnWall cr1 w) =
| not (crOnWall cr1 w) = Just $ w Just $
& soundMultiFrom [TeleSound 0,TeleSound 1] cpos teleS Nothing w
& cWorld . distortions .:~ distortionBulge & soundMultiFrom [TeleSound 0, TeleSound 1] cpos teleS Nothing
& cWorld . creatures . ix cid %~ & cWorld . distortions .:~ distortionBulge
( (crRad .~ 10 * x) & cWorld . creatures . ix cid
. (crMvType . mvSpeed .~ yourDefaultSpeed * x) %~ ( (crRad .~ 10 * x)
. (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x)) . (crMvType . mvSpeed .~ yourDefaultSpeed * x)
) . (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x))
)
| otherwise = Nothing | otherwise = Nothing
where where
cr1 = colCrWall w (cr {_crRad = 10* x}) cr1 = colCrWall w (cr{_crRad = 10 * x})
distR = 120 distR = 120
distortionBulge distortionBulge
| _crRad cr < 10*x = raddist 1.9 | _crRad cr < 10 * x = raddist 1.9
| otherwise = raddist 0.1 | otherwise = raddist 0.1
raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR)
cid = _crID cr cid = _crID cr
cpos = _crPos cr cpos = _crPos cr
pickUpItemID :: Int -> Int -> World -> World pickUpItemID :: Int -> Int -> World -> World
pickUpItemID cid flid w = pickUpItem cid (_floorItems (_cWorld w) IM.! flid) w pickUpItemID cid flid w = pickUpItem cid (_floorItems (_cWorld w) IM.! flid) w
{- | Pick up a specific item. -} -- | Pick up a specific item.
pickUpItem :: Int -> FloorItem -> World -> World pickUpItem :: Int -> FloorItem -> World -> World
pickUpItem cid flit w = maybe w (soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing . snd) pickUpItem cid flit w =
$ tryPutItemInInv cid flit w maybe w (soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing . snd) $
tryPutItemInInv cid flit w
+3 -2
View File
@@ -1,6 +1,7 @@
module Dodge.Creature.Impulse.UseItem module Dodge.Creature.Impulse.UseItem
( useItem ( useItem
, useLeftItem , useLeftItem
, itemEffect
) where ) where
import Dodge.Data import Dodge.Data
import Dodge.Luse import Dodge.Luse
@@ -41,8 +42,8 @@ itemEffect cr it w = case it ^? itUse of
HammerUp -> f w HammerUp -> f w
_ -> w & setuhamdown _ -> w & setuhamdown
setuhamdown = cWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown setuhamdown = cWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
doequipmentchange = setuhamdown $ hammerTest (toggleEquipmentAt (_rbOptions (_cWorld w)) (crSel cr) cr doequipmentchange = setuhamdown $ hammerTest (toggleEquipmentAt (_rbOptions w) (crSel cr) cr
. activateEquipmentAt (_rbOptions (_cWorld w)) cr) . activateEquipmentAt (_rbOptions w) cr)
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
tryReload cr it w f tryReload cr it w f
+5 -113
View File
@@ -58,9 +58,6 @@ module Dodge.Data (
module Dodge.Distortion.Data, module Dodge.Distortion.Data,
module Dodge.Data.Damage, module Dodge.Data.Damage,
module Dodge.Data.SoundOrigin, module Dodge.Data.SoundOrigin,
module Dodge.Creature.Stance.Data,
module Dodge.Creature.Perception.Data,
module Dodge.Creature.Memory.Data,
module Dodge.Config.Data, module Dodge.Config.Data,
module MaybeHelp, module MaybeHelp,
module Dodge.Data.ItemAmount, module Dodge.Data.ItemAmount,
@@ -83,14 +80,14 @@ module Dodge.Data (
module Dodge.Data.GenParams, module Dodge.Data.GenParams,
module Dodge.Data.Terminal, module Dodge.Data.Terminal,
module Dodge.Data.FloorItem, module Dodge.Data.FloorItem,
module Dodge.Data.CWorld,
) where ) where
import Dodge.Data.CWorld
import Color import Color
import Control.Lens import Control.Lens
import Control.Monad.State import Control.Monad.State
import Data.Aeson import Data.Aeson
import Data.Graph.Inductive
import qualified Data.IntSet as IS
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Preload import Data.Preload
import qualified Data.Set as S import qualified Data.Set as S
@@ -99,9 +96,6 @@ import Data.Tile
import Dodge.Combine.Data import Dodge.Combine.Data
import Dodge.Config.Data import Dodge.Config.Data
import Dodge.Config.KeyConfig import Dodge.Config.KeyConfig
import Dodge.Creature.Memory.Data
import Dodge.Creature.Perception.Data
import Dodge.Creature.Stance.Data
import Dodge.Data.ActionPlan import Dodge.Data.ActionPlan
import Dodge.Data.Ammo import Dodge.Data.Ammo
import Dodge.Data.ArcStep import Dodge.Data.ArcStep
@@ -163,10 +157,8 @@ import Dodge.Data.Wall
import Dodge.Data.WorldEffect import Dodge.Data.WorldEffect
import Dodge.Data.Zoning import Dodge.Data.Zoning
import Dodge.Distortion.Data import Dodge.Distortion.Data
import Dodge.GameRoom
import Dodge.RoomCluster.Data import Dodge.RoomCluster.Data
import GHC.Generics import GHC.Generics
import Geometry.ConvexPoly
import Geometry.Data import Geometry.Data
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import MaybeHelp import MaybeHelp
@@ -176,8 +168,6 @@ import Sound.Data
import Streaming import Streaming
import System.Random import System.Random
type CRUpdate = Creature -> World -> (World -> World, Maybe Creature)
type CRUpdate' = Creature -> World -> (World -> World, Creature) type CRUpdate' = Creature -> World -> (World -> World, Creature)
data Universe = Universe data Universe = Universe
@@ -206,100 +196,16 @@ data World = World
, _keys :: S.Set Scancode , _keys :: S.Set Scancode
, _mouseButtons :: M.Map MouseButton Bool , _mouseButtons :: M.Map MouseButton Bool
, _hammers :: M.Map WorldHammer HammerPosition , _hammers :: M.Map WorldHammer HammerPosition
}
data CWorld = CWorld
{ _cameraCenter :: Point2
, _cameraRot :: Float
, _cameraZoom :: Float -- smaller values zoom out
, _itemZoom :: Float
, _defaultZoom :: Float
, _cameraViewFrom :: Point2
, _viewDistance :: Float
, _boundBox :: [Point2]
, _boundDist :: (Float, Float, Float, Float) -- NSEW, S and W negative
, _creatures :: IM.IntMap Creature
, _crZoning :: IM.IntMap (IM.IntMap IS.IntSet) --Zoning IM.IntMap Creature
, _creatureGroups :: IM.IntMap CrGroupParams
, _itemPositions :: IM.IntMap ItemPos
, _clouds :: [Cloud]
, _clZoning :: IM.IntMap (IM.IntMap [Cloud]) --Zoning IM.IntMap Creature
, _gusts :: IM.IntMap Gust
, _gsZoning :: IM.IntMap (IM.IntMap IS.IntSet)
, _props :: IM.IntMap Prop
, _projectiles :: IM.IntMap Proj
, _instantBullets :: [Bullet]
, _bullets :: [Bullet]
, _radarSweeps :: [RadarSweep]
, _energyBalls :: [EnergyBall]
, _posEvents :: [PosEvent]
, _flames :: [Flame]
, _sparks :: [Spark]
, _radarBlips :: [RadarBlip]
, _flares :: [Flare]
, _newBeams :: WorldBeams
, _beams :: WorldBeams
, _teslaArcs :: [TeslaArc]
, _shockwaves :: [Shockwave]
, _lasers :: [LaserStart]
, _lasersToDraw :: [Laser]
, _linearShockwaves :: IM.IntMap LinearShockwave
, _tractorBeams :: [TractorBeam]
, _walls :: IM.IntMap Wall
, _wallDamages :: IM.IntMap [Damage]
, _doors :: IM.IntMap Door
, _machines :: IM.IntMap Machine
, _terminals :: IM.IntMap Terminal
, _magnets :: IM.IntMap Magnet
, _blocks :: IM.IntMap Block
, _coordinates :: IM.IntMap Point2
, _triggers :: IM.IntMap Bool
, _wlZoning :: IM.IntMap (IM.IntMap IS.IntSet) -- Zoning IM.IntMap Wall
, _floorItems :: IM.IntMap FloorItem
, _floorTiles :: [(Point3, Point3)]
, _modifications :: IM.IntMap Modification
, _yourID :: Int
, _worldEvents :: [WdWd]
, _delayedEvents :: [(Int, WdWd)]
, _pressPlates :: IM.IntMap PressPlate
, _buttons :: IM.IntMap Button
, _decorations :: IM.IntMap Picture
, _foregroundShapes :: IM.IntMap ForegroundShape
, _corpses :: IM.IntMap Corpse
, _clickMousePos :: Point2
, _pathGraph :: Gr Point2 PathEdge
, _pnZoning :: IM.IntMap (IM.IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature
, _peZoning :: IM.IntMap (IM.IntMap [(Int, Int, PathEdge)]) --Zoning IM.IntMap Creature
, _hud :: HUD
, _lightSources :: IM.IntMap LightSource
, _tempLightSources :: [TempLightSource]
, _closeObjects :: [Either FloorItem Button]
, _rbOptions :: RightButtonOptions
, _seenLocations :: IM.IntMap (WdP2, String)
, _selLocation :: Int
, _distortions :: [Distortion]
, _worldBounds :: Bounds
, _gameRooms :: [GameRoom] -- consider using an IntMap
, _roomClipping :: [ConvexPoly]
, _maybeWorld :: Maybe' CWorld
, _rewindWorlds :: [CWorld]
, _timeFlow :: TimeFlowStatus
, _worldClock :: Int
, _backspaceTimer :: Int
, _genParams :: GenParams
, _deathDelay :: Maybe Int
, _testFloat :: Float , _testFloat :: Float
, _lLine :: (Point2, Point2) , _lLine :: (Point2, Point2)
, _rLine :: (Point2, Point2) , _rLine :: (Point2, Point2)
, _lSelect :: Point2 , _lSelect :: Point2
, _rSelect :: Point2 , _rSelect :: Point2
, _backspaceTimer :: Int
, _timeFlow :: TimeFlowStatus
, _rbOptions :: RightButtonOptions
} }
deriving (Eq, Show, Read, Generic)
instance ToJSON CWorld where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CWorld
instance ToJSON MouseButton where instance ToJSON MouseButton where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
@@ -397,18 +303,6 @@ data MenuOption
data IntID a = IntID Int a data IntID a = IntID Int a
data WorldBeams = WorldBeams
{ _blockingBeams :: [Beam]
, _lightBeams :: [Beam]
, _positronBeams :: [Beam]
, _electronBeams :: [Beam]
}
deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON WorldBeams where
toEncoding = genericToEncoding defaultOptions
instance FromJSON WorldBeams
type HitEffect' = type HitEffect' =
Flame -> Flame ->
@@ -531,9 +425,7 @@ makeLenses ''World
--makeLenses ''Particle --makeLenses ''Particle
makeLenses ''Universe makeLenses ''Universe
makeLenses ''ScreenLayer makeLenses ''ScreenLayer
makeLenses ''WorldBeams
makeLenses ''GenWorld makeLenses ''GenWorld
makeLenses ''CWorld
----- ROOM LENSES ----- ROOM LENSES
+95 -71
View File
@@ -1,36 +1,43 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StrictData #-}
--{-# LANGUAGE DeriveGeneric #-} --{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE DeriveGeneric #-}
module Dodge.Data.ActionPlan where module Dodge.Data.ActionPlan where
import GHC.Generics
import Data.Aeson
import Dodge.Creature.Stance.Data
import Dodge.Data.CreatureEffect
--import Dodge.ShortShow
import Control.Lens import Control.Lens
import Data.Aeson
import Dodge.Data.Creature.Stance
import Dodge.Data.CreatureEffect
import GHC.Generics
import Geometry.Data import Geometry.Data
import Sound.Data import Sound.Data
--import GHC.Generics
data ActionPlan data ActionPlan
= Inanimate = Inanimate
| ActionPlan | ActionPlan
{_apImpulse :: [Impulse] { _apImpulse :: [Impulse]
,_apAction :: [Action] , _apAction :: [Action]
,_apStrategy :: Strategy , _apStrategy :: Strategy
,_apGoal :: [Goal] , _apGoal :: [Goal]
} }
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON ActionPlan where instance ToJSON ActionPlan where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON ActionPlan instance FromJSON ActionPlan
data RandImpulse data RandImpulse
= RandImpulseList [Impulse] = RandImpulseList [Impulse]
| RandImpulseCircMove Float | RandImpulseCircMove Float
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON RandImpulse where
instance ToJSON RandImpulse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON RandImpulse instance FromJSON RandImpulse
data Impulse data Impulse
= Move Point2 = Move Point2
| MoveForward Float | MoveForward Float
@@ -54,123 +61,134 @@ data Impulse
| ArbitraryImpulse CrWdImp | ArbitraryImpulse CrWdImp
| ArbitraryImpulseEffect CrWdWd | ArbitraryImpulseEffect CrWdWd
| ImpulseUseTargetCID | ImpulseUseTargetCID
{_impulseUseTargetCID :: IntImp { _impulseUseTargetCID :: IntImp
} }
| ImpulseUseTarget | ImpulseUseTarget
{_impulseUseTarget :: CrImp { _impulseUseTarget :: CrImp
} }
| ImpulseUseAheadPos | ImpulseUseAheadPos
{_impulseUseAheadPos :: P2Imp { _impulseUseAheadPos :: P2Imp
} }
| ImpulseNothing | ImpulseNothing
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Impulse where instance ToJSON Impulse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Impulse instance FromJSON Impulse
infixr 9 `WaitThen` infixr 9 `WaitThen`
infixr 9 `DoActionThen` infixr 9 `DoActionThen`
infixr 9 `DoActionWhile` infixr 9 `DoActionWhile`
infixr 9 `DoReplicate` infixr 9 `DoReplicate`
infixr 9 `DoImpulsesAlongside` infixr 9 `DoImpulsesAlongside`
data Action data Action
= LabelAction = LabelAction
{_actLabel :: String { _actLabel :: String
,_actAction :: Action , _actAction :: Action
} }
| ActionNothing | ActionNothing
| AimAt | AimAt
{_targetID :: Int { _targetID :: Int
,_targetSeenAt :: Point2 , _targetSeenAt :: Point2
} }
| PathTo | PathTo
{_pathToPoint :: Point2 { _pathToPoint :: Point2
} }
| TurnToPoint | TurnToPoint
{_turnToPoint :: Point2 { _turnToPoint :: Point2
} }
-- | PickupItem | -- | PickupItem
-- {_pickupItemID :: Int -- {_pickupItemID :: Int
-- } -- }
| ImpulsesList ImpulsesList
{_impulsesListList :: [[Impulse]] { _impulsesListList :: [[Impulse]]
} }
| DoImpulses | DoImpulses
{_doImpulsesList :: [Impulse] { _doImpulsesList :: [Impulse]
} }
| WaitThen | WaitThen
{_waitThenTimer :: Int { _waitThenTimer :: Int
,_waitThenAction :: Action , _waitThenAction :: Action
} }
| DoActionWhile | DoActionWhile
{_doActionWhileCondition :: WdCrBl { _doActionWhileCondition :: WdCrBl
,_doActionWhileAction :: Action , _doActionWhileAction :: Action
} }
| DoActionWhilePartial | DoActionWhilePartial
{_doActionWhilePartial :: Action { _doActionWhilePartial :: Action
,_doActionWhileCondition :: WdCrBl , _doActionWhileCondition :: WdCrBl
,_doActionWhileAction :: Action , _doActionWhileAction :: Action
} }
| DoActionIf | DoActionIf
{_doActionIfCondition :: WdCrBl { _doActionIfCondition :: WdCrBl
,_doActionIfAction :: Action , _doActionIfAction :: Action
} }
| DoActionIfElse | DoActionIfElse
{_doActionIfElseIfAction :: Action { _doActionIfElseIfAction :: Action
,_doActionIfElseCondition :: WdCrBl , _doActionIfElseCondition :: WdCrBl
,_doActionIfElseElseAction :: Action , _doActionIfElseElseAction :: Action
} }
| DoActionWhileInterrupt | DoActionWhileInterrupt
{_doActionWhileThenDo :: Action { _doActionWhileThenDo :: Action
,_doActionWhileThenCondition :: WdCrBl , _doActionWhileThenCondition :: WdCrBl
,_doActionWhileThenThen :: Action , _doActionWhileThenThen :: Action
} }
| DoActions | DoActions
{_doActionsList :: [Action] { _doActionsList :: [Action]
} }
| DoActionThen | DoActionThen
{_doActionThenFirst :: Action { _doActionThenFirst :: Action
,_doActionThenSecond :: Action , _doActionThenSecond :: Action
} }
-- | DoGuardActions | -- | DoGuardActions
-- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)] -- {_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
-- } -- }
| DoReplicate DoReplicate
{_doReplicateTimes :: Int { _doReplicateTimes :: Int
,_doReplicateAction :: Action , _doReplicateAction :: Action
} }
| DoReplicatePartial | DoReplicatePartial
{_partialAction :: Action { _partialAction :: Action
,_doReplicateTimes :: Int , _doReplicateTimes :: Int
,_doReplicateAction :: Action , _doReplicateAction :: Action
} }
| LeadTarget | LeadTarget
{_leadTargetBy :: Point2 { _leadTargetBy :: Point2
} }
| NoAction | NoAction
| StartSentinelPost | StartSentinelPost
| UseTarget | UseTarget
{_useTarget :: MCrAc { _useTarget :: MCrAc
} }
| UseSelf | UseSelf
{_useSelf :: CrAc { _useSelf :: CrAc
} }
| UseAheadPos | UseAheadPos
{_useAheadPos :: P2Ac { _useAheadPos :: P2Ac
} }
| UseMvTargetPos | UseMvTargetPos
{_useMvTargetPos :: MP2Ac { _useMvTargetPos :: MP2Ac
} }
| ArbitraryAction | ArbitraryAction
{ _arbitraryAction :: CrWdAc } {_arbitraryAction :: CrWdAc}
| DoImpulsesAlongside | -- | Repeatedly perform impulses alongside a main action until the main action terminates
-- ^ Repeatedly perform impulses alongside a main action until the main action terminates DoImpulsesAlongside
{_sideImpulses :: [Impulse] { _sideImpulses :: [Impulse]
,_mainAction :: Action , _mainAction :: Action
} }
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Action where instance ToJSON Action where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Action instance FromJSON Action
data Strategy data Strategy
= Flank Int = Flank Int
| Ambush Int | Ambush Int
@@ -187,18 +205,24 @@ data Strategy
| Reload | Reload
| Flee | Flee
| MeleeStrike | MeleeStrike
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Strategy where instance ToJSON Strategy where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Strategy instance FromJSON Strategy
data Goal data Goal
= LiveLongAndProsper = LiveLongAndProsper
| Kill Int | Kill Int
| SentinelAt Point2 Float | SentinelAt Point2 Float
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Goal where instance ToJSON Goal where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Goal instance FromJSON Goal
makeLenses ''ActionPlan makeLenses ''ActionPlan
makeLenses ''Impulse makeLenses ''Impulse
makeLenses ''Action makeLenses ''Action
+159
View File
@@ -0,0 +1,159 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Dodge.Data.CWorld where
import Control.Lens
import Data.Aeson
import Data.Graph.Inductive
import qualified Data.IntSet as IS
import Dodge.Data.Beam
import Dodge.Data.Block
import Dodge.Data.Bounds
import Dodge.Data.Bullet
import Dodge.Data.Button
import Dodge.Data.Cloud
import Dodge.Data.Corpse
import Dodge.Data.CrGroupParams
import Dodge.Data.Creature
import Dodge.Data.Damage
import Dodge.Data.Door
import Dodge.Data.EnergyBall
import Dodge.Data.Flame
import Dodge.Data.Flare
import Dodge.Data.FloorItem
import Dodge.Data.ForegroundShape
import Dodge.Data.GenParams
import Dodge.Data.Gust
import Dodge.Data.HUD
import Dodge.Data.Item
import Dodge.Data.Laser
import Dodge.Data.LightSource
import Dodge.Data.LinearShockwave
import Dodge.Data.Machine
import Dodge.Data.Magnet
import Dodge.Data.Modification
import Dodge.Data.PathGraph
import Dodge.Data.PosEvent
import Dodge.Data.PressPlate
import Dodge.Data.Projectile
import Dodge.Data.Prop
import Dodge.Data.RadarBlip
import Dodge.Data.RadarSweep
import Dodge.Data.Shockwave
import Dodge.Data.Spark
import Dodge.Data.Terminal
import Dodge.Data.TeslaArc
import Dodge.Data.TractorBeam
import Dodge.Data.Wall
import Dodge.Data.WorldEffect
import Dodge.Distortion.Data
import Dodge.GameRoom
import GHC.Generics
import Geometry.ConvexPoly
import Geometry.Data
import qualified IntMapHelp as IM
import MaybeHelp
import Picture.Data
data CWorld = CWorld
{ _cameraCenter :: Point2
, _cameraRot :: Float
, _cameraZoom :: Float -- smaller values zoom out
, _itemZoom :: Float
, _defaultZoom :: Float
, _cameraViewFrom :: Point2
, _viewDistance :: Float
, _boundBox :: [Point2]
, _boundDist :: (Float, Float, Float, Float) -- NSEW, S and W negative
, _creatures :: IM.IntMap Creature
, _crZoning :: IM.IntMap (IM.IntMap IS.IntSet)
, _creatureGroups :: IM.IntMap CrGroupParams
, _itemPositions :: IM.IntMap ItemPos
, _clouds :: [Cloud]
, _clZoning :: IM.IntMap (IM.IntMap [Cloud])
, _gusts :: IM.IntMap Gust
, _gsZoning :: IM.IntMap (IM.IntMap IS.IntSet)
, _props :: IM.IntMap Prop
, _projectiles :: IM.IntMap Proj
, _instantBullets :: [Bullet]
, _bullets :: [Bullet]
, _radarSweeps :: [RadarSweep]
, _energyBalls :: [EnergyBall]
, _posEvents :: [PosEvent]
, _flames :: [Flame]
, _sparks :: [Spark]
, _radarBlips :: [RadarBlip]
, _flares :: [Flare]
, _newBeams :: WorldBeams
, _beams :: WorldBeams
, _teslaArcs :: [TeslaArc]
, _shockwaves :: [Shockwave]
, _lasers :: [LaserStart]
, _lasersToDraw :: [Laser]
, _linearShockwaves :: IM.IntMap LinearShockwave
, _tractorBeams :: [TractorBeam]
, _walls :: IM.IntMap Wall
, _wallDamages :: IM.IntMap [Damage]
, _doors :: IM.IntMap Door
, _machines :: IM.IntMap Machine
, _terminals :: IM.IntMap Terminal
, _magnets :: IM.IntMap Magnet
, _blocks :: IM.IntMap Block
, _coordinates :: IM.IntMap Point2
, _triggers :: IM.IntMap Bool
, _wlZoning :: IM.IntMap (IM.IntMap IS.IntSet) -- Zoning IM.IntMap Wall
, _floorItems :: IM.IntMap FloorItem
, _floorTiles :: [(Point3, Point3)]
, _modifications :: IM.IntMap Modification
, _yourID :: Int
, _worldEvents :: [WdWd]
, _delayedEvents :: [(Int, WdWd)]
, _pressPlates :: IM.IntMap PressPlate
, _buttons :: IM.IntMap Button
, _decorations :: IM.IntMap Picture
, _foregroundShapes :: IM.IntMap ForegroundShape
, _corpses :: IM.IntMap Corpse
, _clickMousePos :: Point2
, _pathGraph :: Gr Point2 PathEdge
, _pnZoning :: IM.IntMap (IM.IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature
, _peZoning :: IM.IntMap (IM.IntMap [(Int, Int, PathEdge)]) --Zoning IM.IntMap Creature
, _hud :: HUD
, _lightSources :: IM.IntMap LightSource
, _tempLightSources :: [TempLightSource]
, _closeObjects :: [Either FloorItem Button]
, _seenLocations :: IM.IntMap (WdP2, String)
, _selLocation :: Int
, _distortions :: [Distortion]
, _worldBounds :: Bounds
, _gameRooms :: [GameRoom] -- consider using an IntMap
, _roomClipping :: [ConvexPoly]
, _maybeWorld :: Maybe' CWorld
, _rewindWorlds :: [CWorld]
, _worldClock :: Int
, _genParams :: GenParams
, _deathDelay :: Maybe Int
}
deriving (Eq, Show, Read, Generic)
instance ToJSON CWorld where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CWorld
data WorldBeams = WorldBeams
{ _blockingBeams :: [Beam]
, _lightBeams :: [Beam]
, _positronBeams :: [Beam]
, _electronBeams :: [Beam]
}
deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON WorldBeams where
toEncoding = genericToEncoding defaultOptions
instance FromJSON WorldBeams
makeLenses ''CWorld
makeLenses ''WorldBeams
+6 -3
View File
@@ -5,6 +5,9 @@ module Dodge.Data.Creature
( module Dodge.Data.Creature ( module Dodge.Data.Creature
, module Dodge.Data.Creature.Misc , module Dodge.Data.Creature.Misc
, module Dodge.Data.Creature.State , module Dodge.Data.Creature.State
, module Dodge.Data.Creature.Perception
, module Dodge.Data.Creature.Memory
, module Dodge.Data.Creature.Stance
) where ) where
import GHC.Generics import GHC.Generics
import Data.Aeson import Data.Aeson
@@ -15,9 +18,9 @@ import Dodge.Data.LoadAction
import Dodge.Data.Material import Dodge.Data.Material
import Dodge.Data.ActionPlan import Dodge.Data.ActionPlan
import Dodge.Data.Hammer import Dodge.Data.Hammer
import Dodge.Creature.Perception.Data import Dodge.Data.Creature.Perception
import Dodge.Creature.Memory.Data import Dodge.Data.Creature.Memory
import Dodge.Creature.Stance.Data import Dodge.Data.Creature.Stance
import Geometry.Data import Geometry.Data
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -1,7 +1,7 @@
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
module Dodge.Creature.Memory.Data module Dodge.Data.Creature.Memory
where where
import GHC.Generics import GHC.Generics
import Data.Aeson import Data.Aeson
@@ -1,7 +1,7 @@
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
module Dodge.Creature.Perception.Data module Dodge.Data.Creature.Perception
( Perception (..) ( Perception (..)
, Vigilance (..) , Vigilance (..)
, Attention (..) , Attention (..)
@@ -1,7 +1,7 @@
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
module Dodge.Creature.Stance.Data module Dodge.Data.Creature.Stance
where where
import GHC.Generics import GHC.Generics
import Data.Aeson import Data.Aeson
+17
View File
@@ -25,16 +25,22 @@ data HeldUse
| HeldForceField | HeldForceField
| HeldShatter | HeldShatter
deriving (Eq, Ord, Show, Read, Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON HeldUse where instance ToJSON HeldUse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON HeldUse instance FromJSON HeldUse
data Cuse data Cuse
= CDoNothing = CDoNothing
| CHeal Int | CHeal Int
deriving (Eq, Ord, Show, Read, Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Cuse where instance ToJSON Cuse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Cuse instance FromJSON Cuse
data Euse data Euse
= EDoNothing = EDoNothing
| EDetector Detector | EDetector Detector
@@ -45,9 +51,12 @@ data Euse
| EonWristShield | EonWristShield
| EoffWristShield | EoffWristShield
deriving (Eq, Ord, Show, Read, Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Euse where instance ToJSON Euse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Euse instance FromJSON Euse
data Luse data Luse
= LDoNothing = LDoNothing
| LRewind | LRewind
@@ -56,13 +65,17 @@ data Luse
| LUnsafeBlink | LUnsafeBlink
| LBoost | LBoost
deriving (Eq, Ord, Show, Read, Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON Luse where instance ToJSON Luse where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON Luse instance FromJSON Luse
data HeldMod data HeldMod
= HeldModNothing = HeldModNothing
| PoisonSprayerMod | PoisonSprayerMod
| FlameSpitterMod | FlameSpitterMod
| FlameSpitterRepeatMod
| FlameThrowerMod | FlameThrowerMod
| LauncherMod | LauncherMod
| TeslaMod | TeslaMod
@@ -88,11 +101,15 @@ data HeldMod
| AutoPistolMod | AutoPistolMod
| MachinePistolMod | MachinePistolMod
| BurstRifleMod | BurstRifleMod
| BurstRifleRepeatMod
| MiniGunMod Int | MiniGunMod Int
| SmgMod | SmgMod
| RevolverXMod | RevolverXMod
| RevolverXRepeatMod
| BangConeMod | BangConeMod
deriving (Eq, Ord, Show, Read, Generic) deriving (Eq, Ord, Show, Read, Generic)
instance ToJSON HeldMod where instance ToJSON HeldMod where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
instance FromJSON HeldMod instance FromJSON HeldMod
+10
View File
@@ -3,12 +3,20 @@
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
module Dodge.Data.WorldEffect where module Dodge.Data.WorldEffect where
import Dodge.Data.Item
import Data.Aeson import Data.Aeson
import GHC.Generics import GHC.Generics
import Dodge.Data.CreatureEffect import Dodge.Data.CreatureEffect
import Sound.Data import Sound.Data
import Geometry.Data import Geometry.Data
import Dodge.Data.SoundOrigin import Dodge.Data.SoundOrigin
data ItCrWdWd = ItCrWdId
| ItCrWdItemEffect
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItCrWdWd where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItCrWdWd
data WdWd = NoWorldEffect data WdWd = NoWorldEffect
| SetTrigger Bool Int | SetTrigger Bool Int
| WorldEffects [WdWd] | WorldEffects [WdWd]
@@ -19,6 +27,8 @@ data WdWd = NoWorldEffect
| MakeStartCloudAt Point3 | MakeStartCloudAt Point3
| TorqueCr Float Int | TorqueCr Float Int
| WdWdNegateTrig Int | WdWdNegateTrig Int
| WdWdFromItixCrixWdWd Int Int ItCrWdWd
| WdWdFromItCrixWdWd Item Int ItCrWdWd
deriving (Eq,Ord,Show,Read,Generic) deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON WdWd where instance ToJSON WdWd where
toEncoding = genericToEncoding defaultOptions toEncoding = genericToEncoding defaultOptions
+8 -8
View File
@@ -19,6 +19,14 @@ defaultWorld = World
, _mouseButtons = mempty , _mouseButtons = mempty
, _mousePos = V2 0 0 , _mousePos = V2 0 0
, _hammers = defaultWorldHammers , _hammers = defaultWorldHammers
, _testFloat = 0
, _lLine = (0,0)
, _rLine = (0,0)
, _lSelect = 0
, _rSelect = 0
, _backspaceTimer = 0
, _timeFlow = NormalTimeFlow
, _rbOptions = NoRightButtonOptions
} }
defaultCWorld :: CWorld defaultCWorld :: CWorld
@@ -95,7 +103,6 @@ defaultCWorld = CWorld
, _lightSources = IM.empty , _lightSources = IM.empty
, _tempLightSources = [] , _tempLightSources = []
, _closeObjects = [] , _closeObjects = []
, _rbOptions = NoRightButtonOptions
, _seenLocations = IM.fromList , _seenLocations = IM.fromList
[(0, (WdYouPos, "CURRENT POSITION")) [(0, (WdYouPos, "CURRENT POSITION"))
,(1, (WdP2Const (V2 0 0) , "START POSITION")) ,(1, (WdP2Const (V2 0 0) , "START POSITION"))
@@ -109,19 +116,12 @@ defaultCWorld = CWorld
, _worldBounds = defaultBounds , _worldBounds = defaultBounds
, _maybeWorld = Nothing' , _maybeWorld = Nothing'
, _rewindWorlds = [] , _rewindWorlds = []
, _timeFlow = NormalTimeFlow
, _backspaceTimer = 0
, _genParams = GenParams M.empty , _genParams = GenParams M.empty
-- , _genPlacements = IM.empty -- , _genPlacements = IM.empty
-- , _genRooms = IM.empty -- , _genRooms = IM.empty
, _deathDelay = Nothing , _deathDelay = Nothing
, _testFloat = 0
, _boundBox = square 100 , _boundBox = square 100
, _boundDist = (100,-100,100,-100) , _boundDist = (100,-100,100,-100)
, _lLine = (0,0)
, _rLine = (0,0)
, _lSelect = 0
, _rSelect = 0
} }
defaultWorldHammers :: M.Map WorldHammer HammerPosition defaultWorldHammers :: M.Map WorldHammer HammerPosition
defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound.. maxBound] defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound.. maxBound]
+3 -3
View File
@@ -97,7 +97,7 @@ wheelEvent y w = case _hudElement $ _hud (_cWorld w) of
-- functions that modify the inventory should be centralised so that -- functions that modify the inventory should be centralised so that
-- this lock can be sensibly applied, perhaps -- this lock can be sensibly applied, perhaps
| _crInvLock (_creatures (_cWorld w) IM.! _yourID (_cWorld w)) -> w | _crInvLock (_creatures (_cWorld w) IM.! _yourID (_cWorld w)) -> w
| rbDown -> case (yourItem w ^? _Just . itUse . heldScroll,_rbOptions (_cWorld w)) of | rbDown -> case (yourItem w ^? _Just . itUse . heldScroll,_rbOptions w) of
(_,EquipOptions{}) -> scrollRBOption y w (_,EquipOptions{}) -> scrollRBOption y w
(Nothing,_) -> closeObjScrollDir y w (Nothing,_) -> closeObjScrollDir y w
(Just f,_) -> w & cWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ doHeldScroll f y (you w) (Just f,_) -> w & cWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ doHeldScroll f y (you w)
@@ -159,8 +159,8 @@ nullCommand = TerminalCommand
scrollRBOption :: Float -> World -> World scrollRBOption :: Float -> World -> World
scrollRBOption y w scrollRBOption y w
| y < 0 = w & cWorld . rbOptions . opSel %~ (min (length (_opEquip (_rbOptions (_cWorld w)))-1) . (+1)) | y < 0 = w & rbOptions . opSel %~ (min (length (_opEquip (_rbOptions w))-1) . (+1))
| y > 0 = w & cWorld . rbOptions . opSel %~ (max 0 . subtract 1) | y > 0 = w & rbOptions . opSel %~ (max 0 . subtract 1)
| otherwise = w | otherwise = w
moveTweakSel :: Int -> World -> World moveTweakSel :: Int -> World -> World
+4 -4
View File
@@ -68,9 +68,9 @@ handleKeyboardEvent kev u = case keyboardEventKeyMotion kev of
handlePressedKey :: Bool -> Scancode -> Universe -> IO (Maybe Universe) handlePressedKey :: Bool -> Scancode -> Universe -> IO (Maybe Universe)
handlePressedKey True ScancodeBackspace u handlePressedKey True ScancodeBackspace u
| _backspaceTimer (_cWorld $ _uvWorld u) <= 0 = handlePressedKey False ScancodeBackspace u | _backspaceTimer (_uvWorld u) <= 0 = handlePressedKey False ScancodeBackspace u
<&> _Just . uvWorld . cWorld . backspaceTimer .~ 0 <&> _Just . uvWorld . backspaceTimer .~ 0
| otherwise = return $ Just $ u & uvWorld . cWorld . backspaceTimer -~ 1 | otherwise = return $ Just $ u & uvWorld . backspaceTimer -~ 1
handlePressedKey True _ u = return $ Just u handlePressedKey True _ u = return $ Just u
handlePressedKey _ scode u = case scode of handlePressedKey _ scode u = case scode of
ScancodeF1 -> Just <$> (writeSaveSlot (SaveSlotNum 1) u >> return u) ScancodeF1 -> Just <$> (writeSaveSlot (SaveSlotNum 1) u >> return u)
@@ -107,7 +107,7 @@ handlePressedKeyTerminal tmid scode w = case scode of
ScancodeReturn -> w & terminalReturnEffect (w ^?! cWorld . terminals . ix tmid) ScancodeReturn -> w & terminalReturnEffect (w ^?! cWorld . terminals . ix tmid)
ScancodeBackspace -> w ScancodeBackspace -> w
& cWorld . terminals . ix tmid . tmInput . tiText %~ doBackspace & cWorld . terminals . ix tmid . tmInput . tiText %~ doBackspace
& cWorld . backspaceTimer .~ 5 & backspaceTimer .~ 5
_ -> w _ -> w
where where
doBackspace t = case T.unsnoc t of doBackspace t = case T.unsnoc t of
+31 -3
View File
@@ -35,7 +35,14 @@ useMod hm = case hm of
[ ammoCheckI [ ammoCheckI
, useTimeCheck , useTimeCheck
, lockInvFor 10 , lockInvFor 10
, repeatOnFrames [1..9] , repeatOnFrames [1..9] FlameSpitterRepeatMod
, withRandomItemParams f
, useAmmoAmount 1
, withSidePushI 5
, withSidePushAfterI 20
]
FlameSpitterRepeatMod ->
[ ammoCheckI
, withRandomItemParams f , withRandomItemParams f
, useAmmoAmount 1 , useAmmoAmount 1
, withSidePushI 5 , withSidePushI 5
@@ -239,7 +246,16 @@ useMod hm = case hm of
, useTimeCheck , useTimeCheck
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2) , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, lockInvFor 7 , lockInvFor 7
, \f' it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [3,6]) f' it , repeatOnFrames [3,6] BurstRifleRepeatMod
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI
, withRecoil
]
BurstRifleRepeatMod ->
[ ammoCheckI
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, withSoundStart tap3S , withSoundStart tap3S
, useAmmoAmount 1 , useAmmoAmount 1
, applyInaccuracy , applyInaccuracy
@@ -278,7 +294,19 @@ useMod hm = case hm of
-- rather than locking the inventory, a better solution may be to check -- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames -- that the weapon is still in your hands in the repeated frames
, lockInvFor 10 , lockInvFor 10
, \f' it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [2,4,6,8,10]) f' it , repeatOnFrames [2,4,6,8,10] RevolverXRepeatMod
, withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
, withMuzFlareI
-- , spreadLoaded
, withTorqueAfter
, withRecoil
]
RevolverXRepeatMod ->
[ ammoCheckI
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, withSoundStart tap3S , withSoundStart tap3S
, useAmmoUpTo 1 , useAmmoUpTo 1
, applyInaccuracy , applyInaccuracy
+19 -19
View File
@@ -185,17 +185,17 @@ updateCloseObjects w = w
updateRBList :: World -> World updateRBList :: World -> World
updateRBList w updateRBList w
| w ^? cWorld . rbOptions . opCurInvPos == Just curinvid | w ^? rbOptions . opCurInvPos == Just curinvid
= w & setEquipAllocation & setEquipActivation = w & setEquipAllocation & setEquipActivation
| otherwise = case cr ^? crInv . ix curinvid . itUse . eqEq . eqSite of | otherwise = case cr ^? crInv . ix curinvid . itUse . eqEq . eqSite of
Just esite -> w Just esite -> w
& cWorld . rbOptions .~ EquipOptions (equipSiteToPositions esite) & rbOptions .~ EquipOptions (equipSiteToPositions esite)
(chooseEquipmentPosition cr (equipSiteToPositions esite)) (chooseEquipmentPosition cr (equipSiteToPositions esite))
curinvid curinvid
DoNotMoveEquipment DoNotMoveEquipment
NoChangeActivateEquipment NoChangeActivateEquipment
& setEquipAllocation & setEquipActivation & setEquipAllocation & setEquipActivation
Nothing -> w & cWorld . rbOptions .~ NoRightButtonOptions Nothing -> w & rbOptions .~ NoRightButtonOptions
-- | otherwise = w & rbOptions .~ NoRightButtonOptions -- | otherwise = w & rbOptions .~ NoRightButtonOptions
where where
curinvid = crSel cr curinvid = crSel cr
@@ -212,53 +212,53 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
setEquipAllocation :: World -> World setEquipAllocation :: World -> World
setEquipAllocation w = case _rbOptions (_cWorld w) of setEquipAllocation w = case _rbOptions w of
EquipOptions {_opEquip = es,_opSel=i} -> EquipOptions {_opEquip = es,_opSel=i} ->
case you w ^? crInvEquipped . ix (crSel (you w)) of case you w ^? crInvEquipped . ix (crSel (you w)) of
Just epos | es !! i == epos Just epos | es !! i == epos
-> w & cWorld . rbOptions . opAllocateEquipment .~ RemoveEquipment -> w & rbOptions . opAllocateEquipment .~ RemoveEquipment
{_allocOldPos = epos} {_allocOldPos = epos}
Just epos | isJust (you w ^? crEquipment . ix (es !! i)) Just epos | isJust (you w ^? crEquipment . ix (es !! i))
-> w & cWorld . rbOptions . opAllocateEquipment .~ SwapEquipment -> w & rbOptions . opAllocateEquipment .~ SwapEquipment
{_allocOldPos = epos {_allocOldPos = epos
,_allocNewPos = es !! i ,_allocNewPos = es !! i
,_allocSwapID = _crEquipment (you w) M.! (es !! i) ,_allocSwapID = _crEquipment (you w) M.! (es !! i)
} }
Just epos -> w & cWorld . rbOptions . opAllocateEquipment .~ MoveEquipment Just epos -> w & rbOptions . opAllocateEquipment .~ MoveEquipment
{_allocOldPos = epos {_allocOldPos = epos
,_allocNewPos = es !! i ,_allocNewPos = es !! i
} }
Nothing | isJust (you w ^? crEquipment . ix (es !! i)) Nothing | isJust (you w ^? crEquipment . ix (es !! i))
-> w & cWorld . rbOptions . opAllocateEquipment .~ ReplaceEquipment -> w & rbOptions . opAllocateEquipment .~ ReplaceEquipment
{_allocNewPos = es !! i {_allocNewPos = es !! i
,_allocRemoveID = _crEquipment (you w) M.! (es !! i) ,_allocRemoveID = _crEquipment (you w) M.! (es !! i)
} }
Nothing -> w & cWorld . rbOptions . opAllocateEquipment .~ PutOnEquipment Nothing -> w & rbOptions . opAllocateEquipment .~ PutOnEquipment
{_allocNewPos = es !! i} {_allocNewPos = es !! i}
_ -> w _ -> w
-- where -- where
-- curpos = invSelPos w -- curpos = invSelPos w
setEquipActivation :: World -> World setEquipActivation :: World -> World
setEquipActivation w = case w ^? cWorld . rbOptions . opAllocateEquipment of setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
Just DoNotMoveEquipment -> w Just DoNotMoveEquipment -> w
Just RemoveEquipment { } Just RemoveEquipment { }
-> case _crLeftInvSel (you w) of -> case _crLeftInvSel (you w) of
Just i | i == invsel -> w & cWorld . rbOptions . opActivateEquipment .~ DeactivateEquipment Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ DeactivateEquipment
{_deactivateEquipment = i} {_deactivateEquipment = i}
_ -> w & cWorld . rbOptions . opActivateEquipment .~ NoChangeActivateEquipment _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Just rbos Just rbos
-> case _crLeftInvSel (you w) of -> case _crLeftInvSel (you w) of
Just i | i == invsel -> w & cWorld . rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Just i | invselcanactivate -> w & cWorld . rbOptions . opActivateEquipment .~ ActivateDeactivateEquipment Just i | invselcanactivate -> w & rbOptions . opActivateEquipment .~ ActivateDeactivateEquipment
{_activateEquipment = invsel,_deactivateEquipment = i} {_activateEquipment = invsel,_deactivateEquipment = i}
Just i | Just i == rbos ^? allocRemoveID Just i | Just i == rbos ^? allocRemoveID
-> w & cWorld . rbOptions . opActivateEquipment .~ DeactivateEquipment i -> w & rbOptions . opActivateEquipment .~ DeactivateEquipment i
Just _ -> w & cWorld . rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Just _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Nothing | invselcanactivate -> w & cWorld . rbOptions . opActivateEquipment .~ ActivateEquipment Nothing | invselcanactivate -> w & rbOptions . opActivateEquipment .~ ActivateEquipment
{_activateEquipment = invsel} {_activateEquipment = invsel}
Nothing -> w & cWorld . rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Nothing -> w & cWorld . rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
where where
invsel = crSel (you w) invsel = crSel (you w)
invselcanactivate = isJust (you w ^? crInv . ix invsel . itUse . lUse) invselcanactivate = isJust (you w ^? crInv . ix invsel . itUse . lUse)
-1
View File
@@ -39,7 +39,6 @@ rewindEffect itm cr w
maxcharge = _wpMaxCharge . _itConsumption $ itm maxcharge = _wpMaxCharge . _itConsumption $ itm
cw = _cWorld w cw = _cWorld w
& rewindWorlds .~ [] & rewindWorlds .~ []
& timeFlow .~ NormalTimeFlow
resetAttachmentEffect :: Item -> Creature -> World -> World resetAttachmentEffect :: Item -> Creature -> World -> World
resetAttachmentEffect itm cr w resetAttachmentEffect itm cr w
+143 -158
View File
@@ -1,173 +1,158 @@
module Dodge.Item.Weapon.BulletGun.Cane module Dodge.Item.Weapon.BulletGun.Cane (
( volleyGun volleyGun,
, repeater repeater,
, rifle rifle,
, autoRifle autoRifle,
, burstRifle burstRifle,
, miniGunX miniGunX,
) where ) where
import Dodge.Reloading.Action
import Dodge.Data import Dodge.Data
import Dodge.Default.Weapon
import Dodge.Default import Dodge.Default
import Dodge.Reloading.Action
import Geometry import Geometry
import LensHelp import LensHelp
defaultBangCane :: Item defaultBangCane :: Item
defaultBangCane = defaultBulletWeapon defaultBangCane =
& itParams .~ BulletShooter defaultBulletWeapon
{ _muzVel = 0.8 & itParams
, _rifling = 0.9 .~ BulletShooter
, _bore = 2 { _muzVel = 0.8
, _gunBarrels = SingleBarrel , _rifling = 0.9
{ _brlInaccuracy = 0.01 , _bore = 2
} , _gunBarrels =
, _recoil = 50 SingleBarrel
, _torqueAfter = 0.1 { _brlInaccuracy = 0.01
, _randomOffset = 0 }
} , _recoil = 50
& itDimension . dimRad .~ 8 , _torqueAfter = 0.1
& itDimension . dimCenter .~ V3 5 0 0 , _randomOffset = 0
& itUse . useDelay . rateMax .~ 6 }
& itUse . useMods .~ BangCaneMod & itDimension . dimRad .~ 8
& itUse . useAim . aimStance .~ OneHand & itDimension . dimCenter .~ V3 5 0 0
& itUse . useAim . aimHandlePos .~ 5 & itUse . useDelay . rateMax .~ 6
& itUse . useAim . aimMuzPos .~ 15 & itUse . useMods .~ BangCaneMod
& itType . iyBase .~ error "undefined bangCane baseitemtype" & itUse . useAim . aimStance .~ OneHand
& itConsumption . laMax .~ 1 & itUse . useAim . aimHandlePos .~ 5
& itConsumption . laCycle .~ [loadPartialInsert 10 1] & itUse . useAim . aimMuzPos .~ 15
volleyGun :: Int -> Item & itType . iyBase .~ error "undefined bangCane baseitemtype"
volleyGun i = defaultBangCane & itConsumption . laMax .~ 1
& itUse . useDelay . rateMax .~ 6 & itConsumption . laCycle .~ [loadPartialInsert 10 1]
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itConsumption . laMax .~ i
& itParams .~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels = SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels .~ MultiBarrel
{_brlSpread = AlignedBarrels
,_brlNum = i
,_brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle = defaultBangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadEject 5, loadInsert 5 ,loadPrime 5]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
-- & itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
& itUse . useAim . aimZoom .~ defaultItZoom {_itZoomFac = 2}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
repeater = rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER
& itConsumption . laCycle .~ [loadEject 20, loadInsert 20 ,loadPrime 20]
& itConsumption . laMax .~ 15
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
& itUse . useDelay . rateMax .~ 6
& itUse . useMods .~ VolleyGunMod
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimStance .~ TwoHandFlat
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
& itUse . useAim . aimHandlePos .~ 5
& itUse . useAim . aimMuzPos .~ 15
& itConsumption . laMax .~ i
& itParams
.~ BulletShooter
{ _muzVel = 0.8
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
SingleBarrel
{ _brlInaccuracy = 0.01
}
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
}
& itParams . gunBarrels
.~ MultiBarrel
{ _brlSpread = AlignedBarrels
, _brlNum = i
, _brlInaccuracy = 0.1
}
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
rifle :: Item
rifle =
defaultBangCane
& itUse . useAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE
& itConsumption . laMax .~ 1
& itConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . useAim . aimWeight .~ 6
& itUse . useAim . aimRange .~ 1
& itUse . useAim . aimZoom .~ defaultItZoom{_itZoomFac = 2}
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
repeater :: Item
repeater =
rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER
& itConsumption . laCycle .~ [loadEject 20, loadInsert 20, loadPrime 20]
& itConsumption . laMax .~ 15
autoRifle :: Item autoRifle :: Item
autoRifle = repeater autoRifle =
& itType . iyBase .~ HELD AUTORIFLE repeater
& itUse . useMods .~ AutoRifleMod & itType . iyBase .~ HELD AUTORIFLE
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE & itUse . useMods .~ AutoRifleMod
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
-- & itUse . useDelay . rateMax .~ 6 -- & itUse . useDelay . rateMax .~ 6
burstRifle :: Item burstRifle :: Item
burstRifle = repeater burstRifle =
& itType . iyBase .~ HELD BURSTRIFLE repeater
& itParams . gunBarrels . brlInaccuracy .~ 0.05 & itType . iyBase .~ HELD BURSTRIFLE
& itUse . useDelay . rateMax .~ 18 & itParams . gunBarrels . brlInaccuracy .~ 0.05
& itUse . useMods .~ BurstRifleMod & itUse . useDelay . rateMax .~ 18
--fastBurstRifle :: Item & itUse . useMods .~ BurstRifleMod
--fastBurstRifle = repeater
-- & itType . iyBase .~ FASTBURSTRIFLE
-- & itParams . gunBarrels . brlInaccuracy .~ 0.06
-- & itUse . useDelay . rateMax .~ 18
-- & itUse . useMods .~
-- [ ammoHammerCheck
-- , useTimeCheck
-- , sideEffectOnFrame 9 (torqueSideEffect 0.4)
-- , lockInvFor 9
-- , \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [2,4,6,8]) f it
-- , withSoundStart tap3S
-- , useAmmoAmount 1
-- , applyInaccuracy
-- , withMuzFlareI
-- , withRecoil
-- ]
--completeBurstRifle :: Item
--completeBurstRifle = repeater
-- & itType . iyBase .~ COMPLETEBURSTRIFLE
-- & itType . iyModules . at ModRifleMag .~ Nothing
-- & itParams . gunBarrels . brlInaccuracy .~ 0.1
-- & itUse . useDelay . rateMax .~ 28
-- & itUse . useMods .~
-- [ ammoHammerCheck
-- , useTimeCheck
-- , sideEffectOnFrame 15 (torqueSideEffect 0.8)
-- , lockInvFor 15
-- , \f it -> repeatOnFrames (take (_laLoaded (_itConsumption it) - 1) [1..14]) f it
-- , withSoundStart tap3S
-- , useAmmoAmount 1
-- , applyInaccuracy
-- , withMuzFlareI
-- , withRecoil
-- ]
miniGunUse :: Int -> ItemUse miniGunUse :: Int -> ItemUse
miniGunUse i = defaultrUse miniGunUse i =
& rUse .~ HeldUseAmmoParams defaultrUse
& useDelay .~ NoDelay & rUse .~ HeldUseAmmoParams
& useMods .~ MiniGunMod i & useDelay .~ NoDelay
& useMods .~ MiniGunMod i
miniGunX :: Int -> Item miniGunX :: Int -> Item
miniGunX i = defaultAutoGun miniGunX i =
{ _itConsumption = defaultBulletLoadable defaultAutoGun
{ _laMax = 1500 { _itConsumption =
, _laLoaded = 1500 defaultBulletLoadable
{ _laMax = 1500
, _laLoaded = 1500
}
& laCycle .~ [loadEject 40, loadInsert 40, loadPrime 40]
, _itUse =
miniGunUse i
& useDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100}
& useAim . aimWeight .~ 6
& useAim . aimRange .~ 1
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom{_itZoomFac = 1.5}
, -- , _itFloorPict = miniGunPictItem
_itParams =
BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels =
MultiBarrel
{ _brlSpread = RotatingBarrels 0.01
, _brlNum = i
, _brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
, _itInvSize = 4
} }
& laCycle .~ [loadEject 40, loadInsert 40 ,loadPrime 40] & itDimension . dimRad .~ 20
, _itUse = miniGunUse i & itDimension . dimCenter .~ V3 5 0 0
& useDelay .~ WarmUpNoDelay {_warmTime = 0,_warmMax = 100} & itDimension . dimAttachPos .~ V3 5 (-5) 0
& useAim . aimWeight .~ 6 & itType . iyBase .~ HELD (MINIGUNX i)
& useAim . aimRange .~ 1 & itUse . useAim . aimMuzPos .~ 40
& useAim . aimStance .~ TwoHandTwist
& useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1.5}
-- , _itFloorPict = miniGunPictItem
, _itParams = BulletShooter
{ _muzVel = 1
, _rifling = 0.9
, _bore = 2
, _gunBarrels = MultiBarrel
{_brlSpread = RotatingBarrels 0.01
,_brlNum = i
,_brlInaccuracy = 0
}
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
, _itInvSize = 4
}
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType . iyBase .~ HELD (MINIGUNX i)
& itUse . useAim . aimMuzPos .~ 40
+6 -6
View File
@@ -1,4 +1,4 @@
--{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
{- | {- |
Weapon effects when pulling the trigger. -} Weapon effects when pulling the trigger. -}
module Dodge.Item.Weapon.TriggerType module Dodge.Item.Weapon.TriggerType
@@ -558,12 +558,12 @@ torqueSideEffect torque _ cr w
(rot, g) = randomR (-torque,torque) $ _randGen w (rot, g) = randomR (-torque,torque) $ _randGen w
-- pump the updated creature into the chain in later frames -- pump the updated creature into the chain in later frames
repeatOnFrames :: [Int] -> ChainEffect repeatOnFrames :: [Int] -> HeldMod -> ChainEffect
repeatOnFrames = const id --repeatOnFrames is hm f it cr w = f it cr w
--repeatOnFrames is f it cr w = f it cr w repeatOnFrames is hm f it cr w = f it cr $ w
-- & delayedEvents .++~ (is <&> (, f')) & cWorld . delayedEvents .++~ (is <&> (, WdWdFromItCrixWdWd (it & itUse . useMods .~ hm) (_crID cr) ItCrWdItemEffect))
-- where -- where
-- f' w' = fromMaybe w' $ do -- f' = fromMaybe w' $ do
-- cr' <- w' ^? creatures . ix (_crID cr) -- cr' <- w' ^? creatures . ix (_crID cr)
-- return $ f it cr' w' -- return $ f it cr' w'
+3 -3
View File
@@ -141,7 +141,7 @@ subInventoryDisplay subinv cfig w = case subinv of
equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr) equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr)
f col invid epos = listTextPictureAt 144 0 cfig (selNumPos invid w) . color col $ text $ eqPosText epos f col invid epos = listTextPictureAt 144 0 cfig (selNumPos invid w) . color col $ text $ eqPosText epos
rboptions = if ButtonRight `M.member` _mouseButtons w rboptions = if ButtonRight `M.member` _mouseButtons w
then drawRBOptions cfig w (_rbOptions (_cWorld w)) then drawRBOptions cfig w (_rbOptions w)
else mempty else mempty
itmInfo :: Maybe Item -> [String] itmInfo :: Maybe Item -> [String]
@@ -187,7 +187,7 @@ drawRBOptions cfig w EquipOptions{_opEquip = es,_opSel=i, _opAllocateEquipment=a
where where
midtext str = listTextPictureAt 252 0 cfig curpos (text str) midtext str = listTextPictureAt 252 0 cfig curpos (text str)
extratext str = listTextPictureAt 432 0 cfig curpos (text (str ++ deactivatetext)) extratext str = listTextPictureAt 432 0 cfig curpos (text (str ++ deactivatetext))
deactivatetext = case w ^? cWorld . rbOptions . opActivateEquipment . deactivateEquipment of deactivatetext = case w ^? rbOptions . opActivateEquipment . deactivateEquipment of
Just k -> " DEACTIVATES " ++ show (_iyBase $ _itType (_crInv (you w) IM.! k)) Just k -> " DEACTIVATES " ++ show (_iyBase $ _itType (_crInv (you w) IM.! k))
Nothing -> "" Nothing -> ""
curpos = invSelPos w curpos = invSelPos w
@@ -255,7 +255,7 @@ topCursorTypeWidth ctype width cfig w i
= ctype 0 0 cfig (selNumPos i w) (selNumCol i w) width (selNumSlots i w) = ctype 0 0 cfig (selNumPos i w) (selNumCol i w) width (selNumSlots i w)
determineInvSelCursorWidth :: World -> Int determineInvSelCursorWidth :: World -> Int
determineInvSelCursorWidth w = case _rbOptions (_cWorld w) of determineInvSelCursorWidth w = case _rbOptions w of
NoRightButtonOptions -> topInvW NoRightButtonOptions -> topInvW
EquipOptions {} -> if ButtonRight `M.member` _mouseButtons w EquipOptions {} -> if ButtonRight `M.member` _mouseButtons w
then 47 then 47
+6 -6
View File
@@ -207,22 +207,22 @@ drawPathBetween w = setLayer DebugLayer
where where
nodepos = (`getNodePos` w) nodepos = (`getNodePos` w)
nodelist = makePathBetween sp ep w nodelist = makePathBetween sp ep w
sp = _lSelect (_cWorld w) sp = _lSelect w
ep = _rSelect (_cWorld w) ep = _rSelect w
drawNodesNearSelect :: World -> Picture drawNodesNearSelect :: World -> Picture
drawNodesNearSelect w = setLayer DebugLayer drawNodesNearSelect w = setLayer DebugLayer
$ runIdentity (S.foldMap_ (drawZoneCol orange pnZoneSize) (zoneAroundPoint pnZoneSize sp)) $ runIdentity (S.foldMap_ (drawZoneCol orange pnZoneSize) (zoneAroundPoint pnZoneSize sp))
<> color green (drawCross sp) <> color green (drawCross sp)
where where
sp = _lSelect (_cWorld w) sp = _lSelect w
drawInspectWalls :: World -> Picture drawInspectWalls :: World -> Picture
drawInspectWalls w = foldMap (drawInspectWall w) drawInspectWalls w = foldMap (drawInspectWall w)
$ filter (isJust . uncurry (intersectSegSeg a b) . _wlLine) $ filter (isJust . uncurry (intersectSegSeg a b) . _wlLine)
$ IM.elems $ _walls (_cWorld w) $ IM.elems $ _walls (_cWorld w)
where where
(a,b) = _lLine (_cWorld w) (a,b) = _lLine w
drawInspectWall :: World -> Wall -> Picture drawInspectWall :: World -> Wall -> Picture
drawInspectWall w wl = setLayer DebugLayer drawInspectWall w wl = setLayer DebugLayer
@@ -252,8 +252,8 @@ drawWorldSelect w = setLayer DebugLayer
$ color cyan (line [a,b]) $ color cyan (line [a,b])
<> color magenta (line [c,d]) <> color magenta (line [c,d])
where where
(a,b) = _lLine (_cWorld w) (a,b) = _lLine w
(c,d) = _rLine (_cWorld w) (c,d) = _rLine w
drawFarWallDetect :: World -> Picture drawFarWallDetect :: World -> Picture
drawFarWallDetect w = setLayer DebugLayer drawFarWallDetect w = setLayer DebugLayer
+255 -219
View File
@@ -1,165 +1,175 @@
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
{- | {- |
Module : Dodge.Update Module : Dodge.Update
Description : Simulation update Description : Simulation update
-} -}
module Dodge.Update ( updateUniverse ) where module Dodge.Update (updateUniverse) where
import Dodge.Magnet.Update
import Dodge.TmTm
import Color import Color
import Dodge.DrWdWd --import Dodge.Zone
import Dodge.TractorBeam.Update
import Dodge.Prop.Update import Control.Applicative
import Dodge.LinearShockwave.Update import Data.List
import Dodge.Shockwave.Update import qualified Data.Map.Strict as M
import Dodge.Tesla.Arc import Data.Maybe
import Dodge.Laser.Update import Dodge.Base
import Dodge.PressPlate
import Dodge.ModificationEffect
import Dodge.CrGroupUpdate
import Dodge.Zoning.Cloud
import Dodge.Zoning.Creature
import Dodge.WorldEffect
import Dodge.Data
import Dodge.Beam import Dodge.Beam
import Dodge.LightSource.Update import Dodge.Bullet
import Dodge.Projectile.Update import Dodge.CrGroupUpdate
import Dodge.Creature.Update import Dodge.Creature.Update
import Dodge.RadarSweep import Dodge.CullBox
import Dodge.PosEvent import Dodge.Data
import Dodge.Spark import Dodge.Distortion
import Dodge.DrWdWd
import Dodge.EnergyBall import Dodge.EnergyBall
import Dodge.Flame import Dodge.Flame
import Dodge.Bullet
import Dodge.Update.Cloud
import Dodge.Machine.Update
import Dodge.RadarBlip
import Dodge.Flare import Dodge.Flare
import Dodge.Menu
import Dodge.CullBox
import Dodge.Distortion
import Dodge.SoundLogic
import Dodge.Update.WallDamage
import Dodge.Base
--import Dodge.Zone
import Dodge.Hammer import Dodge.Hammer
import Dodge.WallCreatureCollisions
import Dodge.Update.Camera
import Dodge.Inventory import Dodge.Inventory
import Sound.Data import Dodge.Laser.Update
import Dodge.LightSource.Update
import Dodge.LinearShockwave.Update
import Dodge.Machine.Update
import Dodge.Magnet.Update
import Dodge.Menu
import Dodge.ModificationEffect
import Dodge.PosEvent
import Dodge.PressPlate
import Dodge.Projectile.Update
import Dodge.Prop.Update
import Dodge.RadarBlip
import Dodge.RadarSweep
import Dodge.Shockwave.Update
import Dodge.SoundLogic
import Dodge.Spark
import Dodge.Tesla.Arc
import Dodge.TmTm
import Dodge.TractorBeam.Update
import Dodge.Update.Camera
import Dodge.Update.Cloud
import Dodge.Update.WallDamage
import Dodge.WallCreatureCollisions
import Dodge.WorldEffect
import Dodge.Zoning.Cloud
import Dodge.Zoning.Creature
import Geometry import Geometry
import LensHelp
import FoldableHelp
import Data.List
import Data.Maybe
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M import LensHelp
import Control.Applicative
--import qualified Streaming.Prelude as S --import qualified Streaming.Prelude as S
import SDL import SDL
import Sound.Data
{- For most menus the only way to change the world is using event handling. -} {- For most menus the only way to change the world is using event handling. -}
updateUniverse :: Universe -> Universe updateUniverse :: Universe -> Universe
updateUniverse u = case _menuLayers u of updateUniverse u = case _menuLayers u of
(WaitScreen s i : _) (WaitScreen s i : _)
| i < 1 -> u & over uvWorld doWorldEvents | i < 1 -> u & over uvWorld doWorldEvents
| otherwise -> u & menuLayers %~ ( (WaitScreen s (i-1) :) . tail ) | otherwise -> u & menuLayers %~ ((WaitScreen s (i -1) :) . tail)
(OptionScreen {_scOptionFlag = GameOverOptions} : _) -> u & uvWorld %~ (OptionScreen{_scOptionFlag = GameOverOptions} : _) ->
( --updateParticles u & uvWorld
(cWorld . radarBlips .~ []) %~ (
-- . updateIMl _props _pjUpdate --updateParticles
. updateLightSources (cWorld . radarBlips .~ [])
. updateClouds ) -- . updateIMl _props _pjUpdate
. updateLightSources
. updateClouds
)
(_ : _) -> u (_ : _) -> u
[] -> functionalUpdate u [] -> functionalUpdate u
{- | The update step. -} -- | The update step.
functionalUpdate :: Universe -> Universe functionalUpdate :: Universe -> Universe
functionalUpdate w = checkEndGame functionalUpdate w =
-- . updateRandGen checkEndGame
. over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held -- . updateRandGen
. over uvWorld (cWorld . worldClock +~ 1) . over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held
. over uvWorld updateWorldSelect . over uvWorld (cWorld . worldClock +~ 1)
. over uvWorld doRewind . over uvWorld updateWorldSelect
. over uvWorld (hammers . each %~ moveHammerUp) . over uvWorld doRewind
. over uvWorld updateDistortions . over uvWorld (hammers . each %~ moveHammerUp)
. over uvWorld updateCreatureSoundPositions . over uvWorld updateDistortions
. over uvWorld ppEvents . over uvWorld updateCreatureSoundPositions
. updateCamera . over uvWorld ppEvents
. colCrsWalls . updateCamera
. over uvWorld simpleCrSprings . colCrsWalls
. over uvWorld zoneCreatures . over uvWorld simpleCrSprings
. over uvWorld (updateIMl (_doors . _cWorld) (doDrWdWd . _drMech) ) . over uvWorld zoneCreatures
. over uvWorld doWorldEvents . over uvWorld (updateIMl (_doors . _cWorld) (doDrWdWd . _drMech))
. over uvWorld updateDelayedEvents . over uvWorld doWorldEvents
. over uvWorld (updateIMl (_modifications. _cWorld) (doModificationEffect . _mdUpdate) ) . over uvWorld updateDelayedEvents
. over uvWorld updateSparks . over uvWorld (updateIMl (_modifications . _cWorld) (doModificationEffect . _mdUpdate))
. over uvWorld updateRadarSweeps . over uvWorld updateSparks
. over uvWorld updatePosEvents . over uvWorld updateRadarSweeps
. over uvWorld updateFlames . over uvWorld updatePosEvents
. over uvWorld updateShockwaves . over uvWorld updateFlames
. over uvWorld updateEnergyBalls . over uvWorld updateShockwaves
-- . over uvWorld updateParticles . over uvWorld updateEnergyBalls
. over uvWorld updateBullets -- . over uvWorld updateParticles
. over uvWorld updateRadarBlips . over uvWorld updateBullets
. over uvWorld updateFlares . over uvWorld updateRadarBlips
. over uvWorld updateBeams . over uvWorld updateFlares
. over uvWorld updateLasers . over uvWorld updateBeams
. over uvWorld updateTeslaArcs . over uvWorld updateLasers
. over uvWorld updateTractorBeams . over uvWorld updateTeslaArcs
. over uvWorld (updateIMl' (_linearShockwaves . _cWorld) updateLinearShockwave) . over uvWorld updateTractorBeams
. over uvWorld (updateIMl' (_props . _cWorld) updateProp ) . over uvWorld (updateIMl' (_linearShockwaves . _cWorld) updateLinearShockwave)
. over uvWorld (updateIMl' (_projectiles . _cWorld) updateProjectile) . over uvWorld (updateIMl' (_props . _cWorld) updateProp)
. over uvWorld updateLightSources . over uvWorld (updateIMl' (_projectiles . _cWorld) updateProjectile)
. over uvWorld updateClouds . over uvWorld updateLightSources
. over uvWorld updateGusts . over uvWorld updateClouds
. over uvWorld zoneClouds . over uvWorld updateGusts
. over uvWorld (updateMIM (cWorld . magnets) (doMagnetUpdate . _mgUpdate) ) . over uvWorld zoneClouds
. over uvWorld (updateIMl' (_terminals . _cWorld) tmUpdate ) . over uvWorld (updateMIM (cWorld . magnets) (doMagnetUpdate . _mgUpdate))
-- . updateIMl _machines mcChooseUpdate . over uvWorld (updateIMl' (_terminals . _cWorld) tmUpdate)
. over uvWorld (updateIMl' (_machines . _cWorld) updateMachine ) -- . updateIMl _machines mcChooseUpdate
. over uvWorld (updateIMl' (_creatures . _cWorld) updateCreature ) . over uvWorld (updateIMl' (_machines . _cWorld) updateMachine)
. over uvWorld (updateIMl' (_creatures . _cWorld) updateCreature)
-- creatures should be updated early so that crOldPos is set before any position change -- creatures should be updated early so that crOldPos is set before any position change
. over (uvWorld . cWorld . creatures) (fmap setOldPos) . over (uvWorld . cWorld . creatures) (fmap setOldPos)
. over uvWorld updateCreatureGroups . over uvWorld updateCreatureGroups
. over uvWorld updateWallDamages . over uvWorld updateWallDamages
. over uvWorld updateSeenWalls . over uvWorld updateSeenWalls
. over uvWorld updateTerminal . over uvWorld updateTerminal
. over uvWorld updateRBList . over uvWorld updateRBList
. updateBounds -- where should this go? next to update camera? . updateBounds -- where should this go? next to update camera?
$ over uvWorld updateCloseObjects w $ over uvWorld updateCloseObjects w
doWorldEvents :: World -> World doWorldEvents :: World -> World
doWorldEvents w = foldr doWorldEffect (w & cWorld . worldEvents .~ []) (_worldEvents (_cWorld w)) doWorldEvents w = foldr doWdWd (w & cWorld . worldEvents .~ []) (_worldEvents (_cWorld w))
updateLasers :: World -> World updateLasers :: World -> World
updateLasers w = w' updateLasers w =
& cWorld . lasers .~ [] w'
& cWorld . lasersToDraw .~ ls & cWorld . lasers .~ []
& cWorld . lasersToDraw .~ ls
where where
(w',ls) = mapAccumR updateLaser w (_lasers (_cWorld w)) (w', ls) = mapAccumR updateLaser w (_lasers (_cWorld w))
zoneClouds :: World -> World zoneClouds :: World -> World
zoneClouds w = w zoneClouds w =
& cWorld . clZoning .~ mempty w
& cWorld . clZoning %~ \zn -> & cWorld . clZoning .~ mempty
foldl' (flip zoneCloud) zn (_clouds (_cWorld w)) & cWorld . clZoning %~ \zn ->
--runIdentity (S.fold_ (flip $ updateZoning (:)) (zn & znObjects .~ mempty) id (_clouds w)) foldl' (flip zoneCloud) zn (_clouds (_cWorld w))
--runIdentity (S.fold_ (flip $ updateZoning (:)) (zn & znObjects .~ mempty) id (_clouds w))
updateWorldSelect :: World -> World updateWorldSelect :: World -> World
updateWorldSelect w = f . g $ case (w ^? mouseButtons . ix ButtonLeft, w ^? mouseButtons . ix ButtonRight) of updateWorldSelect w = f . g $ case (w ^? mouseButtons . ix ButtonLeft, w ^? mouseButtons . ix ButtonRight) of
(Nothing ,Nothing) -> w (Nothing, Nothing) -> w
(Just False,Nothing) -> w & cWorld . lLine . _1 .~ mwp (Just False, Nothing) -> w & lLine . _1 .~ mwp
(Just True ,Nothing) -> w & cWorld . lLine . _2 .~ mwp (Just True, Nothing) -> w & lLine . _2 .~ mwp
(Nothing ,_) -> w (Nothing, _) -> w
(Just False,_) -> w & cWorld . rLine . _1 .~ mwp (Just False, _) -> w & rLine . _1 .~ mwp
(Just True ,_) -> w & cWorld . rLine . _2 .~ mwp (Just True, _) -> w & rLine . _2 .~ mwp
where where
mwp = mouseWorldPos w mwp = mouseWorldPos w
f | ButtonLeft `M.member` _mouseButtons w = cWorld . lSelect .~ mwp f
| ButtonLeft `M.member` _mouseButtons w = lSelect .~ mwp
| otherwise = id | otherwise = id
g | ButtonRight `M.member` _mouseButtons w = cWorld . rSelect .~ mwp g
| ButtonRight `M.member` _mouseButtons w = rSelect .~ mwp
| otherwise = id | otherwise = id
--mcChooseUpdate :: Machine -> Machine -> World -> World --mcChooseUpdate :: Machine -> Machine -> World -> World
@@ -167,31 +177,35 @@ updateWorldSelect w = f . g $ case (w ^? mouseButtons . ix ButtonLeft, w ^? mous
-- | _mcHP mc > 0 = _mcUpdate mc mc' -- | _mcHP mc > 0 = _mcUpdate mc mc'
-- | otherwise = destroyMachine mc -- | otherwise = destroyMachine mc
displayTerminalLineString :: TerminalLineString -> World -> (String,Color) displayTerminalLineString :: TerminalLineString -> World -> (String, Color)
displayTerminalLineString tls = case tls of displayTerminalLineString tls = case tls of
TerminalLineConst str col -> const (str,col) TerminalLineConst str col -> const (str, col)
tmUpdate :: Terminal -> World -> World tmUpdate :: Terminal -> World -> World
tmUpdate tm w = case w ^? cWorld . terminals . ix (_tmID tm) . tmFutureLines . ix 0 of tmUpdate tm w = case w ^? cWorld . terminals . ix (_tmID tm) . tmFutureLines . ix 0 of
Nothing -> w Nothing -> w
Just tl | _tlPause tl > 0 -> w & pointTermParams . tmFutureLines . ix 0 . tlPause -~ 1 Just tl | _tlPause tl > 0 -> w & pointTermParams . tmFutureLines . ix 0 . tlPause -~ 1
Just (TerminalLineDisplay _ f) -> w & pointTermParams %~ Just (TerminalLineDisplay _ f) ->
( ( tmFutureLines %~ tail ) w & pointTermParams
. ( tmDisplayedLines .:~ displayTerminalLineString f w ) %~ ( (tmFutureLines %~ tail)
) . (tmDisplayedLines .:~ displayTerminalLineString f w)
Just (TerminalLineEffect _ eff) -> w )
& pointTermParams . tmFutureLines %~ tail Just (TerminalLineEffect _ eff) ->
& doTmWdWd eff tm w
Just (TerminalLineTerminalEffect _ eff) -> w & pointTermParams . tmFutureLines %~ tail
& pointTermParams . tmFutureLines %~ tail & doTmWdWd eff tm
& pointTermParams %~ doTmTm eff Just (TerminalLineTerminalEffect _ eff) ->
w
& pointTermParams . tmFutureLines %~ tail
& pointTermParams %~ doTmTm eff
where where
pointTermParams = cWorld . terminals . ix (_tmID tm) pointTermParams = cWorld . terminals . ix (_tmID tm)
setOldPos :: Creature -> Creature setOldPos :: Creature -> Creature
setOldPos cr = cr setOldPos cr =
& crOldPos .~ _crPos cr cr
& crOldDir .~ _crDir cr & crOldPos .~ _crPos cr
& crOldDir .~ _crDir cr
-- hack -- hack
--updateRandGen :: World -> World --updateRandGen :: World -> World
@@ -199,25 +213,30 @@ setOldPos cr = cr
doRewind :: World -> World doRewind :: World -> World
doRewind w = case _maybeWorld (_cWorld w) of doRewind w = case _maybeWorld (_cWorld w) of
Just' cw -> w & cWorld .~ (cw & timeFlow .~ RewindingLastFrame) Just' cw ->
Nothing' -> w & cWorld . timeFlow .~ NormalTimeFlow w & cWorld .~ cw
& timeFlow .~ RewindingLastFrame
Nothing' -> w & timeFlow .~ NormalTimeFlow
zoneCreatures :: World -> World zoneCreatures :: World -> World
zoneCreatures w = w zoneCreatures w =
& cWorld . crZoning .~ mempty w
& cWorld . crZoning %~ \zn -> foldl' (flip zoneCreature) zn (_creatures (_cWorld w)) & cWorld . crZoning .~ mempty
& cWorld . crZoning %~ \zn -> foldl' (flip zoneCreature) zn (_creatures (_cWorld w))
-- foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr)) -- foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr))
-- zn (_creatures w) -- zn (_creatures w)
updateCreatureSoundPositions :: World -> World updateCreatureSoundPositions :: World -> World
updateCreatureSoundPositions w = M.foldlWithKey' insertSound w updateCreatureSoundPositions w =
. M.mapMaybeWithKey updateSound M.foldlWithKey' insertSound w
$ _playingSounds w . M.mapMaybeWithKey updateSound
$ _playingSounds w
where where
insertSound w' k s = w' & toPlaySounds %~ M.insertWith (const id) k s insertSound w' k s = w' & toPlaySounds %~ M.insertWith (const id) k s
updateSound (CrMouth cid) s = case w ^? cWorld . creatures . ix cid . crPos of updateSound (CrMouth cid) s = case w ^? cWorld . creatures . ix cid . crPos of
Just p -> Just s {_soundPos = p, _soundAngDist = Just (soundAngle p w,0)} Just p -> Just s{_soundPos = p, _soundAngDist = Just (soundAngle p w, 0)}
Nothing -> Just s {_soundTime = Just 0} Nothing -> Just s{_soundTime = Just 0}
updateSound _ _ = Nothing updateSound _ _ = Nothing
--updateIMr :: (World -> IM.IntMap a) -> (a -> a -> World -> World) -> World -> World --updateIMr :: (World -> IM.IntMap a) -> (a -> a -> World -> World) -> World -> World
@@ -229,8 +248,9 @@ updateIMl' :: (World -> IM.IntMap a) -> (a -> World -> World) -> World -> World
updateIMl' fim fup w = foldl' (flip fup) w (fim w) updateIMl' fim fup w = foldl' (flip fup) w (fim w)
updateCreatureGroups :: World -> World updateCreatureGroups :: World -> World
updateCreatureGroups w = w & cWorld . creatureGroups %~ updateCreatureGroups w =
IM.mapMaybe (\cgp -> doCrGroupUpdate (_crGroupUpdate cgp) w cgp) w & cWorld . creatureGroups
%~ IM.mapMaybe (\cgp -> doCrGroupUpdate (_crGroupUpdate cgp) w cgp)
updateDistortions :: World -> World updateDistortions :: World -> World
updateDistortions = cWorld . distortions %~ mapMaybe updateDistortion updateDistortions = cWorld . distortions %~ mapMaybe updateDistortion
@@ -249,48 +269,48 @@ updateFlares = cWorld . flares %~ mapMaybe updateFlare
updateTeslaArcs :: World -> World updateTeslaArcs :: World -> World
updateTeslaArcs w = w' & cWorld . teslaArcs .~ catMaybes newtas updateTeslaArcs w = w' & cWorld . teslaArcs .~ catMaybes newtas
where where
(w',newtas) = mapAccumR moveTeslaArc w $ _teslaArcs (_cWorld w) (w', newtas) = mapAccumR moveTeslaArc w $ _teslaArcs (_cWorld w)
updateTractorBeams :: World -> World updateTractorBeams :: World -> World
updateTractorBeams w = w' & cWorld . tractorBeams .~ catMaybes newtas updateTractorBeams w = w' & cWorld . tractorBeams .~ catMaybes newtas
where where
(w',newtas) = mapAccumR updateTractorBeam w $ _tractorBeams (_cWorld w) (w', newtas) = mapAccumR updateTractorBeam w $ _tractorBeams (_cWorld w)
{- Apply internal particle updates, delete 'Nothing's. -} {- Apply internal particle updates, delete 'Nothing's. -}
updateBullets :: World -> World updateBullets :: World -> World
updateBullets w = updateInstantBullets $ set (cWorld . bullets) (catMaybes ps) w' updateBullets w = updateInstantBullets $ set (cWorld . bullets) (catMaybes ps) w'
where where
(w',ps) = mapAccumR updateBullet w $ _bullets (_cWorld w) (w', ps) = mapAccumR updateBullet w $ _bullets (_cWorld w)
updateShockwaves :: World -> World updateShockwaves :: World -> World
updateShockwaves w = w' & cWorld . shockwaves .~ catMaybes newflames updateShockwaves w = w' & cWorld . shockwaves .~ catMaybes newflames
where where
(w',newflames) = mapAccumR updateShockwave w $ _shockwaves (_cWorld w) (w', newflames) = mapAccumR updateShockwave w $ _shockwaves (_cWorld w)
updateFlames :: World -> World updateFlames :: World -> World
updateFlames w = w' & cWorld . flames .~ catMaybes newflames updateFlames w = w' & cWorld . flames .~ catMaybes newflames
where where
(w',newflames) = mapAccumR moveFlame w $ _flames (_cWorld w) (w', newflames) = mapAccumR moveFlame w $ _flames (_cWorld w)
updateEnergyBalls :: World -> World updateEnergyBalls :: World -> World
updateEnergyBalls w = w' & cWorld . energyBalls .~ catMaybes newebs updateEnergyBalls w = w' & cWorld . energyBalls .~ catMaybes newebs
where where
(w',newebs) = mapAccumR moveEnergyBall w $ _energyBalls (_cWorld w) (w', newebs) = mapAccumR moveEnergyBall w $ _energyBalls (_cWorld w)
updateRadarSweeps :: World -> World updateRadarSweeps :: World -> World
updateRadarSweeps w = w' & cWorld . radarSweeps .~ catMaybes newradarSweeps updateRadarSweeps w = w' & cWorld . radarSweeps .~ catMaybes newradarSweeps
where where
(w',newradarSweeps) = mapAccumR updateRadarSweep w $ _radarSweeps (_cWorld w) (w', newradarSweeps) = mapAccumR updateRadarSweep w $ _radarSweeps (_cWorld w)
updateSparks :: World -> World updateSparks :: World -> World
updateSparks w = w' & cWorld . sparks .~ catMaybes newsparks updateSparks w = w' & cWorld . sparks .~ catMaybes newsparks
where where
(w',newsparks) = mapAccumR moveSpark w $ _sparks (_cWorld w) (w', newsparks) = mapAccumR moveSpark w $ _sparks (_cWorld w)
updatePosEvents :: World -> World updatePosEvents :: World -> World
updatePosEvents w = w' & cWorld . posEvents .~ catMaybes newposEvents updatePosEvents w = w' & cWorld . posEvents .~ catMaybes newposEvents
where where
(w',newposEvents) = mapAccumR updatePosEvent w $ _posEvents (_cWorld w) (w', newposEvents) = mapAccumR updatePosEvent w $ _posEvents (_cWorld w)
{- Apply internal particle updates, delete 'Nothing's. -} {- Apply internal particle updates, delete 'Nothing's. -}
--updateParticles :: World -> World --updateParticles :: World -> World
@@ -298,55 +318,59 @@ updatePosEvents w = w' & cWorld . posEvents .~ catMaybes newposEvents
-- where -- where
-- (w',ps) = mapAccumR (\a b -> _ptUpdate b a b) w $ _particles w -- (w',ps) = mapAccumR (\a b -> _ptUpdate b a b) w $ _particles w
updateBeams :: World -> World updateBeams :: World -> World
updateBeams w = w updateBeams w =
& cWorld . newBeams .~ WorldBeams [] [] [] [] w
& cWorld . beams .~ thebeams & cWorld . newBeams .~ WorldBeams [] [] [] []
& combineBeams thebeams & cWorld . beams .~ thebeams
& combineBeams thebeams
where where
thebeams = _newBeams (_cWorld w) thebeams = _newBeams (_cWorld w)
combineBeams :: WorldBeams -> World -> World combineBeams :: WorldBeams -> World -> World
combineBeams wbeams w = w'' combineBeams wbeams w =
& cWorld . beams . positronBeams .~ pbeams w''
& cWorld . beams . electronBeams .~ ebeams & cWorld . beams . positronBeams .~ pbeams
& cWorld . beams . electronBeams .~ ebeams
where where
(w',pbeams) = mapAccumR (combineBeamBeams (_electronBeams wbeams)) w $ _positronBeams wbeams (w', pbeams) = mapAccumR (combineBeamBeams (_electronBeams wbeams)) w $ _positronBeams wbeams
(w'',ebeams) = mapAccumR (combineBeamBeams (_positronBeams wbeams)) w' $ _electronBeams wbeams (w'', ebeams) = mapAccumR (combineBeamBeams (_positronBeams wbeams)) w' $ _electronBeams wbeams
combineBeamBeams :: [Beam] -> World -> Beam -> (World,Beam) combineBeamBeams :: [Beam] -> World -> Beam -> (World, Beam)
combineBeamBeams bms w bm = case intersectBeamBeams bm bms of combineBeamBeams bms w bm = case intersectBeamBeams bm bms of
(ps,Nothing) -> (w, bm & bmFirstPoints .~ ps) (ps, Nothing) -> (w, bm & bmFirstPoints .~ ps)
(ps,Just a) -> (doBeamCombine (_beamCombine (_bmType bm)) a w, bm & bmFirstPoints .~ ps) (ps, Just a) -> (doBeamCombine (_beamCombine (_bmType bm)) a w, bm & bmFirstPoints .~ ps)
-- intersect a beam with a list of beams. -- intersect a beam with a list of beams.
-- returns the (reversed) travel of the beam up to maybe an intersection point -- returns the (reversed) travel of the beam up to maybe an intersection point
intersectBeamBeams :: Beam -> [Beam] intersectBeamBeams ::
-> ([Point2], Maybe (Point2,(Point2,Point2,Beam),(Point2,Point2,Beam))) Beam ->
[Beam] ->
([Point2], Maybe (Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)))
intersectBeamBeams bm bms = f [] $ _bmPoints bm intersectBeamBeams bm bms = f [] $ _bmPoints bm
where where
f ps (x:y:ys) = case intersectSegBeams x y bms of f ps (x : y : ys) = case intersectSegBeams x y bms of
Just (z,a) -> (z:x:ps, Just (z,(x,y,bm),a)) Just (z, a) -> (z : x : ps, Just (z, (x, y, bm), a))
Nothing -> f (x:ps) (y:ys) Nothing -> f (x : ps) (y : ys)
f ps [x] = (x:ps, Nothing) f ps [x] = (x : ps, Nothing)
f _ _ = error "made an empty beam" f _ _ = error "made an empty beam"
intersectSegBeams :: Point2 -> Point2 -> [Beam] -> Maybe (Point2,(Point2,Point2,Beam)) intersectSegBeams :: Point2 -> Point2 -> [Beam] -> Maybe (Point2, (Point2, Point2, Beam))
intersectSegBeams sp ep (bm:bms) = case intersectSegBeam sp ep bm of intersectSegBeams sp ep (bm : bms) = case intersectSegBeam sp ep bm of
Nothing -> intersectSegBeams sp ep bms Nothing -> intersectSegBeams sp ep bms
--Just a@(z,_) -> maybe (Just a) Just $ intersectSegBeams sp z bms --Just a@(z,_) -> maybe (Just a) Just $ intersectSegBeams sp z bms
Just a@(z,_) -> intersectSegBeams sp z bms <|> Just a Just a@(z, _) -> intersectSegBeams sp z bms <|> Just a
intersectSegBeams _ _ _ = Nothing intersectSegBeams _ _ _ = Nothing
intersectSegBeam :: Point2 -> Point2 -> Beam -> Maybe (Point2,(Point2,Point2,Beam)) intersectSegBeam :: Point2 -> Point2 -> Beam -> Maybe (Point2, (Point2, Point2, Beam))
intersectSegBeam sp ep bm = case intersectSegSegs' sp ep (_bmPoints bm) of intersectSegBeam sp ep bm = case intersectSegSegs' sp ep (_bmPoints bm) of
Nothing -> Nothing Nothing -> Nothing
Just (z,x,y) -> Just (z,(x,y,bm)) Just (z, x, y) -> Just (z, (x, y, bm))
intersectSegSegs' :: Point2 -> Point2 -> [Point2] -> Maybe (Point2,Point2,Point2) intersectSegSegs' :: Point2 -> Point2 -> [Point2] -> Maybe (Point2, Point2, Point2)
intersectSegSegs' sp ep (x:y:ys) = case intersectSegSeg sp ep x y of intersectSegSegs' sp ep (x : y : ys) = case intersectSegSeg sp ep x y of
--Just z -> maybe (Just (z,x,y)) Just $ intersectSegSegs' sp z (y:ys) --Just z -> maybe (Just (z,x,y)) Just $ intersectSegSegs' sp z (y:ys)
Just z -> intersectSegSegs' sp z (y:ys) <|> Just (z,x,y) Just z -> intersectSegSegs' sp z (y : ys) <|> Just (z, x, y)
Nothing -> intersectSegSegs' sp ep (y:ys) Nothing -> intersectSegSegs' sp ep (y : ys)
intersectSegSegs' _ _ _ = Nothing intersectSegSegs' _ _ _ = Nothing
--intersectSegSegs :: Point2 -> Point2 -> [Point2] -> Maybe Point2 --intersectSegSegs :: Point2 -> Point2 -> [Point2] -> Maybe Point2
@@ -370,8 +394,9 @@ intersectSegSegs' _ _ _ = Nothing
updateInstantBullets :: World -> World updateInstantBullets :: World -> World
updateInstantBullets w = case _instantBullets (_cWorld w) of updateInstantBullets w = case _instantBullets (_cWorld w) of
[] -> w [] -> w
ps -> let (w',ps') = mapAccumR updateBullet (w & cWorld . instantBullets.~[]) ps ps ->
in updateInstantBullets $ w' & cWorld . bullets .++~ catMaybes ps' let (w', ps') = mapAccumR updateBullet (w & cWorld . instantBullets .~ []) ps
in updateInstantBullets $ w' & cWorld . bullets .++~ catMaybes ps'
--updateInstantParticles :: World -> World --updateInstantParticles :: World -> World
--updateInstantParticles w = case _instantParticles w of --updateInstantParticles w = case _instantParticles w of
@@ -399,6 +424,7 @@ ppEvents w = IM.foldl' (flip $ \pp -> doPressPlateEvent (_ppEvent pp) pp) w $ _p
updateSeenWalls :: World -> World updateSeenWalls :: World -> World
updateSeenWalls w = foldl' markWallSeen w (map (_wlID . snd) $ allVisibleWalls w) updateSeenWalls w = foldl' markWallSeen w (map (_wlID . snd) $ allVisibleWalls w)
-- where -- where
-- f w' !i -- = w' & walls . ix i . wlSeen .~ True -- f w' !i -- = w' & walls . ix i . wlSeen .~ True
-- = w' { _walls = IM.adjust mw i $ _walls w' } -- = w' { _walls = IM.adjust mw i $ _walls w' }
@@ -408,12 +434,14 @@ markWallSeen :: World -> Int -> World
markWallSeen !w !i = w & cWorld . walls .~ IM.adjust markSeen i (_walls (_cWorld w)) markWallSeen !w !i = w & cWorld . walls .~ IM.adjust markSeen i (_walls (_cWorld w))
markSeen :: Wall -> Wall markSeen :: Wall -> Wall
markSeen wl = wl {_wlSeen = True} markSeen wl = wl{_wlSeen = True}
checkEndGame :: Universe -> Universe checkEndGame :: Universe -> Universe
checkEndGame uv = case _deathDelay (_cWorld w) of checkEndGame uv = case _deathDelay (_cWorld w) of
Just x | x < 0 -> uv & menuLayers .~ [gameOverMenu] Just x
& uvWorld . cWorld . deathDelay .~ Nothing | x < 0 ->
uv & menuLayers .~ [gameOverMenu]
& uvWorld . cWorld . deathDelay .~ Nothing
Just _ -> uv & uvWorld . cWorld . deathDelay . _Just -~ 1 Just _ -> uv & uvWorld . cWorld . deathDelay . _Just -~ 1
_ | _crHP (you w) < 1 -> uv & uvWorld . cWorld . deathDelay ?~ 50 _ | _crHP (you w) < 1 -> uv & uvWorld . cWorld . deathDelay ?~ 50
_ -> uv _ -> uv
@@ -426,27 +454,33 @@ updateGusts w = w & cWorld . gusts %~ IM.mapMaybe (mvGust w)
mvGust :: World -> Gust -> Maybe Gust mvGust :: World -> Gust -> Maybe Gust
mvGust _ gu mvGust _ gu
| _guTime gu < 0 = Nothing | _guTime gu < 0 = Nothing
| otherwise = Just $ gu | otherwise =
& guPos .+.+~ _guVel gu Just $
& guTime -~ 1 gu
& guPos .+.+~ _guVel gu
& guTime -~ 1
updateClouds :: World -> World updateClouds :: World -> World
updateClouds w = w' & cWorld . clouds .~ catMaybes mclouds updateClouds w = w' & cWorld . clouds .~ catMaybes mclouds
where where
-- cls = _clouds w -- cls = _clouds w
(w',mclouds) = mapAccumR updateCloud w (_clouds (_cWorld w)) (w', mclouds) = mapAccumR updateCloud w (_clouds (_cWorld w))
cloudEffect :: Cloud -> World -> World cloudEffect :: Cloud -> World -> World
cloudEffect cl = case _clType cl of cloudEffect cl = case _clType cl of
GasCloud -> cloudPoisonDamage cl GasCloud -> cloudPoisonDamage cl
SmokeCloud -> id SmokeCloud -> id
updateCloud :: World -> Cloud -> (World,Maybe Cloud) updateCloud :: World -> Cloud -> (World, Maybe Cloud)
updateCloud w c updateCloud w c
| _clTimer c < 1 = (w, Nothing) | _clTimer c < 1 = (w, Nothing)
| otherwise = (cloudEffect c w, Just $ c | otherwise =
& clPos .~ finalPos ( cloudEffect c w
& clVel .~ finalVel , Just $
& clTimer -~ 1 c
& clPos .~ finalPos
& clVel .~ finalVel
& clTimer -~ 1
) )
where where
newVel@(V3 _ _ nvz) = (0.95 *.*.* springVels) +.+.+ V3 0 0 (0.001 * vertVel) newVel@(V3 _ _ nvz) = (0.95 *.*.* springVels) +.+.+ V3 0 0 (0.001 * vertVel)
@@ -459,7 +493,7 @@ updateCloud w c
newPos2 = stripZ newPos newPos2 = stripZ newPos
hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w hitWl = bouncePoint (const True) 1 oldPos2 newPos2 w
finalPos = addZ (min 74 npz) $ maybe newPos2 fst hitWl finalPos = addZ (min 74 npz) $ maybe newPos2 fst hitWl
-- allowing clouds at/above height 75 causes graphical glitches 22.05.23 -- allowing clouds at/above height 75 causes graphical glitches 22.05.23
finalVel = addZ nvz $ maybe newVel2 snd hitWl finalVel = addZ nvz $ maybe newVel2 snd hitWl
clClSpringVel :: Cloud -> Point3 -> Cloud -> Point3 clClSpringVel :: Cloud -> Point3 -> Cloud -> Point3
@@ -482,27 +516,29 @@ crSpring c w = foldl' (flip $ crCrSpring c) w cs
crCrSpring :: Creature -> Creature -> World -> World crCrSpring :: Creature -> Creature -> World -> World
crCrSpring c1 c2 crCrSpring c1 c2
| id1 == id2 = id | id1 == id2 = id
| vec == V2 0 0 = id | vec == V2 0 0 = id
| diff >= comRad = id | diff >= comRad = id
| otherwise = cWorld . creatures %~ | otherwise =
( over (ix id1 . crPos) (+.+ overlap1) cWorld . creatures
. over (ix id2 . crPos) (-.- overlap2) %~ ( over (ix id1 . crPos) (+.+ overlap1)
) . over (ix id2 . crPos) (-.- overlap2)
)
where where
id1 = _crID c1 id1 = _crID c1
id2 = _crID c2 id2 = _crID c2
vec = _crPos c1 -.- _crPos c2 vec = _crPos c1 -.- _crPos c2
diff = magV vec diff = magV vec
comRad = _crRad c1 + _crRad c2 comRad = _crRad c1 + _crRad c2
overlap1 = ((comRad - diff) * _crMass c2 * 0.5 / massT) *.* errorNormalizeV 55 vec overlap1 = ((comRad - diff) * _crMass c2 * 0.5 / massT) *.* errorNormalizeV 55 vec
overlap2 = ((comRad - diff) * _crMass c1 * 0.5 / massT) *.* errorNormalizeV 56 vec overlap2 = ((comRad - diff) * _crMass c1 * 0.5 / massT) *.* errorNormalizeV 56 vec
massT = _crMass c1 + _crMass c2 massT = _crMass c1 + _crMass c2
updateDelayedEvents :: World -> World updateDelayedEvents :: World -> World
updateDelayedEvents w = let (neww,newde) = mapAccumR f w (_delayedEvents (_cWorld w)) updateDelayedEvents w =
in neww & cWorld . delayedEvents .~ catMaybes newde let (neww, newde) = mapAccumR f w (_delayedEvents (_cWorld w))
in neww & cWorld . delayedEvents .~ catMaybes newde
where where
f w' (i,g) f w' (i, g)
| i <= 0 = (w' & cWorld . worldEvents .:~ g, Nothing) | i <= 0 = (w' & cWorld . worldEvents .:~ g, Nothing)
| otherwise = (w', Just (i-1,g)) | otherwise = (w', Just (i -1, g))
+2 -2
View File
@@ -53,10 +53,10 @@ updatePressedButtons' :: M.Map MouseButton Bool -> World -> World
updatePressedButtons' pkeys w updatePressedButtons' pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv | isDown ButtonLeft && isDown ButtonRight && inTopInv
= useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown = useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && (inTopInv || _timeFlow (_cWorld w) == RewindingLastFrame) | isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
&& w ^?! hammers . ix DoubleMouseHam == HammerUp && w ^?! hammers . ix DoubleMouseHam == HammerUp
= useLeftItem (_yourID (_cWorld w)) w = useLeftItem (_yourID (_cWorld w)) w
| isDown ButtonLeft && (inTopInv || _timeFlow (_cWorld w) == RewindingLastFrame) | isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
= w & hammers . ix DoubleMouseHam .~ HammerDown = w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonRight && inTopInv = w | isDown ButtonRight && inTopInv = w
| isDown ButtonMiddle | isDown ButtonMiddle
+56 -45
View File
@@ -1,55 +1,67 @@
module Dodge.WorldEffect where module Dodge.WorldEffect where
import Dodge.Terminal
import Dodge.SoundLogic
import Dodge.WorldEvent.Cloud
import Dodge.Data
import Dodge.Inventory.Lock
import Dodge.Default
import LensHelp
import Data.Maybe
import Data.Foldable import Data.Foldable
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Creature.Impulse.UseItem
import Dodge.Data
import Dodge.Default
import Dodge.Inventory.Lock
import Dodge.Item.Location
import Dodge.SoundLogic
import Dodge.Terminal
import Dodge.WorldEvent.Cloud
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp
import System.Random import System.Random
doWorldEffect :: WdWd -> World -> World doWdWd :: WdWd -> World -> World
doWorldEffect we = case we of doWdWd we = case we of
NoWorldEffect -> id NoWorldEffect -> id
SetTrigger bool tid -> cWorld . triggers . ix tid .~ bool SetTrigger bool tid -> cWorld . triggers . ix tid .~ bool
SetLSCol col lsid -> cWorld . lightSources . ix lsid . lsParam . lsCol .~ col SetLSCol col lsid -> cWorld . lightSources . ix lsid . lsParam . lsCol .~ col
AccessTerminal mtmid -> accessTerminal mtmid AccessTerminal mtmid -> accessTerminal mtmid
WorldEffects wes -> \w -> foldr doWorldEffect w wes WorldEffects wes -> \w -> foldr doWdWd w wes
UnlockInv cid -> unlockInv cid UnlockInv cid -> unlockInv cid
MakeStartCloudAt p -> makeStartCloudAt p MakeStartCloudAt p -> makeStartCloudAt p
TorqueCr x cid -> torqueCr x cid TorqueCr x cid -> torqueCr x cid
SoundStart so p sid mi -> soundStart so p sid mi SoundStart so p sid mi -> soundStart so p sid mi
WdWdNegateTrig trid -> cWorld . triggers . ix trid %~ not WdWdNegateTrig trid -> cWorld . triggers . ix trid %~ not
WdWdFromItixCrixWdWd itid crid f -> \w -> fromMaybe w $ do
cr <- w ^? cWorld . creatures . ix crid
it <- getItem itid w
return $ doItCrWdWd f it cr w
WdWdFromItCrixWdWd it crid f -> \w -> fromMaybe w $ do
cr <- w ^? cWorld . creatures . ix crid
return $ doItCrWdWd f it cr w
doItCrWdWd :: ItCrWdWd -> Item -> Creature -> World -> World
doItCrWdWd icww = case icww of
ItCrWdId -> \_ _ -> id
ItCrWdItemEffect -> flip itemEffect
accessTerminal :: Maybe Int -> World -> World accessTerminal :: Maybe Int -> World -> World
accessTerminal mtmid w = case mtmid of accessTerminal mtmid w = case mtmid of
Nothing -> w Nothing -> w
Just tmid -> w & cWorld . hud . hudElement .~ DisplayInventory (DisplayTerminal tmid) Just tmid ->
& cWorld . terminals . ix tmid . tmInput . tiFocus .~ True w & cWorld . hud . hudElement .~ DisplayInventory (DisplayTerminal tmid)
& cWorld . terminals . ix tmid %~ tryToBoot & cWorld . terminals . ix tmid . tmInput . tiFocus .~ True
& cWorld . terminals . ix tmid %~ tryToBoot
where where
tryToBoot tm = case _tmStatus tm of tryToBoot tm = case _tmStatus tm of
TerminalReady -> tm TerminalReady -> tm
TerminalBusy -> tm TerminalBusy -> tm
TerminalOff -> tm TerminalOff ->
& tmFutureLines .~ doTerminalBootProgram (_tmBootProgram tm) tm w tm
& tmStatus .~ TerminalBusy & tmFutureLines .~ doTerminalBootProgram (_tmBootProgram tm) tm w
& tmStatus .~ TerminalBusy
torqueCr :: Float -> Int -> World -> World torqueCr :: Float -> Int -> World -> World
torqueCr x cid w torqueCr x cid w
| cid == 0 = set randGen g $ over (cWorld . cameraRot) (+rot) w | cid == 0 = set randGen g $ over (cWorld . cameraRot) (+ rot) w
| otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+rot) w | otherwise = set randGen g $ over (cWorld . creatures . ix cid . crDir) (+ rot) w
where where
(rot, g) = randomR (-x,x) $ _randGen w (rot, g) = randomR (- x, x) $ _randGen w
doCommandInstant :: String -> Terminal -> World -> World doCommandInstant :: String -> Terminal -> World -> World
doCommandInstant arg tm w = doLineEffectsInstant tm w $ commandFutureLines arg tm w doCommandInstant arg tm w = doLineEffectsInstant tm w $ commandFutureLines arg tm w
@@ -62,25 +74,27 @@ doLineEffectsInstant tm = foldr f
TerminalLineEffect _ eff -> doTmWdWd eff tm w TerminalLineEffect _ eff -> doTmWdWd eff tm w
_ -> w _ -> w
lineOutputTerminal :: [TerminalLine] -> Terminal lineOutputTerminal :: [TerminalLine] -> Terminal
lineOutputTerminal tls = defaultTerminal lineOutputTerminal tls =
{_tmDisplayedLines = [] defaultTerminal
,_tmFutureLines = [] { _tmDisplayedLines = []
,_tmMaxLines = 14 , _tmFutureLines = []
,_tmTitle = "TERMINAL" , _tmMaxLines = 14
,_tmInput = defaultTerminalInput , _tmTitle = "TERMINAL"
,_tmScrollCommands = [quitCommand] , _tmInput = defaultTerminalInput
,_tmWriteCommands = [helpCommand,commandsCommand] , _tmScrollCommands = [quitCommand]
,_tmBootProgram = TerminalBootLines $ connectionBlurbLines tls , _tmWriteCommands = [helpCommand, commandsCommand]
, _tmDeathEffect = TmWdWdDoDeathTriggers , _tmBootProgram = TerminalBootLines $ connectionBlurbLines tls
} , _tmDeathEffect = TmWdWdDoDeathTriggers
}
doDeathTriggers :: Terminal -> World -> World doDeathTriggers :: Terminal -> World -> World
doDeathTriggers tm w = w doDeathTriggers tm w =
& cWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs w
& cWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
where where
xs = M.elems $ _tmToggles tm xs = M.elems $ _tmToggles tm
doDeathToggle :: TerminalToggle -> IM.IntMap Bool -> IM.IntMap Bool doDeathToggle :: TerminalToggle -> IM.IntMap Bool -> IM.IntMap Bool
doDeathToggle (TerminalToggle trid f) = ix trid %~ doBlBl f doDeathToggle (TerminalToggle trid f) = ix trid %~ doBlBl f
@@ -90,20 +104,17 @@ doBlBl bb = case bb of
BlConst bl -> const bl BlConst bl -> const bl
BlId -> id BlId -> id
doTerminalBootProgram :: TerminalBootProgram -> Terminal -> World -> [TerminalLine] doTerminalBootProgram :: TerminalBootProgram -> Terminal -> World -> [TerminalLine]
doTerminalBootProgram tbp = case tbp of doTerminalBootProgram tbp = case tbp of
TerminalBootMempty -> \_ _ -> [] TerminalBootMempty -> \_ _ -> []
TerminalBootLines ls -> \_ _ -> ls TerminalBootLines ls -> \_ _ -> ls
doTmWdWd :: TmWdWd -> Terminal -> World -> World doTmWdWd :: TmWdWd -> Terminal -> World -> World
doTmWdWd tmwdwd = case tmwdwd of doTmWdWd tmwdwd = case tmwdwd of
TmWdId -> const id TmWdId -> const id
TmWdWdDisconnectTerminal -> disconnectTerminal TmWdWdDisconnectTerminal -> disconnectTerminal
TmWdWdTermSound sid -> \tm w -> let tpos = fromMaybe 0 $ w ^? cWorld . buttons . ix (_tmButtonID tm) . btPos TmWdWdTermSound sid -> \tm w ->
in soundStart TerminalSound tpos sid Nothing w let tpos = fromMaybe 0 $ w ^? cWorld . buttons . ix (_tmButtonID tm) . btPos
in soundStart TerminalSound tpos sid Nothing w
TmWdWdDoDeathTriggers -> doDeathTriggers TmWdWdDoDeathTriggers -> doDeathTriggers
TmWdWdfromWdWd f -> \_ -> doWorldEffect f TmWdWdfromWdWd f -> \_ -> doWdWd f