Defunction-ify item modules, requires more cleanup

This commit is contained in:
2022-06-08 12:28:11 +01:00
parent d91a53f76c
commit bcbfd7d2fa
48 changed files with 762 additions and 740 deletions
-6
View File
@@ -91,9 +91,3 @@ creatureTurnToward p turnSpeed cr
{- | Speed modifier of an item when not aiming. -}
equipSpeed :: Item -> Float
equipSpeed _ = 1
{- | Speed modifier of an item when aiming. -}
equipAimSpeed :: Item -> Float -- TODO remove/rethink
equipAimSpeed it
| _itType it == FRONTARMOUR = 0.5
| _itType it == FLAMESHIELD = 0.5
| otherwise = 1
+1 -1
View File
@@ -49,7 +49,7 @@ ltAutoCrit = defaultCreature
, _crStrategy = StrategyActions WatchAndWait [StartSentinelPost]
, _crGoal = []
}
, _crInv = IM.fromList [(0,ltAutoGun),(1,medkit 100)]
, _crInv = IM.fromList [(0,autoPistol),(1,medkit 100)]
, _crInvSel = 0
, _crRad = 10
, _crHP = 500
+1 -1
View File
@@ -185,7 +185,7 @@ movementSideEff cr w
_ -> w
| otherwise = footstepSideEffect cr w
where
hasJetPack = any (\it -> it ^? itType == Just JETPACK) $ _crInv cr
hasJetPack = any (\it -> it ^? itType . iyBase == Just JETPACK) $ _crInv cr
oldPos = _crOldPos cr
momentum' = 0.97 *.* (_crPos cr -.- _crOldPos cr)
momentum'' | magV momentum' > 3 = 3 *.* normalizeV momentum'
+1 -1
View File
@@ -15,7 +15,7 @@ strFromEquipment :: Creature -> Int
strFromEquipment = sum . fmap equipmentStrValue . crCurrentEquipment
equipmentStrValue :: Item -> Int
equipmentStrValue itm = case _itType itm of
equipmentStrValue itm = case _iyBase $ _itType itm of
FRONTARMOUR -> negate 3
POWERLEGS -> 3
_ -> 0
+1 -1
View File
@@ -89,7 +89,7 @@ crIsArmouredFrom = hasFrontArmour
hasFrontArmour :: Point2 -> Creature -> Bool
hasFrontArmour p cr = fromMaybe False $ do
invid <- cr ^? crEquipment . ix OnChest
ittype <- cr ^? crInv . ix invid . itType
ittype <- cr ^? crInv . ix invid . itType . iyBase
return $ FRONTARMOUR == ittype
&& p /= _crOldPos cr
&& angleVV (unitVectorAtAngle (_crDir cr + frontarmdirection)) (p -.- _crOldPos cr) < pi/2