Continue reload refactor

This commit is contained in:
2022-06-21 14:07:17 +01:00
parent 14a7189b44
commit 53c8be0679
33 changed files with 106 additions and 115 deletions
+4 -4
View File
@@ -373,7 +373,7 @@ tractorGunPic it =
-- | assumes that the item is held
shootTeslaArc :: Item -> Creature -> World -> World
shootTeslaArc it cr w = w'
& creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itParams .~ ip
& creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
where
(w',ip) = shootTeslaArc' (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
@@ -385,7 +385,7 @@ shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam
where
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
phasev = _phaseV . _itParams $ _crInv cr IM.! _crInvSel cr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
dam = _lasDamage $ _itParams it
@@ -405,7 +405,7 @@ shootDualLaser it cr w = w'
| otherwise = mwp
dirl = argV $ mwp' -.- posl
dirr = argV $ mwp' -.- posr
phasev = _phaseV . _itParams $ _crInv cr IM.! _crInvSel cr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
dam = _lasDamage $ _itParams it
drawBeam :: Beam -> Picture
@@ -448,7 +448,7 @@ aTractorBeam _ cr w = w & plNew props pjID (tractorBeamAt spos outpos dir power)
dir = _crDir cr
outpos = collidePointWalls cpos xpos
$ wallsAlongLine cpos xpos w
power = _attractionPower . _itParams $ _crInv cr IM.! _crInvSel cr
power = _attractionPower . _itParams $ _crInv cr IM.! crSel cr
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> Prop
tractorBeamAt pos outpos dir power = ProjectileTimed
+3 -3
View File
@@ -99,7 +99,7 @@ throwGrenade thePayload cr w = setWp $ removePict $ over props addG w
, _pjPayload = thePayload
, _pjTimer = fuseTime
}
j = _crInvSel cr
j = crSel cr
removePict = set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> (,) emptySH blank
i = IM.newKey $ _props w
v' = 1 / (fromIntegral fuseTime * _cameraZoom w) *.* rotateV (_cameraRot w) ( _mousePos w)
@@ -233,7 +233,7 @@ throwRemoteBomb cr w = setLocation
v' = 0.02 / _cameraZoom w *.* rotateV (_cameraRot w) ( _mousePos w)
v | magV v' > 6 = 6 *.* normalizeV v'
| otherwise = v'
j = _crInvSel cr
j = crSel cr
-- resetName = set (creatures . ix cid . crInv . ix j . itName) "REMOTE"
removePict = set (creatures . ix cid . crInv . ix j . itEquipPict) $ \ _ _ -> emptyBlank
resetFire = set (creatures . ix cid . crInv . ix j . itUse . rUse)
@@ -266,7 +266,7 @@ explodeRemoteBomb itid pjid cr w
resetPict = set (creatures . ix cid . crInv . ix j . itEquipPict )
(pictureWeaponAim $ \_ -> (,) emptySH remoteBombUnarmedPic)
-- resetScope = creatures . ix cid . crInv . ix j . itScope . _Just . scopePos .~ (0,0)
j = _crInvSel $ _creatures w IM.! cid
j = crSel $ _creatures w IM.! cid
remoteBombPic
:: Int -- ^ time
-> Picture
+2 -2
View File
@@ -293,7 +293,7 @@ fireRemoteShell it cr w = set (creatures . ix cid . crInv . ix j . itUse . rUse)
cid = _crID cr
addRemRocket = makeShell it cr $ \pj ->
decTimMvVel pj . setRemoteScope itid pj . moveRemoteShell cid itid pj
j = _crInvSel cr
j = crSel cr
moveRemoteShell :: Int -> Int -> Prop -> World -> World
moveRemoteShell cid itid pj w
@@ -320,7 +320,7 @@ moveRemoteShell cid itid pj w
newPos = oldPos +.+ vel
newdir
| SDL.ButtonRight `S.member` _mouseButtons w
&& w ^? creatures . ix cid . crInvSel == w ^? itemPositions . ix itid . ipInvId
&& w ^? creatures . ix cid . crInvSel . iselPos == w ^? itemPositions . ix itid . ipInvId
= _cameraRot w + argV (_mousePos w)
| otherwise = _pjDir pj
accel = rotateV newdir (V2 2 0)
+1 -1
View File
@@ -173,7 +173,7 @@ overNozzles' :: (Item -> Creature -> World -> Nozzle -> (World,Nozzle))
overNozzles' eff it cr w = neww & creatures . ix cid . crInv . ix i . itParams . sprayNozzles .~ newNozzles
where
cid = _crID cr
i = _crInvSel $ _creatures w IM.! cid
i = crSel $ _creatures w IM.! cid
(neww,newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it)
overNozzle :: (Nozzle -> Item -> Creature -> World -> World)
+1 -1
View File
@@ -12,7 +12,7 @@ useTargetPos
-> Creature
-> World
-> World
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . tgPos of
useTargetPos f cr w = case cr ^? crInv . ix (crSel cr) . itTargeting . tgPos of
Nothing -> w
Just p -> f p cr w
+10 -10
View File
@@ -140,7 +140,7 @@ ammoHammerCheck eff it cr w
_ -> setHammerDown w
where
cid = _crID cr
setHammerDown = creatures . ix cid . crInv . ix (_crInvSel cr) . itUse
setHammerDown = creatures . ix cid . crInv . ix (crSel cr) . itUse
. useHammer . hammerPosition .~ HammerDown
@@ -170,7 +170,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
fastRate = _rateMinMax . _useDelay $ _itUse item
startRate = _rateMaxMax . _useDelay $ _itUse item
cid = _crID cr
itRef = _crInvSel cr
itRef = crSel cr
pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = crWeaponReady cr && _rateTime (_useDelay (_itUse item)) == 1
@@ -190,7 +190,7 @@ withWarmUp soundID f item cr w
& f item cr
where
cid = _crID cr
itRef = _crInvSel cr
itRef = crSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef
curWarmUp = _warmTime . _useDelay $ _itUse item
maxWarmUp = _warmMax . _useDelay $ _itUse item
@@ -283,14 +283,14 @@ withSidePushAfterI maxSide eff item cr w = over (creatures . ix cid) push . eff
(pushAmount, g) = randomR (-maxSide,maxSide) $ _randGen w
useAllAmmo :: ChainEffect
useAllAmmo eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded .~ 0)
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded .~ 0)
useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded
%~ (max 0 . subtract amAmount))
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr = eff item cr
. (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itConsumption . laLoaded -~ amAmount)
. (creatures . ix (_crID cr) . crInv . ix (crSel cr) . itConsumption . laLoaded -~ amAmount)
{- |
Applies a world effect after an item use cooldown check. -}
useTimeCheck :: ChainEffect
@@ -299,7 +299,7 @@ useTimeCheck f item cr w = case item ^? itUse . useDelay . rateTime of
_ -> w
where
cid = _crID cr
setUseTime = creatures . ix cid . crInv . ix (_crInvSel cr) . itUse . useDelay . rateTime +~ userate
setUseTime = creatures . ix cid . crInv . ix (crSel cr) . itUse . useDelay . rateTime +~ userate
userate = fromMaybe 0 $ item ^? itUse . useDelay . rateMax
{- | Applies a world effect after a hammer position check. -}
hammerCheckI :: ChainEffect
@@ -308,7 +308,7 @@ hammerCheckI f it cr w = case it ^? itUse . useHammer . hammerPosition of
_ -> setHammerDown w
where
cid = _crID cr
setHammerDown = creatures . ix cid . crInv . ix (_crInvSel cr) . itUse
setHammerDown = creatures . ix cid . crInv . ix (crSel cr) . itUse
. useHammer . hammerPosition .~ HammerDown
{- | Applies a world effect after an ammo check. -}
-- this should be made "safe" incase there is no _rateTime
@@ -321,7 +321,7 @@ ammoUseCheck f item cr w
| otherwise = w
where
cid = _crID cr
itRef = _crInvSel cr
itRef = crSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = crWeaponReady cr
&& _rateTime (_useDelay (_itUse item)) == 0
@@ -366,7 +366,7 @@ shootL f item cr w
withItem :: (Item -> ChainEffect) -> ChainEffect
withItem g f it = g it f it
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
withItemUpdate up g f it cr = g it f it cr . (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) %~ up)
withItemUpdate up g f it cr = g it f it cr . (creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr = eff item cr
. over tempLightSources (theTLS :)