Make unequip event occur on equipped item drop
This commit is contained in:
@@ -56,10 +56,16 @@ rmInvItem cid invid w = case w ^? creatures . ix cid . crInv . ix invid . itCons
|
||||
& creatures . ix cid . crInvSel %~ g
|
||||
& creatures . ix cid . crLeftInvSel %~ g'
|
||||
& removeAnySlotEquipment
|
||||
& dounequipfunction
|
||||
& creatures . ix cid . crInvEquipped %~ IM.delete invid
|
||||
& creatures . ix cid . crInvEquipped %~ IM.mapKeys g
|
||||
-- TODO check whether this can be mapKeysMonotonic
|
||||
where
|
||||
cr = _creatures w IM.! cid
|
||||
itm = _crInv cr IM.! invid
|
||||
dounequipfunction = fromMaybe id $ do
|
||||
rmf <- itm ^? itUse . eqOnRemove
|
||||
return $ rmf itm cr
|
||||
removeAnySlotEquipment = case w ^? creatures . ix cid . crInvEquipped . ix invid of
|
||||
Just epos -> creatures . ix cid . crEquipment . at epos .~ Nothing
|
||||
Nothing -> id
|
||||
|
||||
Reference in New Issue
Block a user