Work towards duct taping torch

This commit is contained in:
2022-07-14 10:50:12 +01:00
parent bfe9073808
commit 2cfa3ca3a7
8 changed files with 40 additions and 11 deletions
+16 -3
View File
@@ -11,7 +11,7 @@ import Dodge.Prop.Gib
import Dodge.Base
import Dodge.Creature.State.WalkCycle
import Dodge.Creature.Impulse.Movement
--import Dodge.Creature.Test
import Dodge.LightSource.Torch
--import Dodge.Base
import Dodge.SoundLogic
import RandomHelp
@@ -24,12 +24,12 @@ import Picture
import Shape
import ShapePicture
import qualified IntMapHelp as IM
import LensHelp
--import StrictHelp
--import FoldableHelp
import Data.Function
import Control.Lens
--import qualified Data.IntSet as IS
--import Data.Maybe
--import Control.Applicative
@@ -212,7 +212,20 @@ equipmentEffects cr = flip (foldr $ useEquipment cr) (IM.keys $ _crInvEquipped c
invSideEff :: Creature -> World -> World
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
where
f i it w' = doItemTargeting i cr w' & maybe id (\g -> g it cr) (it ^? itEffect . ieInv)
f i it w' = itemInvSideEffect cr it
$ doItemTargeting i cr w' & maybe id (\g -> g it cr) (it ^? itEffect . ieInv)
itemInvSideEffect :: Creature -> Item -> World -> World
itemInvSideEffect cr it
| hastorchattach = createAttachLight cr it
| otherwise = id
where
hastorchattach = it ^? itType . iyModules . ix ModHeldAttach == Just ATTACHTORCH && _itIsHeld it
createAttachLight :: Creature -> Item -> World -> World
createAttachLight cr it = createTorchLightOffset cr it attachoff
where
attachoff = it ^?! itUse . heldAttachPos
itemUpdate :: Creature -> Int -> Item -> Item
itemUpdate cr i