Allow more general detection of item use focus
This commit is contained in:
@@ -15,6 +15,9 @@ import Geometry
|
||||
import LensHelp
|
||||
import Picture
|
||||
|
||||
-- note collideCircWalls doesn't always correctly zone walls, this should be
|
||||
-- replaced.
|
||||
-- I think the test circHitWall DOES work
|
||||
-- | Teleport a creature to the mouse position
|
||||
blinkActionMousePos :: Creature -> World -> World
|
||||
blinkActionMousePos cr w =
|
||||
|
||||
@@ -24,7 +24,7 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
let usedloc = case itmloc ^. locLDT . ldtValue . _1 . itUseFocus of
|
||||
let usedloc = case useLocation itmloc of
|
||||
UseFromLocation -> itmloc ^. locLDT
|
||||
UseFromRoot -> locToTop itmloc ^. locLDT
|
||||
let itm = usedloc ^. ldtValue . _1
|
||||
@@ -46,6 +46,13 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
|
||||
where
|
||||
fst3 (x,_,_) = x
|
||||
|
||||
useLocation :: LocationLDT ItemLink ComposedItem -> UseFocus
|
||||
useLocation loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = UseFromLocation
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile
|
||||
= UseFromLocation
|
||||
| otherwise = UseFromRoot
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
DoNotMoveEquipment -> w
|
||||
|
||||
Reference in New Issue
Block a user