Move item effect functions
This commit is contained in:
@@ -76,50 +76,50 @@ grenadeDraw :: Float -> Prop -> SPic
|
||||
grenadeDraw dir prop = translateSPz (_pjZ prop) $ uncurryV translateSPf (_prPos prop)
|
||||
$ rotateSP dir $ grenadePic $ _pjTimer prop
|
||||
|
||||
throwGrenade
|
||||
:: (Point2 -> World -> World) -- ^ Payload
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
||||
where
|
||||
n = _crID cr
|
||||
addG = IM.insert i $ Bomb
|
||||
{ _prPos = p
|
||||
, _pjZ = 10
|
||||
, _pjVelZ = 2
|
||||
, _pjVel = v
|
||||
, _prDraw = grenadeDraw dir
|
||||
, _pjID = i
|
||||
, _pjUpdate = moveGrenade
|
||||
, _pjPayload = thePayload
|
||||
, _pjTimer = fuseTime
|
||||
}
|
||||
j = crSel cr
|
||||
removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
||||
i = IM.newKey $ _props w
|
||||
v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
| otherwise = v'
|
||||
p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||
p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||
| otherwise = p'
|
||||
dir = argV v
|
||||
setWp :: World -> World
|
||||
setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
||||
fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
||||
--throwGrenade
|
||||
-- :: (Point2 -> World -> World) -- ^ Payload
|
||||
-- -> Creature
|
||||
-- -> World
|
||||
-- -> World
|
||||
--throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
|
||||
-- where
|
||||
-- n = _crID cr
|
||||
-- addG = IM.insert i $ Bomb
|
||||
-- { _prPos = p
|
||||
-- , _pjZ = 10
|
||||
-- , _pjVelZ = 2
|
||||
-- , _pjVel = v
|
||||
-- , _prDraw = grenadeDraw dir
|
||||
-- , _pjID = i
|
||||
-- , _pjUpdate = moveGrenade
|
||||
-- , _pjPayload = thePayload
|
||||
-- , _pjTimer = fuseTime
|
||||
-- }
|
||||
-- j = crSel cr
|
||||
-- removePict = id -- set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
|
||||
-- i = IM.newKey $ _props w
|
||||
-- v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
|
||||
-- v | magV v' > 6 = 6 *.* normalizeV v'
|
||||
-- | otherwise = v'
|
||||
-- p' = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr) 0)
|
||||
-- p | circOnSomeWall p' 4 w = _crPos cr +.+ rotateV (_crDir cr) (V2 (_crRad cr-4) 0)
|
||||
-- | otherwise = p'
|
||||
-- dir = argV v
|
||||
-- setWp :: World -> World
|
||||
-- setWp w' = w' & creatures . ix n . crInv . ix j . itEffect .~ throwArmReset 20
|
||||
-- fuseTime = _atFuseTime $ _itAttachment $ _crInv cr IM.! j
|
||||
|
||||
throwArmReset :: Int -> ItEffect
|
||||
throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
||||
where
|
||||
f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
||||
where
|
||||
i = _ipInvID $ _itPos itm
|
||||
counterDown it
|
||||
| _ieCounter (_itEffect it) == 0 = it
|
||||
& itUse . useHammer .~ HammerUp
|
||||
-- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
||||
| otherwise = it & itEffect . ieCounter -~ 1
|
||||
--throwArmReset :: Int -> ItEffect
|
||||
--throwArmReset x = ItInvEffect {_ieInv = f ,_ieCounter = x }
|
||||
-- where
|
||||
-- f itm cr = creatures . ix (_crID cr) . crInv %~ IM.adjust counterDown i
|
||||
-- where
|
||||
-- i = _ipInvID $ _itPos itm
|
||||
-- counterDown it
|
||||
-- | _ieCounter (_itEffect it) == 0 = it
|
||||
-- & itUse . useHammer .~ HammerUp
|
||||
---- & itEquipPict .~ pictureWeaponAim (\_ -> grenadePic 50)
|
||||
-- | otherwise = it & itEffect . ieCounter -~ 1
|
||||
|
||||
--flameGrenade :: Item
|
||||
--flameGrenade = grenade {
|
||||
|
||||
@@ -20,24 +20,12 @@ rewindGun = defaultLeftItem
|
||||
{ _wpMaxCharge = 250
|
||||
, _wpCharge = 0
|
||||
}
|
||||
, _itEffect = ItRewindEffect rewindEffect []
|
||||
, _itEffect = ItRewindEffect RewindEffect []
|
||||
, _itUse = defaultlUse
|
||||
& lUse .~ LRewind --useRewindGun
|
||||
& eqEq . eqSite .~ GoesOnChest
|
||||
}
|
||||
& itType . iyBase .~ LEFT REWINDER
|
||||
rewindEffect :: Item -> Creature -> World -> World
|
||||
rewindEffect itm cr w
|
||||
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
|
||||
& ptrWpCharge .~ length (_rewindWorlds w)
|
||||
| otherwise = w & rewindWorlds .~ []
|
||||
& ptrWpCharge .~ 0
|
||||
where
|
||||
invid = _ipInvID $ _itPos itm
|
||||
ptrWpCharge = creatures . ix (_crID cr) . crInv . ix invid . itConsumption . wpCharge
|
||||
maxcharge = _wpMaxCharge . _itConsumption $ itm
|
||||
w' = w & rewindWorlds .~ []
|
||||
& timeFlow .~ NormalTimeFlow
|
||||
|
||||
-- needs to shift this item to the current inventory slot
|
||||
shrinkGun :: Item
|
||||
|
||||
Reference in New Issue
Block a user