Add new targeting datatypes
This commit is contained in:
@@ -136,6 +136,7 @@ invItemUpdate = itUse %~ useupdate
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr
|
||||
. flip (IS.foldr useeq) (_crInvEquipped cr)
|
||||
. doHeldItemTargeting cr
|
||||
$ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
useeq i = _eqUse (_itUse $ _crInv cr IM.! i) cr i
|
||||
@@ -148,6 +149,12 @@ invSideEff cr w = weaponReloadSounds cr
|
||||
| otherwise = itpointer %~ invItemUpdate
|
||||
itpointer = creatures . ix (_crID cr) . crInv . ix i
|
||||
|
||||
doHeldItemTargeting :: Creature -> World -> World
|
||||
doHeldItemTargeting cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting' . tgHeldUpdate of
|
||||
Nothing -> w
|
||||
Just f -> w & creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itTargeting'
|
||||
%~ f (_crInv cr IM.! _crInvSel cr) cr w
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
|
||||
Just am@LoadableAmmo{} -> case _reloadType am of
|
||||
|
||||
+5
-4
@@ -370,6 +370,7 @@ data Item = Item
|
||||
, _itInvDisplay :: Item -> [String]
|
||||
, _itInvColor :: Color
|
||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
||||
, _itTargeting' :: Targeting
|
||||
, _itDimension :: ItemDimension
|
||||
, _itCurseStatus :: CurseStatus
|
||||
, _itParams :: ItemParams
|
||||
@@ -379,10 +380,10 @@ data Item = Item
|
||||
}
|
||||
data Targeting
|
||||
= NoTargeting
|
||||
| Targeting
|
||||
{ _tgPos :: Maybe Point2
|
||||
, _tgUpdate :: Item -> Creature -> World -> Maybe Point2
|
||||
, _tgDraw :: Item -> Creature -> World -> Picture
|
||||
| TargetingOnHeld
|
||||
{ _tgPos :: Maybe Point2
|
||||
, _tgHeldUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
||||
, _tgDraw :: Item -> Creature -> World -> Picture
|
||||
}
|
||||
data ModuleSlot
|
||||
= ModBullet
|
||||
|
||||
@@ -157,6 +157,7 @@ defaultEquipment = Item
|
||||
, _itTargeting = Nothing
|
||||
, _itModules = M.empty
|
||||
, _itScope = NoScope
|
||||
, _itTargeting' = NoTargeting
|
||||
}
|
||||
defaultItZoom :: ItZoom
|
||||
defaultItZoom = ItZoom 20 0.2 1
|
||||
@@ -182,6 +183,7 @@ defaultConsumable = Item
|
||||
, _itTweaks = NoTweaks
|
||||
, _itModules = M.empty
|
||||
, _itScope = NoScope
|
||||
, _itTargeting' = NoTargeting
|
||||
}
|
||||
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
|
||||
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
|
||||
|
||||
@@ -104,6 +104,7 @@ defaultGun = Item
|
||||
,(ModBulletTarget,DefaultModule)
|
||||
]
|
||||
, _itScope = NoScope
|
||||
, _itTargeting' = NoTargeting
|
||||
}
|
||||
defaultCraftable :: Item
|
||||
defaultCraftable = Item
|
||||
@@ -126,6 +127,7 @@ defaultCraftable = Item
|
||||
, _itTweaks = NoTweaks
|
||||
, _itModules = M.empty
|
||||
, _itScope = NoScope
|
||||
, _itTargeting' = NoTargeting
|
||||
}
|
||||
defItDim :: ItemDimension
|
||||
defItDim = ItemDimension
|
||||
|
||||
Reference in New Issue
Block a user