Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -4,7 +4,7 @@ import Dodge.Data.World
|
||||
import LensHelp
|
||||
|
||||
basicMachineApplyDamage :: Machine -> World -> World
|
||||
basicMachineApplyDamage mc = cWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams))
|
||||
basicMachineApplyDamage mc = cWorld . lWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams))
|
||||
where
|
||||
dams = sum $ map _dmAmount $ _mcDamage mc
|
||||
mcid = _mcID mc
|
||||
|
||||
@@ -11,7 +11,7 @@ import LensHelp
|
||||
|
||||
destroyMachine :: Machine -> World -> World
|
||||
destroyMachine mc =
|
||||
(cWorld . machines %~ IM.delete (_mcID mc))
|
||||
(cWorld . lWorld . machines %~ IM.delete (_mcID mc))
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
. makeExplosionAt (_mcPos mc)
|
||||
. mcKillTerm mc
|
||||
@@ -26,7 +26,7 @@ destroyMcType mt mc = case mt of
|
||||
mcKillTerm :: Machine -> World -> World
|
||||
mcKillTerm mc w = fromMaybe w $ do
|
||||
tmid <- mc ^? mcMounts . ix ObTerminal
|
||||
tm <- w ^? cWorld . terminals . ix tmid
|
||||
tm <- w ^? cWorld . lWorld . terminals . ix tmid
|
||||
return $
|
||||
w
|
||||
& doTmWdWd (_tmDeathEffect tm) tm
|
||||
@@ -34,4 +34,4 @@ mcKillTerm mc w = fromMaybe w $ do
|
||||
mcKillBut :: Machine -> World -> World
|
||||
mcKillBut mc w = fromMaybe w $ do
|
||||
btid <- mc ^? mcMounts . ix ObButton
|
||||
return $ w & cWorld . buttons . at btid .~ Nothing
|
||||
return $ w & cWorld . lWorld . buttons . at btid .~ Nothing
|
||||
|
||||
+12
-12
@@ -36,7 +36,7 @@ updateTurret rotSpeed mc w =
|
||||
& elecDamBranch
|
||||
where
|
||||
dodamage =
|
||||
cWorld . machines . ix mcid
|
||||
cWorld . lWorld . machines . ix mcid
|
||||
%~ ( (mcDamage .~ [Damage ELECTRICAL (min 2500 $ max 0 (elecDam - 10)) 0 0 0 NoDamageEffect])
|
||||
. (mcHP -~ dam)
|
||||
)
|
||||
@@ -51,12 +51,12 @@ updateTurret rotSpeed mc w =
|
||||
dam = sum $ map _dmAmount dams
|
||||
elecDam = sum $ map _dmAmount elecDams
|
||||
doTurn
|
||||
| seesYou = cWorld . machines . ix mcid . mcType . _McTurret . tuDir %~ turnTo rotSpeed mcpos ypos
|
||||
| seesYou = cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuDir %~ turnTo rotSpeed mcpos ypos
|
||||
| otherwise = id
|
||||
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
|
||||
updateFiringStatus
|
||||
| closeFireAngle = cWorld . machines . ix mcid . mcType . _McTurret . tuFireTime .~ 20
|
||||
| otherwise = cWorld . machines . ix mcid . mcType . _McTurret . tuFireTime %~ (max 0 . subtract 1)
|
||||
| closeFireAngle = cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime .~ 20
|
||||
| otherwise = cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime %~ (max 0 . subtract 1)
|
||||
|
||||
mcUseItem :: Machine -> World -> World
|
||||
mcUseItem mc = fromMaybe id $ do
|
||||
@@ -70,7 +70,7 @@ mcSensorTriggerUpdate :: Sensor -> Machine -> World -> World
|
||||
mcSensorTriggerUpdate se mc = fromMaybe id $ do
|
||||
trid <- mc ^? mcMounts . ix ObTrigger
|
||||
bval <- mcTriggerVal se
|
||||
return $ cWorld . triggers . ix trid ||~ bval
|
||||
return $ cWorld . lWorld . triggers . ix trid ||~ bval
|
||||
|
||||
mcTriggerVal :: Sensor -> Maybe Bool
|
||||
mcTriggerVal se = case se of
|
||||
@@ -94,7 +94,7 @@ mcApplyDamage ds mc = case mc ^? mcType . _McSensor of
|
||||
_ -> mcpointer
|
||||
%~ (mcDamage .~ [])
|
||||
where
|
||||
mcpointer = cWorld . machines . ix (_mcID mc)
|
||||
mcpointer = cWorld . lWorld . machines . ix (_mcID mc)
|
||||
|
||||
mcSensorUpdate :: Sensor -> Machine -> World -> World
|
||||
mcSensorUpdate se mc w = case se of
|
||||
@@ -110,13 +110,13 @@ mcProximitySensorUpdate mc w = case ( _proxStatus sens
|
||||
(_, True, _, _) -> w
|
||||
(_, False, True, True) ->
|
||||
w
|
||||
& cWorld . machines . ix (_mcID mc) . mcType . _McSensor . sensToggle .~ True
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . sensToggle .~ True
|
||||
& playsound dedaS
|
||||
& cWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
||||
(NotClose, _, False, True) ->
|
||||
w & playsound dedumS
|
||||
& cWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
||||
(_, _, _, False) -> w & cWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ NotClose
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
||||
(_, _, _, False) -> w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ NotClose
|
||||
_ -> w
|
||||
where
|
||||
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
||||
@@ -133,7 +133,7 @@ mcProxTest mc w = case mc ^? mcType . _McSensor . proxRequirement of
|
||||
|
||||
senseDamage :: Int -> DamageType -> Machine -> World -> World
|
||||
senseDamage threshold dt mc =
|
||||
(cWorld . machines . ix mcid %~ upmc)
|
||||
(cWorld . lWorld . machines . ix mcid %~ upmc)
|
||||
. updatels
|
||||
where
|
||||
upmc = mcType . _McSensor . sensAmount %~ min (100 * threshold) . max 0 . (+ newsense)
|
||||
@@ -146,7 +146,7 @@ senseDamage threshold dt mc =
|
||||
ni = fromIntegral (mc ^?! mcType . _McSensor . sensAmount) / fromIntegral threshold
|
||||
updatels = fromMaybe id $ do
|
||||
lsid <- mc ^? mcMounts . ix ObLightSource
|
||||
return $ cWorld . lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
|
||||
return $ cWorld . lWorld . lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
|
||||
|
||||
damageUsing :: DamageType -> Damage -> Either Int Int
|
||||
damageUsing dt dm
|
||||
|
||||
Reference in New Issue
Block a user