Cleanup constructors FooUse -> UseFoo

This commit is contained in:
2024-10-03 20:39:41 +01:00
parent 6b4cf596b1
commit 127d85e7ce
10 changed files with 49 additions and 92 deletions
+9 -11
View File
@@ -11,7 +11,6 @@ import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Control.Lens
import Control.Monad
--import Data.Foldable
import Data.Maybe
import Dodge.Cuse
import Dodge.Data.World
@@ -33,20 +32,20 @@ useRootItem crid w = fromMaybe w $ do
& worldEventFlags . at InventoryChange ?~ ()
itemUseEffect :: Creature -> LabelDoubleTree ComposeLinkType Item -> World -> World
itemUseEffect cr it w = case it ^. ldtValue . itUse of
UseHeld{} -> heldEffect it cr w
itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of
UseHeld{} -> heldEffect itmtree cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
UseHotkey{} -> doequipmentchange
UseEquip{} -> doequipmentchange
(UseConsume eff) -> useC eff (_ldtValue it) cr w
CraftUse{} -> w
UseAttach{} -> selectUse it cr w
TargetingUse {} -> w
(UseConsume eff) -> useC eff (_ldtValue itmtree) cr w
UseCraft{} -> w
UseAttach{} -> selectUse itmtree cr w
UseTargeting {} -> w
UseAmmoMag{} -> w
ScopeUse{} -> w
BulletModUse{} -> w
UseScope{} -> w
UseBulletMod{} -> w
where
itm = it ^. ldtValue
itm = itmtree ^. ldtValue
doequipmentchange = fromMaybe w $ do
guard (_crHammerPosition cr == HammerUp)
invid <- itm ^? itLocation . ilInvID
@@ -111,7 +110,6 @@ useItemLeftClick cr w = fromMaybe w $ do
_ -> Nothing
useItemLeftClick' :: Creature -> World -> World
--useItemLeftClick' cr' w = fromMaybe (f w) $ do
useItemLeftClick' cr' w = fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
itRef <- cr ^? crManipulation . manObject . imSelectedItem
+8 -16
View File
@@ -229,14 +229,10 @@ itemInvSideEffect cr itm = case _itType itm of
-- this probably needs to be set to null when dropped as well?
updateItemTargeting :: TargetingType -> Creature -> Item -> World -> World
updateItemTargeting tt cr itm w = case tt of
_
| not isattached ->
w
& pointItUse . tgPos .~ Nothing
& pointItUse . tgActive .~ False
TARGETLASER
| crIsAiming cr ->
w
_ | not isattached -> w
& pointItUse . tgPos .~ Nothing
& pointItUse . tgActive .~ False
TARGETLASER | crIsAiming cr -> w
& cWorld . lWorld . lasers
.:~ LaserStart
{ _lpPhaseV = 1
@@ -246,19 +242,15 @@ updateItemTargeting tt cr itm w = case tt of
, _lpType = TargetingLaser (_itID itm)
}
TARGETLASER -> w & pointItUse . tgPos .~ Nothing
TargetRBPress
| rbpressed ->
w
TargetRBPress | rbpressed -> w
& pointItUse . tgPos %~ maybe (Just $ mouseWorldPos (w ^. input) (w ^. wCam)) Just
& pointItUse . tgActive .~ True
TargetRBPress ->
w
TargetRBPress -> w
& pointItUse . tgPos .~ Nothing
& pointItUse . tgActive .~ False
TargetRBCreature -> w & pointItUse %~ setRBCreatureTargeting cr w
TargetCursor ->
w & pointItUse
.~ TargetingUse
TargetCursor -> w
& pointItUse .~ UseTargeting
(Just (mouseWorldPos (w ^. input) (w ^. wCam)))
Nothing
True