First (buggy) implementation of rewind gun
This commit is contained in:
@@ -163,7 +163,7 @@ startCr = defaultCreature
|
|||||||
{- | Items you start with. -}
|
{- | Items you start with. -}
|
||||||
startInvList :: [Item]
|
startInvList :: [Item]
|
||||||
startInvList =
|
startInvList =
|
||||||
[
|
[ rewindGun
|
||||||
]
|
]
|
||||||
startInventory :: IM.IntMap Item
|
startInventory :: IM.IntMap Item
|
||||||
startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem
|
startInventory = IM.fromList $ zip [0..defaultInvSize -1] $ startInvList ++ repeat NoItem
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ isCognizant _ = False
|
|||||||
|
|
||||||
combineAwareness :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel
|
combineAwareness :: AwarenessLevel -> AwarenessLevel -> AwarenessLevel
|
||||||
combineAwareness (Suspicious x) (Suspicious y)
|
combineAwareness (Suspicious x) (Suspicious y)
|
||||||
| x + y < 10000 = Suspicious $ x + y
|
| x + y < 5000 = Suspicious $ x + y
|
||||||
| otherwise = Cognizant 5000
|
| otherwise = Cognizant 1000
|
||||||
combineAwareness (Suspicious x) (Cognizant y) = Cognizant $ min 10000 $ x + y
|
combineAwareness (Suspicious x) (Cognizant y) = Cognizant $ min 10000 $ x + y
|
||||||
combineAwareness (Cognizant x) (Suspicious 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
|
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 :: AwarenessLevel -> Maybe AwarenessLevel
|
||||||
decreaseAwareness (Suspicious 0) = Nothing
|
decreaseAwareness (Suspicious 0) = Nothing
|
||||||
decreaseAwareness (Suspicious x) = Just $ Suspicious (x - 50)
|
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
|
decreaseAwareness (Cognizant x) = Just $ Cognizant $ x - 50
|
||||||
|
|
||||||
{- | Given a fixed group of creatures, direct attention to those of them that
|
{- | Given a fixed group of creatures, direct attention to those of them that
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ data World = World
|
|||||||
, _config :: Configuration
|
, _config :: Configuration
|
||||||
, _preloadData :: PreloadData
|
, _preloadData :: PreloadData
|
||||||
, _savedWorlds :: M.Map SaveSlot World
|
, _savedWorlds :: M.Map SaveSlot World
|
||||||
|
, _rewindWorlds :: [World]
|
||||||
, _frameClock :: Int
|
, _frameClock :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,12 +422,17 @@ data ItemDimension = ItemDimension
|
|||||||
|
|
||||||
data ReloadType = ActiveReload | PassiveReload SoundID
|
data ReloadType = ActiveReload | PassiveReload SoundID
|
||||||
|
|
||||||
|
-- I believe this is called every frame, not sure when though
|
||||||
data ItEffect = NoItEffect
|
data ItEffect = NoItEffect
|
||||||
| ItInvEffect
|
| ItInvEffect
|
||||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||||
-- the Int is the items inventory position
|
-- the Int is the items inventory position
|
||||||
,_itEffectCounter :: Int
|
,_itEffectCounter :: Int
|
||||||
}
|
}
|
||||||
|
| ItRewindEffect
|
||||||
|
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||||
|
,_itStoredWorlds :: [World]
|
||||||
|
}
|
||||||
| ItEffect
|
| ItEffect
|
||||||
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
{_itInvEffect :: ItEffect -> Creature -> Int -> World -> World
|
||||||
,_itFloorEffect :: Int -> World -> World
|
,_itFloorEffect :: Int -> World -> World
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ defaultWorld = World
|
|||||||
, _preloadData = DummyPdata -- hack TODO remove this
|
, _preloadData = DummyPdata -- hack TODO remove this
|
||||||
, _frameClock = 0
|
, _frameClock = 0
|
||||||
, _worldBounds = defaultBounds
|
, _worldBounds = defaultBounds
|
||||||
|
, _rewindWorlds = []
|
||||||
}
|
}
|
||||||
youLight :: TempLightSource
|
youLight :: TempLightSource
|
||||||
youLight =
|
youLight =
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ data ItemIdentity
|
|||||||
| LongGun
|
| LongGun
|
||||||
| Flamethrower
|
| Flamethrower
|
||||||
| Blinker
|
| Blinker
|
||||||
|
| Rewinder
|
||||||
| Grenade
|
| Grenade
|
||||||
| RemoteBomb
|
| RemoteBomb
|
||||||
| TeslaGun
|
| TeslaGun
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Item.Weapon.Utility where
|
module Dodge.Item.Weapon.Utility where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.Base
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Picture.Layer
|
import Dodge.Picture.Layer
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
@@ -7,11 +8,35 @@ import Dodge.Item.Weapon.TriggerType
|
|||||||
import Dodge.Default.Weapon
|
import Dodge.Default.Weapon
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
--import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import Shape
|
import Shape
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
|
||||||
import Control.Lens
|
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 :: Item
|
||||||
shrinkGun = defaultGun
|
shrinkGun = defaultGun
|
||||||
{ _itName = "SHRINKER"
|
{ _itName = "SHRINKER"
|
||||||
|
|||||||
Reference in New Issue
Block a user