Partial removal of reloading

This commit is contained in:
2024-09-08 10:21:35 +01:00
parent 581d2494dc
commit e03c8dd830
16 changed files with 256 additions and 187 deletions
+86 -1
View File
@@ -1 +1,86 @@
All good (615 modules, at 22:22:36)
/home/justin/Haskell/loop/src/Dodge/Creature/State.hs:26:1-22: warning: [-Wunused-imports]
The import of Dodge.Reloading is redundant
|
26 | import Dodge.Reloading
| ^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:20:1-22: warning: [-Wunused-imports]
The import of Dodge.Reloading is redundant
|
20 | import Dodge.Reloading
| ^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:118:5-14: warning: [-Wunused-local-binds]
Defined but not used: hammerTest
|
118 | hammerTest f = case _crHammerPosition cr of
| ^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Creature/Impulse/UseItem.hs:121:5-15: warning: [-Wunused-local-binds]
Defined but not used: setuhamdown
|
121 | setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
| ^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Inventory.hs:28:1-22: warning: [-Wunused-imports]
The import of Dodge.Reloading is redundant
|
28 | import Dodge.Reloading
| ^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Item/Ammo.hs:7:1-29: warning: [-Wunused-imports]
The import of Dodge.Reloading.Action is redundant
|
7 | import Dodge.Reloading.Action
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading/Action.hs:3:1-49: warning: [-Wunused-imports]
The import of Dodge.Data.Item.Use.Consumption.LoadAction is redundant
|
3 | import Dodge.Data.Item.Use.Consumption.LoadAction
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading/Action.hs:4:1-49: warning: [-Wunused-imports]
The import of Dodge.SoundLogic.ExternallyGeneratedSounds is redundant
|
4 | import Dodge.SoundLogic.ExternallyGeneratedSounds
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/CreatureEffect.hs:(50,13)-(54,28): warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: CrIsReloading
|
50 | doCrBl cb = case cb of
| ^^^^^^^^^^...
/home/justin/Haskell/loop/src/Dodge/Creature/Statistics.hs:8:1-26: warning: [-Wunused-imports]
The import of Dodge.Creature.Test is redundant
|
8 | import Dodge.Creature.Test
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Item/Weapon/TriggerType.hs:72:1-22: warning: [-Wunused-imports]
The import of Dodge.Reloading is redundant
|
72 | import Dodge.Reloading
| ^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Projectile/Create.hs:4:1-22: warning: [-Wunused-imports]
The import of Dodge.Reloading is redundant
|
4 | import Dodge.Reloading
| ^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading.hs:7:1-19: warning: [-Wunused-imports]
The import of Control.Lens is redundant
|
7 | import Control.Lens
| ^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading.hs:8:1-17: warning: [-Wunused-imports]
The import of Data.Maybe is redundant
|
8 | import Data.Maybe
| ^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading.hs:9:1-26: warning: [-Wunused-imports]
The import of Dodge.Data.Creature is redundant
|
9 | import Dodge.Data.Creature
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Reloading.hs:10:1-20: warning: [-Wunused-imports]
The import of Control.Monad is redundant
|
10 | import Control.Monad
| ^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs:11:1-17: warning: [-Wunused-imports]
The import of Sound.Data is redundant
|
11 | import Sound.Data
| ^^^^^^^^^^^^^^^^^
+4 -2
View File
@@ -106,11 +106,13 @@ useItemLeftClick cr w = fromMaybe w $ do
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
ituse <- cr ^? crInv . ix invid . itUse
case ituse of
HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle)
--HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle)
HeldUse{} -> return w
ConsumeUse{} -> return $ useItemRightClick cr w
EquipUse{} -> return $ useItemRightClick cr w
LeftUse{} -> return $ useItemRightClick cr w
AmmoMagUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle)
AmmoMagUse{} -> return w
--AmmoMagUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crReloadToggle)
_ -> Nothing
where
hammerTest f = case _crHammerPosition cr of
+14 -14
View File
@@ -145,7 +145,7 @@ internalHammerUpdate :: Creature -> World -> World
internalHammerUpdate cr =
cWorld . lWorld . creatures . ix (_crID cr)
%~ ( (crHammerPosition %~ moveHammerUp)
. stepReloading
-- . stepReloading
. updateMovement
)
@@ -233,7 +233,7 @@ equipmentEffects cr = flip (foldl' $ flip $ useEquipment cr) (IM.keys $ _crInvEq
invSideEff :: Creature -> World -> World
invSideEff cr w =
updateTargeting (crGetTargeting cr) cr $
weaponReloadSounds cr $
-- weaponReloadSounds cr $
IM.foldl' f w (_crInv cr)
where
-- be careful with side effects that affect creature targeting
@@ -288,18 +288,18 @@ crGetTargeting cr = do
guard (canAttachTargeting tt itm)
return tt
weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just ReloadAction{_reloadAction = la} ->
soundContinue
(CrReloadSound cid)
(_crPos cr)
(_actionSound la)
(Just 1)
w
_ -> w
where
cid = _crID cr
--weaponReloadSounds :: Creature -> World -> World
--weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
-- Just ReloadAction{_reloadAction = la} ->
-- soundContinue
-- (CrReloadSound cid)
-- (_crPos cr)
-- (_actionSound la)
-- (Just 1)
-- w
-- _ -> w
-- where
-- cid = _crID cr
updateMovement :: Creature -> Creature
updateMovement cr
+2 -1
View File
@@ -36,7 +36,8 @@ crCurrentEquipment cr =
strFromHeldItem :: Creature -> Int
strFromHeldItem cr
| _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
| _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix i . itUse . heldAim . aimWeight
| otherwise = 0
+5 -5
View File
@@ -7,7 +7,7 @@ in fact a creature with that id need not exist.
-}
module Dodge.Creature.Test (
crIsAiming,
crIsReloading,
-- crIsReloading,
crIsArmouredFrom,
oneH,
twists,
@@ -33,10 +33,10 @@ import Dodge.Base.Collide
import Dodge.Data.World
import Geometry
crIsReloading :: Creature -> Bool
crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just ReloadAction{} -> True
_ -> False
--crIsReloading :: Creature -> Bool
--crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
-- Just ReloadAction{} -> True
-- _ -> False
-- Assumes the ammotype below the selected item is correct
crWeaponReady :: Creature -> Bool
+1 -1
View File
@@ -49,7 +49,7 @@ doWdCrBl wcb = case wcb of
doCrBl :: CrBl -> Creature -> Bool
doCrBl cb = case cb of
CrCanShoot -> crCanShoot
CrIsReloading -> crIsReloading
-- CrIsReloading -> crIsReloading
CrIsAiming -> crIsAiming
CrIsAnimate -> isAnimate
+1 -3
View File
@@ -20,9 +20,7 @@ import Dodge.Data.Item.Use.Consumption.LoadAction
data ReloadStatus = ReloadStatus
{ _iaMax :: Int
, _iaLoaded :: Int
, _iaPrimed :: Bool
, _iaCycle :: [LoadAction]
, _iaProgress :: Maybe [LoadAction]
-- , _iaPrimed :: Bool
}
deriving (Eq, Show, Read) --Generic, Flat)
@@ -10,13 +10,6 @@ import Data.Aeson
import Data.Aeson.TH
import Sound.Data
data LoadAction
= LoadEject {_actionTime :: Int, _actionSound :: SoundID}
| LoadInsert {_actionTime :: Int, _actionSound :: SoundID}
| LoadAdd {_actionTime :: Int, _actionSound :: SoundID, _insertMax :: Int}
| LoadPrime {_actionTime :: Int, _actionSound :: SoundID}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Manipulation -- should be ManipulatedObject?
-- = InvSel {_isel :: SelPos}
= Manipulator {_manObject :: ManipulatedObject
@@ -42,16 +35,13 @@ data InventoryManipulation
data InvSelAction
= NoInvSelAction
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _reloadInvID :: Int}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''LoadAction
makeLenses ''ManipulatedObject
makeLenses ''Manipulation
makeLenses ''InventoryManipulation
makeLenses ''NearbyManipulation
makeLenses ''InvSelAction
deriveJSON defaultOptions ''LoadAction
deriveJSON defaultOptions ''InvSelAction
deriveJSON defaultOptions ''InventoryManipulation
deriveJSON defaultOptions ''NearbyManipulation
+1 -1
View File
@@ -50,7 +50,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
& worldEventFlags . at InventoryChange ?~ ()
_ ->
w
& pointcid %~ crCancelReloading
-- & pointcid %~ crCancelReloading
& doanyitemeffect
& dounequipfunction --the ordering of these is
& pointcid . crInv %~ f -- important
-10
View File
@@ -19,9 +19,6 @@ tinMag =
ReloadStatus
{ _iaMax = 15
, _iaLoaded = 15
, _iaPrimed = True
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
, _iaProgress = Nothing
}
}
@@ -31,7 +28,6 @@ revolveMag =
& itType . iyBase .~ AMMOMAG REVOLVEMAG
& itUse . amagLoadStatus . iaMax .~ 6
& itUse . amagLoadStatus . iaLoaded .~ 6
& itUse . amagLoadStatus . iaCycle .~ [loadPartialInsert 10 1]
drumMag :: Item
drumMag =
@@ -59,9 +55,6 @@ shellMag =
ReloadStatus
{ _iaMax = 1
, _iaLoaded = 1
, _iaPrimed = True
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
, _iaProgress = Nothing
}
, _amagType = ProjectileAmmo
}
@@ -77,8 +70,5 @@ battery =
ReloadStatus
{ _iaMax = 100
, _iaLoaded = 100
, _iaPrimed = True
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
, _iaProgress = Nothing
}
}
+19 -16
View File
@@ -123,8 +123,8 @@ itemNumberDisplay cr itm = case iu of
EquipUse{} -> showEquipmentNumber cr itm
CraftUse x -> [show $ x ^. getItAmount]
ConsumeUse {_useAmount = x} -> [show $ x ^. getItAmount]
AttachUse {} -> [showReloadProgress cr itm]
AmmoMagUse {} -> [showReloadProgress cr itm]
AttachUse {} -> [] --[showReloadProgress cr itm]
AmmoMagUse {} -> [showLoadedAmount itm]
-- this could be cleaner here...
where
iu = itm ^?! itUse
@@ -152,12 +152,15 @@ showEquipmentNumber _ itm = case _eeUse ee of
-- )
-- <|> Just [x]
showReloadProgress :: Creature -> Item -> String
showReloadProgress _ itm = fromMaybe [] $ do
ia <- itm ^? itUse . amagLoadStatus
return $ case ia ^? iaProgress . _Just . ix 0 of
Nothing -> maybe "" show $ ia ^? iaLoaded
Just la -> showLoadActionType la ia
showLoadedAmount :: Item -> String
showLoadedAmount itm = fromMaybe [] $ fmap show $ itm ^? itUse . amagLoadStatus . iaLoaded
--showReloadProgress :: Creature -> Item -> String
--showReloadProgress _ itm = fromMaybe [] $ do
-- ia <- itm ^? itUse . amagLoadStatus
-- return $ case ia ^? iaProgress . _Just . ix 0 of
-- Nothing -> maybe "" show $ ia ^? iaLoaded
-- Just la -> showLoadActionType la ia
--showReloadProgress :: Creature -> Item -> String
--showReloadProgress cr itm = case ic ^? laSource of
-- Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
@@ -171,14 +174,14 @@ showReloadProgress _ itm = fromMaybe [] $ do
-- where
-- ic = itm ^?! itUse . heldConsumption
showLoadActionType :: LoadAction -> ReloadStatus -> String
showLoadActionType la as = case la of
LoadEject{} -> "E"
LoadInsert{} -> "L"
LoadAdd{} -> "A" ++ x
LoadPrime{} -> "P"
where
x = maybe "" show $ as ^? iaLoaded
--showLoadActionType :: LoadAction -> ReloadStatus -> String
--showLoadActionType la as = case la of
-- LoadEject{} -> "E"
-- LoadInsert{} -> "L"
-- LoadAdd{} -> "A" ++ x
-- LoadPrime{} -> "P"
-- where
-- x = maybe "" show $ as ^? iaLoaded
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
+1 -1
View File
@@ -148,7 +148,7 @@ ammoCheckI eff ams itm cr w = fromMaybe (failsound w) $ do
matype <- ams ^? ix 0 . itUse . amagType
iatype <- itm ^? itUse . heldConsumption . ix 0
guard $ matype == iatype
return $ eff ams itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
return $ eff ams itm cr $ w -- & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
+3 -2
View File
@@ -22,10 +22,11 @@ createProjectile ammoitem muz itm cr = fromMaybe failsound $ do
CreateShell -> fireShell ammoitem muz itm cr . extrafuncs j
CreateTrackingShell -> fireTrackingShell ammoitem muz itm cr . extrafuncs j
where
extrafuncs j = cancelanyreloading . startthesound . useammo j
--extrafuncs j = cancelanyreloading . startthesound . useammo j
extrafuncs j = startthesound . useammo j
useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
--cancelanyreloading = cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
-- the sound should be moved to the projectile firing
startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
+107 -107
View File
@@ -1,7 +1,7 @@
module Dodge.Reloading (
crCancelReloading,
crReloadToggle,
stepReloading,
-- crCancelReloading,
-- crReloadToggle,
-- stepReloading,
) where
import Control.Lens
@@ -10,108 +10,108 @@ import Dodge.Data.Creature
import Control.Monad
--import Data.Monoid
crCancelReloading :: Creature -> Creature
crCancelReloading cr =
cr
& updateProgress
& crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
where
updateProgress = fromMaybe id $ do
InInventory (SelItem i _) <- cr ^? crManipulation . manObject
return $
crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress
%~ const Nothing
stepReloading :: Creature -> Creature
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
Just (SelItem _ (ReloadAction x la j))
| x > 0 ->
cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
| otherwise ->
cr
& crInv . ix j . itUse . amagLoadStatus %~ doLoadAction la
& crInv . ix j . itUse . amagLoadStatus %~ rotateActionProgress
& tryNextLoadAction
_ -> cr
tryNextLoadAction :: Creature -> Creature
tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
Just (SelItem i _) -> case cr ^? crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress . _Just . ix 0 of
Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
Just la ->
cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
_ -> cr
crReloadToggle :: Creature -> Creature
crReloadToggle cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just NoInvSelAction -> cr & tryStartLoading
_ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
tryStartLoading :: Creature -> Creature
tryStartLoading cr = fromMaybe cr $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
magtypes <- cr ^? crInv . ix i . itUse . heldConsumption
--let mags = cr ^.. crInv . dropping (i + 1) traverse -- note this gets all items below the manipulated
let mags = cr ^.. crInv . dropping i traverse
iaj <- listToMaybe . catMaybes $ zipWith tryStartLoadMagazine mags magtypes
return $ startLoading iaj cr
tryStartLoadMagazine :: Item -> AmmoType -> Maybe (ReloadStatus, Int)
tryStartLoadMagazine mag atype = do
magat <- mag ^? itUse . amagType
guard $ magat == atype
ia <- mag ^? itUse . amagLoadStatus
maxammo <- ia ^? iaMax
loadedammo <- ia ^? iaLoaded
guard $ loadedammo < maxammo
j <- mag ^? itLocation . ipInvID
return (ia, j)
-- case as of
-- InternalSource ia -> return $ startLoading ia cr
-- AboveSource -> return cr
startLoading :: (ReloadStatus,Int) -> Creature -> Creature
startLoading (ic,j) cr = case ic ^? iaProgress . _Just . ix 0 of
Just la -> cr & startLoadingStep la j
Nothing -> case ic ^. iaCycle of
[] -> error "item has empty load cycle"
_ | _iaLoaded ic >= _iaMax ic -> cr -- THIS SHOULD TRY PUSHING TO THE NEXT MAGAZINE
(la : las) -> fromMaybe (error "item loading error") $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
return $
cr & startLoadingStep la i
& crInv . ix i . itUse . amagLoadStatus . iaProgress ?~ (la : las)
startLoadingStep :: LoadAction
-> Int -- i think this is the inventory position?
-> Creature -> Creature
startLoadingStep la j cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la j
rotateActionProgress :: ReloadStatus -> ReloadStatus
rotateActionProgress ic = case ic ^. iaProgress of
Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las)
_ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic
_ -> ic & iaProgress .~ Nothing
doLoadAction :: LoadAction -> ReloadStatus -> ReloadStatus
doLoadAction la ic = case la of
LoadEject{} -> ic & iaLoaded .~ 0 & iaPrimed .~ False
LoadInsert{} -> ic & iaLoaded .~ _iaMax ic
LoadAdd{_insertMax = x} ->
ic & iaLoaded +~ min x (_iaMax ic - _iaLoaded ic)
LoadPrime{} -> ic & iaPrimed .~ True
--{- | Start reloading if clip is empty. -}
--crAutoReload :: Creature -> Creature
--crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of
-- Just 0 | _posture (_crStance cr) /= Aiming
-- -> cr & ptrItConsumption . reloadState .~ strictify reloadT
-- & ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA)
-- _ -> cr
----crCancelReloading :: Creature -> Creature
--crCancelReloading cr =
-- cr
-- & updateProgress
-- & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
-- where
-- ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption
-- ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption
-- reloadT = cr ^? ptrItConsumption' . reloadTime
-- maxA = fmap itMaxAmmo $ cr ^? crInv . ix (_crInvSel cr)
-- updateProgress = fromMaybe id $ do
-- InInventory (SelItem i _) <- cr ^? crManipulation . manObject
-- return $
-- crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress
-- %~ const Nothing
--
--stepReloading :: Creature -> Creature
--stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
-- Just (SelItem _ (ReloadAction x la j))
-- | x > 0 ->
-- cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
-- | otherwise ->
-- cr
-- & crInv . ix j . itUse . amagLoadStatus %~ doLoadAction la
-- & crInv . ix j . itUse . amagLoadStatus %~ rotateActionProgress
-- & tryNextLoadAction
-- _ -> cr
--
--tryNextLoadAction :: Creature -> Creature
--tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
-- Just (SelItem i _) -> case cr ^? crInv . ix (i + 1) . itUse . amagLoadStatus . iaProgress . _Just . ix 0 of
-- Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
-- Just la ->
-- cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
-- & crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
-- _ -> cr
--
--crReloadToggle :: Creature -> Creature
--crReloadToggle cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
-- Just NoInvSelAction -> cr & tryStartLoading
-- _ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
--
--tryStartLoading :: Creature -> Creature
--tryStartLoading cr = fromMaybe cr $ do
-- i <- cr ^? crManipulation . manObject . inInventory . ispItem
-- magtypes <- cr ^? crInv . ix i . itUse . heldConsumption
-- --let mags = cr ^.. crInv . dropping (i + 1) traverse -- note this gets all items below the manipulated
-- let mags = cr ^.. crInv . dropping i traverse
-- iaj <- listToMaybe . catMaybes $ zipWith tryStartLoadMagazine mags magtypes
-- return $ startLoading iaj cr
--
--tryStartLoadMagazine :: Item -> AmmoType -> Maybe (ReloadStatus, Int)
--tryStartLoadMagazine mag atype = do
-- magat <- mag ^? itUse . amagType
-- guard $ magat == atype
-- ia <- mag ^? itUse . amagLoadStatus
-- maxammo <- ia ^? iaMax
-- loadedammo <- ia ^? iaLoaded
-- guard $ loadedammo < maxammo
-- j <- mag ^? itLocation . ipInvID
-- return (ia, j)
--
---- case as of
---- InternalSource ia -> return $ startLoading ia cr
---- AboveSource -> return cr
--
--startLoading :: (ReloadStatus,Int) -> Creature -> Creature
--startLoading (ic,j) cr = case ic ^? iaProgress . _Just . ix 0 of
-- Just la -> cr & startLoadingStep la j
-- Nothing -> case ic ^. iaCycle of
-- [] -> error "item has empty load cycle"
-- _ | _iaLoaded ic >= _iaMax ic -> cr -- THIS SHOULD TRY PUSHING TO THE NEXT MAGAZINE
-- (la : las) -> fromMaybe (error "item loading error") $ do
-- i <- cr ^? crManipulation . manObject . inInventory . ispItem
-- return $
-- cr & startLoadingStep la i
-- & crInv . ix i . itUse . amagLoadStatus . iaProgress ?~ (la : las)
--
--startLoadingStep :: LoadAction
-- -> Int -- i think this is the inventory position?
-- -> Creature -> Creature
--startLoadingStep la j cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la j
--
--rotateActionProgress :: ReloadStatus -> ReloadStatus
--rotateActionProgress ic = case ic ^. iaProgress of
-- Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las)
-- _ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic
-- _ -> ic & iaProgress .~ Nothing
--
--doLoadAction :: LoadAction -> ReloadStatus -> ReloadStatus
--doLoadAction la ic = case la of
-- LoadEject{} -> ic & iaLoaded .~ 0 & iaPrimed .~ False
-- LoadInsert{} -> ic & iaLoaded .~ _iaMax ic
-- LoadAdd{_insertMax = x} ->
-- ic & iaLoaded +~ min x (_iaMax ic - _iaLoaded ic)
-- LoadPrime{} -> ic & iaPrimed .~ True
--
----{- | Start reloading if clip is empty. -}
----crAutoReload :: Creature -> Creature
----crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of
---- Just 0 | _posture (_crStance cr) /= Aiming
---- -> cr & ptrItConsumption . reloadState .~ strictify reloadT
---- & ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA)
---- _ -> cr
---- where
---- ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption
---- ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption
---- reloadT = cr ^? ptrItConsumption' . reloadTime
---- maxA = fmap itMaxAmmo $ cr ^? crInv . ix (_crInvSel cr)
+11 -11
View File
@@ -3,14 +3,14 @@ module Dodge.Reloading.Action where
import Dodge.Data.Item.Use.Consumption.LoadAction
import Dodge.SoundLogic.ExternallyGeneratedSounds
loadInsert :: Int -> LoadAction
loadInsert x = LoadInsert x insertS
loadPartialInsert :: Int -> Int -> LoadAction
loadPartialInsert x = LoadAdd x insertOneS
loadEject :: Int -> LoadAction
loadEject x = LoadEject x ejectS
loadPrime :: Int -> LoadAction
loadPrime x = LoadPrime x primeS
--loadInsert :: Int -> LoadAction
--loadInsert x = LoadInsert x insertS
--
--loadPartialInsert :: Int -> Int -> LoadAction
--loadPartialInsert x = LoadAdd x insertOneS
--
--loadEject :: Int -> LoadAction
--loadEject x = LoadEject x ejectS
--
--loadPrime :: Int -> LoadAction
--loadPrime x = LoadPrime x primeS
+1 -2
View File
@@ -19,7 +19,6 @@ import Dodge.InputFocus
import Dodge.Inventory
import Dodge.Inventory.Add
import Dodge.Menu
import Dodge.Reloading
import Dodge.Save
import Dodge.SelectionSections
import Dodge.Terminal.LeftButton
@@ -116,7 +115,7 @@ updateInitialPressInGame uv sc = case sc of
ScancodeP -> pauseGame uv
ScancodeF -> over uvWorld youDropItem uv
ScancodeM -> toggleMap uv
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv
-- ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv
ScancodeT -> over uvWorld testEvent uv
ScancodeX -> uv & uvWorld %~ toggleTweakInv
ScancodeC -> toggleCombineInv uv