Cleanup, slight improvements to item location references

This commit is contained in:
2024-09-24 22:05:20 +01:00
parent 25cec10313
commit df80e87427
5 changed files with 35 additions and 59 deletions
+6 -6
View File
@@ -62,6 +62,7 @@ bulGunEffect' t cr w = fromMaybe (error "error in bulGunEffect") $ do
& doWeaponRepetitions upitm cr
-- & cWorld . lWorld . lTestInt +~ 1
-- need to be careful about inventory lock or item ids here
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
Just (x:xs) -> cWorld . lWorld . delayedEvents .++~ ((x:xs) <&> (,WdWdFromItCrixWdWd upitm (_crID cr) ItCrWdItemEffect))
@@ -218,18 +219,17 @@ walkNozzle mzid mz itm cr w = fromMaybe w $ do
shootTractorBeam :: Item -> Creature -> World -> World
shootTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt' spos outpos dir power
shootTractorBeam itm cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
where
cpos = _crPos cr
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
dir = _crDir cr
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crManipulation . manObject . imRootItem -- unsafe!! TODO change
power = _attractionPower . _itParams $ itm
tractorBeamAt' :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
tractorBeamAt' pos outpos dir power =
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
tractorBeamAt pos outpos dir power =
TractorBeam
{ _tbPos = pos
, _tbStartPos = outpos
@@ -316,7 +316,7 @@ useHeld hu = case hu of
-- HeldLaser -> shootLaser . _ldtValue
-- HeldCircleLaser -> circleLaser . _ldtValue
-- HeldDualLaser -> shootDualLaser . _ldtValue
HeldTractor -> aTractorBeam . _ldtValue
-- HeldTractor -> aTractorBeam . _ldtValue
-- HeldSonicWave -> aSonicWave
HeldForceField -> useForceFieldGun . _ldtValue
HeldShatter -> shootShatter . _ldtValue