Separate out concrete part of world
This commit is contained in:
+21
-21
@@ -34,7 +34,7 @@ mcTurretUpdate mc = case _mcType mc of
|
||||
-- this needs a major cleanup
|
||||
updateTurret :: Float -> Machine -> World -> World
|
||||
updateTurret rotSpeed mc w
|
||||
| _mcHP mc < 1 = w & machines %~ IM.delete mcid
|
||||
| _mcHP mc < 1 = w & cWorld . machines %~ IM.delete mcid
|
||||
& deleteWallIDs (_mcWallIDs mc)
|
||||
& makeExplosionAt mcpos
|
||||
& copyItemToFloor mcpos lasGun
|
||||
@@ -47,12 +47,12 @@ updateTurret rotSpeed mc w
|
||||
where
|
||||
deleteHomonculus = case _tuMCrID (_mcType mc) of
|
||||
Nothing -> id
|
||||
Just cid -> creatures . at cid .~ Nothing
|
||||
initHomonculus w' = case w' ^? machines . ix mcid . mcType . tuMCrID . _Just of
|
||||
Nothing -> w' & machines . ix mcid . mcType . tuMCrID ?~ cid
|
||||
& creatures . at cid ?~ thecreature
|
||||
Just cid -> cWorld . creatures . at cid .~ Nothing
|
||||
initHomonculus w' = case w' ^? cWorld . machines . ix mcid . mcType . tuMCrID . _Just of
|
||||
Nothing -> w' & cWorld . machines . ix mcid . mcType . tuMCrID ?~ cid
|
||||
& cWorld . creatures . at cid ?~ thecreature
|
||||
where
|
||||
cid = IM.newKey (_creatures w')
|
||||
cid = IM.newKey (_creatures (_cWorld w'))
|
||||
thecreature = defaultCreature
|
||||
& crID .~ cid
|
||||
& crInv . at 0 ?~ (_tuWeapon (_mcType mc) & itUse . useAim . aimHandlePos -~ 10
|
||||
@@ -65,9 +65,9 @@ updateTurret rotSpeed mc w
|
||||
& crStance . posture .~ Aiming
|
||||
& crMaterial .~ Crystal
|
||||
Just cid -> w'
|
||||
& creatures . ix cid . crPos .~ mcpos
|
||||
& creatures . ix cid . crDir .~ mcdir
|
||||
dodamage = machines . ix mcid %~
|
||||
& cWorld . creatures . ix cid . crPos .~ mcpos
|
||||
& cWorld . creatures . ix cid . crDir .~ mcdir
|
||||
dodamage = cWorld . machines . ix mcid %~
|
||||
( (mcDamage .~ [Damage ELECTRICAL (min 2500 $ max 0 (elecDam - 10)) 0 0 0 NoDamageEffect])
|
||||
. (mcHP -~ dam)
|
||||
)
|
||||
@@ -78,7 +78,7 @@ updateTurret rotSpeed mc w
|
||||
| _tuFireTime (_mcType mc) > 0
|
||||
= fromMaybe id $ do
|
||||
cid <- _tuMCrID (_mcType mc)
|
||||
return $ creatures . ix cid . crActionPlan . apImpulse .~ [UseItem]
|
||||
return $ cWorld . creatures . ix cid . crActionPlan . apImpulse .~ [UseItem]
|
||||
| otherwise = id
|
||||
mcid = _mcID mc
|
||||
ypos = _crPos $ you w
|
||||
@@ -89,18 +89,18 @@ updateTurret rotSpeed mc w
|
||||
dam = sum $ map _dmAmount dams
|
||||
elecDam = sum $ map _dmAmount elecDams
|
||||
doTurn
|
||||
| seesYou = machines . ix mcid . mcDir %~ turnTo rotSpeed mcpos ypos
|
||||
| seesYou = cWorld . machines . ix mcid . mcDir %~ turnTo rotSpeed mcpos ypos
|
||||
| otherwise = id
|
||||
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
|
||||
updateFiringStatus
|
||||
| closeFireAngle = machines . ix mcid . mcType . tuFireTime .~ 20
|
||||
| otherwise = machines . ix mcid . mcType . tuFireTime %~ (max 0 . subtract 1)
|
||||
| closeFireAngle = cWorld . machines . ix mcid . mcType . tuFireTime .~ 20
|
||||
| otherwise = cWorld . machines . ix mcid . mcType . tuFireTime %~ (max 0 . subtract 1)
|
||||
|
||||
mcSensorTriggerUpdate :: Machine -> World -> World
|
||||
mcSensorTriggerUpdate mc = fromMaybe id $ do
|
||||
trid <- mc ^? mcMounts . ix ObTrigger
|
||||
bval <- mcTriggerVal mc
|
||||
return $ triggers . ix trid .~ bval
|
||||
return $ cWorld . triggers . ix trid .~ bval
|
||||
|
||||
mcTriggerVal :: Machine -> Maybe Bool
|
||||
mcTriggerVal mc = case mc ^. mcSensor of
|
||||
@@ -119,7 +119,7 @@ mcPlaySound mc w = case _mcCloseSound mc of
|
||||
|
||||
mcApplyDamage :: [Damage] -> Machine -> World -> World
|
||||
mcApplyDamage ds mc = case _mcSensor mc of
|
||||
NoSensor -> machines . ix (_mcID mc) %~
|
||||
NoSensor -> cWorld . machines . ix (_mcID mc) %~
|
||||
( (mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds)) )
|
||||
_ -> id
|
||||
|
||||
@@ -137,12 +137,12 @@ mcProximitySensorUpdate mc w = case
|
||||
, dist (_crPos ycr) (_mcPos mc) < _proxDist sens) of
|
||||
(_,True,_,_) -> w
|
||||
(_,False,True,True) -> w
|
||||
& machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
|
||||
& cWorld . machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
|
||||
& playsound dedaS
|
||||
& machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
||||
& cWorld . machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
||||
(NotClose,_,False,True) -> w & playsound dedumS
|
||||
& machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
||||
(_,_,_,False) -> w & machines . ix (_mcID mc) . mcSensor . proxStatus .~ NotClose
|
||||
& cWorld . machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
||||
(_,_,_,False) -> w & cWorld . machines . ix (_mcID mc) . mcSensor . proxStatus .~ NotClose
|
||||
_ -> w
|
||||
where
|
||||
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
||||
@@ -158,7 +158,7 @@ mcProxTest mc w = case mc ^? mcSensor . proxRequirement of
|
||||
cr = you w
|
||||
|
||||
senseDamage :: DamageType -> Machine -> World -> World
|
||||
senseDamage dt mc = (machines . ix mcid %~ upmc)
|
||||
senseDamage dt mc = (cWorld . machines . ix mcid %~ upmc)
|
||||
. updatels
|
||||
where
|
||||
upmc = mcSensor . sensAmount %~ min 1000 . max 0 . (+ (newsense - 5))
|
||||
@@ -167,7 +167,7 @@ senseDamage dt mc = (machines . ix mcid %~ upmc)
|
||||
ni = fromIntegral (_sensAmount $ _mcSensor mc) / 1000
|
||||
updatels = fromMaybe id $ do
|
||||
lsid <- mc ^? mcMounts . ix ObLightSource
|
||||
return $ lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
|
||||
return $ cWorld . 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