First (buggy) implementation of rewind gun
This commit is contained in:
@@ -27,6 +27,7 @@ data ItemIdentity
|
||||
| LongGun
|
||||
| Flamethrower
|
||||
| Blinker
|
||||
| Rewinder
|
||||
| Grenade
|
||||
| RemoteBomb
|
||||
| TeslaGun
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module Dodge.Item.Weapon.Utility where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Default
|
||||
import Dodge.Picture.Layer
|
||||
import Dodge.Creature.Action
|
||||
@@ -7,11 +8,35 @@ import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.Default.Weapon
|
||||
import Geometry
|
||||
import Picture
|
||||
--import qualified IntMapHelp as IM
|
||||
import qualified IntMapHelp as IM
|
||||
import Shape
|
||||
import ShapePicture
|
||||
|
||||
import Control.Lens
|
||||
|
||||
rewindGun :: Item
|
||||
rewindGun = defaultGun
|
||||
{ _itName = "REWINDER"
|
||||
, _itIdentity = Rewinder
|
||||
, _wpMaxAmmo = 0
|
||||
, _wpLoadedAmmo = 0
|
||||
, _itUse = useRewindGun
|
||||
, _itEffect = ItRewindEffect rewindEffect []
|
||||
, _itLeftClickUse = Just $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
|
||||
}
|
||||
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
rewindEffect iteff cr invid w = w & rewindWorlds %~ (take 100 . (w' : ))
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w)
|
||||
where
|
||||
w' = w & rewindWorlds .~ []
|
||||
|
||||
useRewindGun :: Item -> Creature -> World -> World
|
||||
useRewindGun it cr w = case _rewindWorlds w of
|
||||
(_:w':ws) -> w' & keys .~ _keys w
|
||||
& mouseButtons .~ _mouseButtons w
|
||||
& rewindWorlds .~ ws
|
||||
_ -> w
|
||||
|
||||
shrinkGun :: Item
|
||||
shrinkGun = defaultGun
|
||||
{ _itName = "SHRINKER"
|
||||
|
||||
Reference in New Issue
Block a user