Cleanup
This commit is contained in:
+28
-28
@@ -419,7 +419,8 @@ itemSidePush = \case
|
||||
|
||||
applyInvLock :: Item -> Creature -> World -> World
|
||||
applyInvLock itm cr = case itemInvLock itm of
|
||||
i | i > 0 && cid == 0 ->
|
||||
i
|
||||
| i > 0 && cid == 0 ->
|
||||
(cWorld . lWorld . delayedEvents .:~ (i, UnlockInv)) . lockInv
|
||||
_ -> id
|
||||
where
|
||||
@@ -619,26 +620,29 @@ heldTorqueAmount = \case
|
||||
|
||||
-- fugly
|
||||
loadMuzzle :: LocationDT OItem -> Creature -> (Bool, World) -> Muzzle -> (Bool, World)
|
||||
loadMuzzle loc cr (b, w) mz = maybe (b, w) (True,) $ do
|
||||
case mz ^. mzAmmoSlot of
|
||||
NoAmmoRequired -> return (useLoadedAmmo loc cr mz Nothing w)
|
||||
as -> do
|
||||
mag <- case as of
|
||||
MagBelow mi _ -> find (isAmmoIntLink mi . (^. dtValue . _2)) (loc ^. locDT . dtLeft)
|
||||
CapacitorSelf _ -> loc ^? locDT
|
||||
CapacitorBelow _ ->
|
||||
find
|
||||
((== PulseBallSF) . (^. dtValue . _2))
|
||||
(loc ^. locDT . dtLeft)
|
||||
mid <- mag ^? dtValue . _1 . itID . unNInt
|
||||
availableammo <- w ^? cWorld . lWorld . items . ix mid . itConsumables . _Just
|
||||
let usedammo = case as ^?! aps of
|
||||
UseUpTo x -> min x availableammo
|
||||
UseExactly x
|
||||
| x <= availableammo -> x
|
||||
| otherwise -> 0
|
||||
guard $ usedammo > 0
|
||||
return $ useLoadedAmmo loc cr mz (Just (usedammo, mag)) w
|
||||
loadMuzzle loc cr (b, w) mz = maybe (b, w) (True,) $ case mz ^. mzAmmoSlot of
|
||||
NoAmmoRequired -> return (useLoadedAmmo loc cr mz Nothing w)
|
||||
as -> do
|
||||
mag <- case as of
|
||||
MagBelow mi _ ->
|
||||
find
|
||||
(isAmmoIntLink mi . (^. dtValue . _2))
|
||||
(loc ^. locDT . dtLeft)
|
||||
CapacitorSelf _ -> loc ^? locDT
|
||||
CapacitorBelow _ ->
|
||||
find
|
||||
((== PulseBallSF) . (^. dtValue . _2))
|
||||
(loc ^. locDT . dtLeft)
|
||||
mid <- mag ^? dtValue . _1 . itID . unNInt
|
||||
availableammo <- w ^? cWorld . lWorld . items . ix mid . itConsumables . _Just
|
||||
let usedammo = case as ^?! aps of
|
||||
UseUpTo x -> min x availableammo
|
||||
UseExactly x
|
||||
| x <= availableammo -> x
|
||||
| otherwise -> 0
|
||||
guard $ usedammo > 0
|
||||
return $ useLoadedAmmo loc cr mz (Just (usedammo, mag)) $
|
||||
removeAmmoFromMag usedammo mid w
|
||||
|
||||
makeMuzzleFlare :: Muzzle -> LocationDT OItem -> Creature -> World -> World
|
||||
makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
|
||||
@@ -716,7 +720,7 @@ useLoadedAmmo ::
|
||||
World ->
|
||||
World
|
||||
useLoadedAmmo loc cr mz m w =
|
||||
removeAmmoFromMag m . makeMuzzleFlare mz loc cr $ case _mzEffect mz of
|
||||
makeMuzzleFlare mz loc cr $ case _mzEffect mz of
|
||||
MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w
|
||||
MuzzleLaser -> creatureShootLaser loc cr mz w
|
||||
MuzzlePulseLaser -> creatureShootPulseLaser loc cr mz w
|
||||
@@ -912,12 +916,8 @@ shootPulseBall p dir w =
|
||||
where
|
||||
i = IM.newKey $ w ^. cWorld . lWorld . pulseBalls
|
||||
|
||||
--removeAmmoFromMag :: Int -> Maybe Int -> Creature -> World -> World
|
||||
removeAmmoFromMag :: Maybe (Int, DTree OItem) -> World -> World
|
||||
removeAmmoFromMag m = fromMaybe id $ do
|
||||
(x, magtree) <- m
|
||||
magid <- magtree ^? dtValue . _1 . itID . unNInt
|
||||
return $
|
||||
removeAmmoFromMag :: Int -> Int -> World -> World
|
||||
removeAmmoFromMag x magid =
|
||||
cWorld . lWorld . items
|
||||
. ix magid
|
||||
. itConsumables
|
||||
|
||||
Reference in New Issue
Block a user