First (buggy) implementation of rewind gun
This commit is contained in:
@@ -163,7 +163,7 @@ startCr = defaultCreature
|
||||
{- | Items you start with. -}
|
||||
startInvList :: [Item]
|
||||
startInvList =
|
||||
[
|
||||
[ rewindGun
|
||||
]
|
||||
startInventory :: IM.IntMap Item
|
||||
startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem
|
||||
|
||||
@@ -59,8 +59,8 @@ isCognizant _ = False
|
||||
|
||||
combineAwareness :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel
|
||||
combineAwareness (Suspicious x) (Suspicious y)
|
||||
| x + y < 10000 = Suspicious $ x + y
|
||||
| otherwise = Cognizant 5000
|
||||
| x + y < 5000 = Suspicious $ x + y
|
||||
| otherwise = Cognizant 1000
|
||||
combineAwareness (Suspicious x) (Cognizant y) = Cognizant $ min 10000 $ x + y
|
||||
combineAwareness (Cognizant x) (Suspicious y) = Cognizant $ min 10000 $ x + y
|
||||
combineAwareness (Cognizant x) (Cognizant y) = Cognizant $ min 10000 $ x + y
|
||||
@@ -70,7 +70,7 @@ combineAwareness (Cognizant x) (Cognizant y) = Cognizant $ min 10000 $ x + y
|
||||
decreaseAwareness :: AwarenessLevel -> Maybe AwarenessLevel
|
||||
decreaseAwareness (Suspicious 0) = Nothing
|
||||
decreaseAwareness (Suspicious x) = Just $ Suspicious (x - 50)
|
||||
decreaseAwareness (Cognizant 0) = Just $ Suspicious 10000
|
||||
decreaseAwareness (Cognizant 0) = Just $ Suspicious 1000
|
||||
decreaseAwareness (Cognizant x) = Just $ Cognizant $ x - 50
|
||||
|
||||
{- | Given a fixed group of creatures, direct attention to those of them that
|
||||
|
||||
@@ -115,6 +115,7 @@ data World = World
|
||||
, _config :: Configuration
|
||||
, _preloadData :: PreloadData
|
||||
, _savedWorlds :: M.Map SaveSlot World
|
||||
, _rewindWorlds :: [World]
|
||||
, _frameClock :: Int
|
||||
}
|
||||
|
||||
@@ -421,12 +422,17 @@ data ItemDimension = ItemDimension
|
||||
|
||||
data ReloadType = ActiveReload | PassiveReload SoundID
|
||||
|
||||
-- I believe this is called every frame, not sure when though
|
||||
data ItEffect = NoItEffect
|
||||
| ItInvEffect
|
||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
-- the Int is the items inventory position
|
||||
,_itEffectCounter :: Int
|
||||
}
|
||||
| ItRewindEffect
|
||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
,_itStoredWorlds :: [World]
|
||||
}
|
||||
| ItEffect
|
||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||
,_itFloorEffect :: Int -> World -> World
|
||||
|
||||
@@ -84,6 +84,7 @@ defaultWorld = World
|
||||
, _preloadData = DummyPdata -- hack TODO remove this
|
||||
, _frameClock = 0
|
||||
, _worldBounds = defaultBounds
|
||||
, _rewindWorlds = []
|
||||
}
|
||||
youLight :: TempLightSource
|
||||
youLight =
|
||||
|
||||
@@ -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