Move UseDelay out of records

This commit is contained in:
2025-06-05 11:00:17 +01:00
parent 289bbcc8a9
commit c8a04b8b1e
16 changed files with 226 additions and 217 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -31,10 +31,10 @@ import Geometry.Data
data ItemUse
= UseHeld
{ _heldDelay :: UseDelay
-- , _heldMuzzles :: [Muzzle]
, _heldFrame :: Int
}
-- { --_heldDelay :: UseDelay
---- , _heldMuzzles :: [Muzzle]
---- _heldFrame :: Int
-- }
| UseEquip {_uequipEffect :: EquipEffect}
| UseAttach {_uaParams :: AttachParams}
| UseInt {_uInt :: Int}
+1 -1
View File
@@ -23,7 +23,7 @@ defaultHeldItem =
, _itTargeting = NoItTargeting
, _itAmmoSlots = mempty
, _itLocation = InVoid
, _itUse = defaultHeldUse
, _itUse = UseHeld
, _itParams = NoParams
, _itUseCondition = UseableWhenAimed
, _itScroll = NoItemScroll
+5 -6
View File
@@ -12,9 +12,8 @@ defaultEquipUse =
{ _uequipEffect = defaultEquip
}
defaultHeldUse :: ItemUse
defaultHeldUse =
UseHeld
{ _heldDelay = FixedRate{_rateMax = 8} --, _rateTimeLastUsed = 0}
, _heldFrame = 0
}
--defaultHeldUse :: ItemUse
--defaultHeldUse =
-- UseHeld
-- { _heldFrame = 0
-- }
+10 -9
View File
@@ -10,6 +10,7 @@ module Dodge.HeldUse (
heldEffectMuzzles,
) where
import Dodge.Item.UseDelay
import Dodge.Base
import Color
import Control.Applicative
@@ -110,24 +111,24 @@ hammerCheck f pt it cr
-- | Applies a world effect after an item use cooldown check.
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
Just (FixedRate rate)
useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
FixedRate rate
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
Just FixedRate{} -> w
FixedRate{} -> w
--Just (WarmUpNoDelay wt wm ws)
Just (WarmUpNoDelay wm ws)
WarmUpNoDelay wm ws
-- | wt < wm ->
| _wTime (_itParams $ _ldtValue item) < wm ->
w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~ 2
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 2
Just (WarmUpNoDelay wm _) ->
WarmUpNoDelay wm _ ->
f item cr w
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime .~ (wm + 1)
Just NoDelay -> f item cr w
Nothing -> w
NoDelay -> f item cr w
--Nothing -> w
where
lastused = item ^. ldtValue . itTimeLastUsed
cid = _crID cr
@@ -625,7 +626,7 @@ loadMuzzle ::
Muzzle ->
(LabelDoubleTree ComposeLinkType Item, Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item))
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
-- guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
let as = _mzAmmoSlot mz
amamount = _mzAmmoPerShot mz
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
@@ -1171,7 +1172,7 @@ mcShootLaser _ mc =
mcShootAuto :: Item -> Machine -> World -> World
mcShootAuto itm mc w
| Just (FixedRate rate) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
| Just (FixedRate rate) <- useDelay <$> mc ^? mcType . mctTurret . tuWeapon -- . itUse . heldDelay
, w ^. cWorld . lWorld . lClock - rate > lastused =
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
+2 -1
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Display (
itemInternalValue,
) where
import Dodge.Item.UseDelay
import ShortShow
import Data.Maybe
import Dodge.Data.World
@@ -41,7 +42,7 @@ itemInternalValue itm
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
maybeWarmupStatus it = case useDelay it ^? warmMax of
Nothing -> Nothing
--Just m -> case m - (_warmTime . _heldDelay $ _itUse it) of
Just m -> case m - (_wTime $ _itParams it) of
+2 -2
View File
@@ -21,7 +21,7 @@ teslaGun =
defaultHeldItem
-- & itUse . heldParams .~ BeamShooterParams-- (Just (elecCrackleS, 2))
& itParams .~ teslaParams
& itUse . heldDelay .~ NoDelay
-- & itUse . heldDelay .~ NoDelay
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 10 0
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ TeslaGunFlare
@@ -43,7 +43,7 @@ laser =
defaultHeldItem
-- & itUse . heldParams .~ BeamShooterParams-- Nothing
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldDelay .~ NoDelay
-- & itUse . heldDelay .~ NoDelay
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 6 0
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ LasGunFlare
+5 -6
View File
@@ -7,7 +7,6 @@ module Dodge.Item.Held.Cane (
miniGunX,
) where
import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Data.Item
import Dodge.Default
import qualified Data.IntMap.Strict as IM
@@ -17,7 +16,7 @@ defaultBangCane :: Item
defaultBangCane =
defaultBulletWeapon
-- & itUse . heldParams . recoil .~ 50
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMods .~ BangCaneMod
-- & itUse . heldAim . aimHandlePos .~ 5
@@ -56,14 +55,14 @@ burstRifle =
rifle
& itType .~ HELD BURSTRIFLE
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldDelay . rateMax .~ 6
miniGunX :: Int -> Item
miniGunX i =
autoRifle
& itUse . heldDelay .~ WarmUpNoDelay{
--_warmTime = 0,
_warmMax = 100, _warmSound = crankSlowS}
-- & itUse . heldDelay .~ WarmUpNoDelay{
-- --_warmTime = 0,
-- _warmMax = 100, _warmSound = crankSlowS}
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
-- & itUse . heldMuzzles
-- .~ replicate i
+1 -1
View File
@@ -13,7 +13,7 @@ import Dodge.Default.Item
bangCone :: Item
bangCone =
defaultBulletWeapon
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldDelay . rateMax .~ 20
-- & itUse . heldMuzzles
-- .~ [Muzzle (V2 15 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 0]
& itType .~ HELD BANGCONE
+1 -1
View File
@@ -14,7 +14,7 @@ import qualified IntMapHelp as IM
rLauncher :: Item
rLauncher =
defaultHeldItem
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldDelay . rateMax .~ 20
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleRLauncher
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 20 0
+1 -1
View File
@@ -18,7 +18,7 @@ import LensHelp
bangRod :: Item
bangRod =
defaultBulletWeapon
& itUse . heldDelay . rateMax .~ 12
-- & itUse . heldDelay . rateMax .~ 12
& itType .~ HELD BANGROD
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ HeavySmokeFlare
+2 -2
View File
@@ -24,7 +24,7 @@ flameSpitter :: Item
flameSpitter =
flameThrower
& itType .~ HELD FLAMESPITTER
& itUse . heldDelay .~ FixedRate{_rateMax = 3} --, _rateTimeLastUsed = 0}
-- & itUse . heldDelay .~ FixedRate{_rateMax = 3} --, _rateTimeLastUsed = 0}
-- & itUse . heldParams . weaponInvLock .~ 10
-- & itUse . heldParams . weaponRepeat .~ [1..9]
-- & itUse . heldMuzzles . ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
@@ -65,7 +65,7 @@ flameThrower :: Item
flameThrower =
defaultHeldItem
& itParams .~ NozzleAngle 0
& itUse . heldDelay .~ NoDelay
-- & itUse . heldDelay .~ NoDelay
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
-- & itUse . heldMuzzles .~ [Muzzle (V2 18 0) 0 0 0 NoFlare
-- MuzzleNozzle
+5 -6
View File
@@ -9,7 +9,6 @@ module Dodge.Item.Held.Stick (
--import Dodge.Base
import Dodge.Data.Item
import Dodge.Default.Item
import Dodge.SoundLogic.ExternallyGeneratedSounds
--import Geometry
import LensHelp
@@ -18,7 +17,7 @@ bangStick i =
defaultBulletWeapon
-- & itUse . heldParams . recoil .~ 25
& itType .~ HELD (BANGSTICK i)
& itUse . heldDelay . rateMax .~ 8
-- & itUse . heldDelay . rateMax .~ 8
-- & itUse . heldMuzzles
-- .~ [ Muzzle
-- (V2 10 0)
@@ -41,7 +40,7 @@ bangStick i =
pistol :: Item
pistol =
bangStick 1
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMuzzles . ix 0 . mzPos %~ const (V2 10 0)
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy %~ const 0.05
-- & itUse . heldMuzzles . ix 0 . mzFlareType %~ const BasicFlare
@@ -53,9 +52,9 @@ autoPistol = pistol & itType .~ HELD AUTOPISTOL
machinePistol :: Item
machinePistol =
autoPistol
& itUse . heldDelay .~ WarmUpNoDelay{
--_warmTime = 0,
_warmMax = 50, _warmSound = crankSlowS}
-- & itUse . heldDelay .~ WarmUpNoDelay{
-- --_warmTime = 0,
-- _warmMax = 50, _warmSound = crankSlowS}
& itType .~ HELD MACHINEPISTOL
& itParams .~ WarmTime 0
+2 -2
View File
@@ -36,7 +36,7 @@ detector :: Detector -> Item
detector dt =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldDelay . rateMax .~ 20
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itType .~ DETECTOR dt
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleDetector
@@ -46,7 +46,7 @@ blinker :: Item
blinker =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldDelay . rateMax .~ 20
& itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleBlink
-- & itUse . heldMuzzles . ix 0 . mzAmmoPerShot .~ UseExactly 10000000
+1 -1
View File
@@ -9,7 +9,7 @@ shatterGun :: Item
shatterGun =
defaultHeldItem
& itType .~ HELD SHATTERGUN
& itUse . heldDelay . rateMax .~ 10
-- & itUse . heldDelay . rateMax .~ 10
& itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
+183 -173
View File
File diff suppressed because it is too large Load Diff