Minor changes, commit before playing with creature update
This commit is contained in:
@@ -39,17 +39,15 @@ meleeCooldown u w (f,g) cr = u w (f,g) $ cr & crMeleeCooldown . _Just %~ (max 0
|
||||
-- the whole of this update cycle could do with a rethink, it is becoming
|
||||
-- convoluted
|
||||
stateUpdate :: CRUpdate -> CRUpdate
|
||||
stateUpdate u w (f,g) cr =
|
||||
let (cr', g'') = updateMovement g cr
|
||||
in case u w (f,g'') cr' of
|
||||
stateUpdate u w (f,g) cr = case u w (f,g) cr of
|
||||
((f',g') , maybeCr) ->
|
||||
( (invSideEff cr . movementSideEff cr . deathEff . f'
|
||||
, g')
|
||||
, fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
||||
, fmap (stepReloading . stepItemUseCooldown . doDamage . crAutoReload . updateMovement g') $ crOrCorpse =<< maybeCr
|
||||
)
|
||||
where
|
||||
crOrCorpse cr'
|
||||
| cr' ^. crHP > 0 = Just cr'
|
||||
crOrCorpse cr'''
|
||||
| cr''' ^. crHP > 0 = Just cr'''
|
||||
| otherwise = Nothing
|
||||
deathEff
|
||||
| cr ^.crHP > 0 = id
|
||||
@@ -135,16 +133,16 @@ weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
updateMovement :: StdGen -> Creature -> (Creature, StdGen)
|
||||
updateMovement :: StdGen -> Creature -> Creature
|
||||
updateMovement g cr
|
||||
| isFrictionless cr = (over crPos (+.+ momentum) $ setOldPos cr, g')
|
||||
| otherwise = (updateWalkCycle $ setOldPos cr, g)
|
||||
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr
|
||||
| otherwise = updateWalkCycle $ setOldPos cr
|
||||
where
|
||||
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
|
||||
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'
|
||||
| otherwise = momentum'
|
||||
momentum = momentum'' +.+ 0.01 *.* unitVectorAtAngle randAng
|
||||
(randAng,g') = randomR (0,2*pi) g
|
||||
(randAng,_) = randomR (0,2*pi) g
|
||||
|
||||
isFrictionless :: Creature -> Bool
|
||||
isFrictionless cr = case cr ^? crStance . carriage of
|
||||
|
||||
Reference in New Issue
Block a user