Separate out concrete part of world
This commit is contained in:
@@ -39,7 +39,7 @@ lasTurret = Turret
|
||||
-- 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
|
||||
@@ -52,12 +52,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
|
||||
@@ -70,9 +70,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)
|
||||
)
|
||||
@@ -83,7 +83,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
|
||||
@@ -94,12 +94,12 @@ 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)
|
||||
|
||||
|
||||
drawTurret :: Machine -> SPic
|
||||
|
||||
Reference in New Issue
Block a user