Remove heldParams record

This commit is contained in:
2025-06-04 13:33:44 +01:00
parent 0cb7b54180
commit 9797f610aa
7 changed files with 38 additions and 28 deletions
+9 -9
View File
@@ -33,7 +33,7 @@ data ItemUse
= UseHeld
{ _heldDelay :: UseDelay
, _heldMuzzles :: [Muzzle]
, _heldParams :: HeldParams
-- , _heldParams :: HeldParams
, _heldFrame :: Int
, _heldUseEffect :: HeldUseEffect
}
@@ -73,12 +73,12 @@ data AttachParams
| APNothing
deriving (Eq, Show, Read)
data HeldParams
= DefaultHeldParams
| GasSprayParams { _weaponInvLock :: Int }
| BeamShooterParams
| BulletShooterParams { _weaponInvLock :: Int }
deriving (Eq, Show, Read) --Generic, Flat)
--data HeldParams
-- = DefaultHeldParams
-- | GasSprayParams { _weaponInvLock :: Int }
-- | BeamShooterParams
-- | BulletShooterParams { _weaponInvLock :: Int }
-- deriving (Eq, Show, Read) --Generic, Flat)
data AmmoParams
= BulletParams {_ampBullet :: Bullet}
@@ -149,7 +149,7 @@ makeLenses ''ItemUse
--makeLenses ''AimParams
makeLenses ''Muzzle
makeLenses ''HeldParams
--makeLenses ''HeldParams
makeLenses ''AttachParams
makeLenses ''AmmoParams
makeLenses ''MuzzleEffect
@@ -163,7 +163,7 @@ deriveJSON defaultOptions ''UseCondition
deriveJSON defaultOptions ''MuzzleEffect
deriveJSON defaultOptions ''FlareType
deriveJSON defaultOptions ''AmmoParams
deriveJSON defaultOptions ''HeldParams
--deriveJSON defaultOptions ''HeldParams
deriveJSON defaultOptions ''AmmoPerShot
deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AttachParams
+3 -3
View File
@@ -27,9 +27,9 @@ defaultHeldUse :: ItemUse
defaultHeldUse = UseHeld
{ _heldDelay = FixedRate{_rateMax = 8, _rateTimeLastUsed = 0}
, _heldMuzzles = defaultMuzzles
, _heldParams = BulletShooterParams
{ _weaponInvLock = 0
}
-- , _heldParams = BulletShooterParams
-- { _weaponInvLock = 0
-- }
, _heldFrame = 0
, _heldUseEffect = NoHeldUseEffect
}
+16 -4
View File
@@ -231,15 +231,27 @@ itemSidePush = \case
BLINKERUNSAFE -> 0
applyInvLock :: Item -> Creature -> World -> World
applyInvLock itm cr = case itm ^? itUse . heldParams . weaponInvLock of
Just i
| i > 0 ->
applyInvLock itm cr
| i <- itemInvLock itm
, i > 0 =
(cWorld . lWorld . delayedEvents .:~ (i, UnlockInv cid))
. lockInv cid
_ -> id
| otherwise = id
where
cid = _crID cr
itemInvLock :: Item -> Int
itemInvLock itm = case itm ^. itType of
HELD hit -> heldItemInvLock hit
_ -> 0
heldItemInvLock :: HeldItemType -> Int
heldItemInvLock = \case
FLAMESPITTER -> 10
VOLLEYGUN i -> i + 1
BURSTRIFLE -> 7
_ -> 0
applySoundCME :: Item -> Creature -> World -> World
applySoundCME itm cr = fromMaybe id $ do
(soundid, x) <- bgunSound itm
+3 -3
View File
@@ -19,7 +19,7 @@ sparkGun =
teslaGun :: Item
teslaGun =
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams-- (Just (elecCrackleS, 2))
-- & itUse . heldParams .~ BeamShooterParams-- (Just (elecCrackleS, 2))
& itParams .~ teslaParams
& itUse . heldDelay .~ NoDelay
& itUse . heldMuzzles . ix 0 . mzPos .~ V2 10 0
@@ -41,7 +41,7 @@ teslaParams =
laser :: Item
laser =
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams-- Nothing
-- & itUse . heldParams .~ BeamShooterParams-- Nothing
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldDelay .~ NoDelay
& itUse . heldMuzzles . ix 0 . mzPos .~ V2 6 0
@@ -60,7 +60,7 @@ laser =
tractorGun :: Item
tractorGun =
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams
-- & itUse . heldParams .~ BeamShooterParams
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-2
View File
@@ -37,7 +37,6 @@ volleyGun i =
<*> pure (UseExactly 1)
<*> ZipList [0..i-1]
)
& itUse . heldParams . weaponInvLock .~ i + 1
-- & itUse . heldParams . recoil .~ 30
& itType .~ HELD (VOLLEYGUN i)
& itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
@@ -74,7 +73,6 @@ burstRifle =
& itType .~ HELD BURSTRIFLE
& itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 6
& itUse . heldParams . weaponInvLock .~ 7
& itUse . heldMuzzles %~ doreplicate
where
doreplicate (x:_) = [x,x & mzFrame .~ 3,x & mzFrame .~ 6]
+5 -5
View File
@@ -25,7 +25,7 @@ flameSpitter =
flameThrower
& itType .~ HELD FLAMESPITTER
& itUse . heldDelay .~ FixedRate{_rateMax = 3, _rateTimeLastUsed = 0}
& itUse . heldParams . weaponInvLock .~ 10
-- & itUse . heldParams . weaponInvLock .~ 10
-- & itUse . heldParams . weaponRepeat .~ [1..9]
& itUse . heldMuzzles . ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
@@ -79,7 +79,7 @@ flameThrower =
]
& itAmmoSlots .~ singleAmmo GasAmmo
& itType .~ HELD FLAMETHROWER
& itUse . heldParams .~ GasSprayParams
{ _weaponInvLock = 0
-- , _weaponRepeat = mempty
}
-- & itUse . heldParams .~ GasSprayParams
-- { _weaponInvLock = 0
---- , _weaponRepeat = mempty
-- }
+2 -2
View File
@@ -41,7 +41,7 @@ detector dt =
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
-- & itUse . heldParams .~ DefaultHeldParams
& itType .~ DETECTOR dt
& itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleDetector
& itUse . heldMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 100
@@ -53,7 +53,7 @@ blinker =
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
-- & itUse . heldParams .~ DefaultHeldParams
& itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleBlink
& itUse . heldMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 10000000
& itType .~ HELD BLINKER