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