Continue record refactor

This commit is contained in:
2025-06-04 09:50:18 +01:00
parent e1ec4e1a89
commit 9f884b5aa7
10 changed files with 97 additions and 31 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -11
View File
@@ -27,7 +27,6 @@ import Dodge.Data.Item.Targeting
import Dodge.Data.Item.Use.Consumption
import Dodge.Data.Item.Use.Equipment
import Geometry.Data
--import Sound.Data
data ItemUse
= UseHeld
@@ -85,15 +84,9 @@ data HeldParams
}
| BeamShooterParams
| BulletShooterParams
{ _muzVel :: GenFloat
, _rifling :: GenFloat
-- , _recoil :: Float
, _torqueAfter :: Float
{ _torqueAfter :: Float
, _randomOffset :: Float
, _sidePush :: Float
-- , _bulGunSound :: Maybe (SoundID, Int) -- if the int is 0, play sound on new channel
-- if >0, continue playing sound for
-- given time
, _weaponInvLock :: Int
, _weaponRepeat :: [Int]
}
@@ -106,9 +99,6 @@ data AmmoParams
| NoAmmoParams
deriving (Eq, Show, Read) --Generic, Flat)
--data AimParams = AimParams { _aimMuzzles :: [Muzzle] }
-- deriving (Eq, Ord, Show, Read) --Generic, Flat)
data FlareType
= NoFlare
| BasicFlare
+1 -4
View File
@@ -29,10 +29,7 @@ defaultHeldUse = UseHeld
-- , _heldHammer = HammerUp
, _heldMuzzles = defaultMuzzles
, _heldParams = BulletShooterParams
{ _muzVel = ConstFloat 0.8
, _rifling = ConstFloat 0.8
-- , _recoil = 10
, _torqueAfter = 0.2
{ _torqueAfter = 0.2
, _randomOffset = 0
, _sidePush = 0
-- , _bulGunSound = Just (tap3S, 0)
+92 -2
View File
@@ -1,5 +1,6 @@
{-# OPTIONS -Wno-incomplete-uni-patterns #-}
--{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
module Dodge.HeldUse (
heldEffect,
@@ -670,13 +671,102 @@ makeBullet thebullet itm bulpos dir w =
)
where
g = _randGen w
(drag, g') = case _rifling (_heldParams $ _itUse itm) of
(drag, g') = case heldItemRifling (_ibtHeld $ _itType itm) of --unsafe
ConstFloat x -> (x, g)
UniRandFloat x y -> randomR (x, y) g
(muzvel, g'') = case _muzVel $ _heldParams $ _itUse itm of
(muzvel, g'') = case heldItemMuzVel $ _ibtHeld $ _itType itm of
ConstFloat x -> (x, g')
UniRandFloat x y -> randomR (x, y) g'
heldItemMuzVel :: HeldItemType -> GenFloat
heldItemMuzVel = \case
BANGSTICK{} -> ConstFloat 0.8
REWINDER -> ConstFloat 0.8
TIMESTOPPER -> ConstFloat 0.8
TIMESCROLLER -> ConstFloat 0.8
PISTOL -> ConstFloat 0.8
MACHINEPISTOL -> ConstFloat 0.8
AUTOPISTOL -> ConstFloat 0.8
SMG -> ConstFloat 0.8
BANGCONE -> UniRandFloat 0.5 0.8
BLUNDERBUSS -> UniRandFloat 0.5 0.8
GRAPECANNON{} -> UniRandFloat 0.5 0.8
MINIGUNX{} -> ConstFloat 0.8
VOLLEYGUN{} -> ConstFloat 0.8
RIFLE -> ConstFloat 0.8
ALTERIFLE -> ConstFloat 0.8
AUTORIFLE -> ConstFloat 0.8
BURSTRIFLE -> ConstFloat 0.8
BANGROD -> ConstFloat 0.8
ELEPHANTGUN -> ConstFloat 0.8
AMR -> ConstFloat 0.8
AUTOAMR -> ConstFloat 0.8
SNIPERRIFLE -> ConstFloat 0.8
FLAMESPITTER -> ConstFloat 0.8
FLAMETHROWER -> ConstFloat 0.8
FLAMETORRENT -> ConstFloat 0.8
FLAMEWALL -> ConstFloat 0.8
BLOWTORCH -> ConstFloat 0.8
SPARKGUN -> ConstFloat 0.8
TESLAGUN -> ConstFloat 0.8
LASER -> ConstFloat 0.8
TRACTORGUN -> ConstFloat 0.8
RLAUNCHER -> ConstFloat 0
RLAUNCHERX{} -> ConstFloat 0
GLAUNCHER -> ConstFloat 0
POISONSPRAYER -> ConstFloat 0.8
SHATTERGUN -> ConstFloat 0.8
TORCH -> ConstFloat 0.8
FLATSHIELD -> ConstFloat 0
KEYCARD{} -> ConstFloat 0.8
BLINKER -> ConstFloat 0.8
BLINKERUNSAFE -> ConstFloat 0.8
heldItemRifling :: HeldItemType -> GenFloat
heldItemRifling = \case
BANGSTICK{} -> ConstFloat 0.8
REWINDER -> ConstFloat 0.8
TIMESTOPPER -> ConstFloat 0.8
TIMESCROLLER -> ConstFloat 0.8
PISTOL -> ConstFloat 0.8
MACHINEPISTOL -> ConstFloat 0.8
AUTOPISTOL -> ConstFloat 0.8
SMG -> ConstFloat 0.8
BANGCONE -> UniRandFloat 0.3 0.8
BLUNDERBUSS -> UniRandFloat 0.3 0.8
GRAPECANNON{} -> UniRandFloat 0.3 0.8
MINIGUNX{} -> UniRandFloat 0.8 0.9
VOLLEYGUN{} -> ConstFloat 0.9
RIFLE -> ConstFloat 0.9
ALTERIFLE -> ConstFloat 0.9
AUTORIFLE -> ConstFloat 0.9
BURSTRIFLE -> ConstFloat 0.9
BANGROD -> ConstFloat 1
ELEPHANTGUN -> ConstFloat 1
AMR -> ConstFloat 1
AUTOAMR -> ConstFloat 1
SNIPERRIFLE -> ConstFloat 1
FLAMESPITTER -> ConstFloat 0.8
FLAMETHROWER -> ConstFloat 0.8
FLAMETORRENT -> ConstFloat 0.8
FLAMEWALL -> ConstFloat 0.8
BLOWTORCH -> ConstFloat 0.8
SPARKGUN -> ConstFloat 0.8
TESLAGUN -> ConstFloat 0.8
LASER -> ConstFloat 0.8
TRACTORGUN -> ConstFloat 0.8
RLAUNCHER -> ConstFloat 0
RLAUNCHERX{} -> ConstFloat 0
GLAUNCHER -> ConstFloat 0
POISONSPRAYER -> ConstFloat 0.8
SHATTERGUN -> ConstFloat 0.8
TORCH -> ConstFloat 0.8
FLATSHIELD -> ConstFloat 0.8
KEYCARD{} -> ConstFloat 0.8
BLINKER -> ConstFloat 0.8
BLINKERUNSAFE -> ConstFloat 0.8
mcUseHeld :: HeldItemType -> Item -> Machine -> World -> World
mcUseHeld hit = case hit of
LASER -> mcShootLaser
-2
View File
@@ -20,7 +20,6 @@ import Control.Applicative
defaultBangCane :: Item
defaultBangCane =
defaultBulletWeapon
& itUse . heldParams . rifling .~ ConstFloat 0.9
-- & itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldDelay . rateMax .~ 6
@@ -98,7 +97,6 @@ miniGunX i =
& itUse . heldParams . torqueAfter .~ 0.04 + 0.02 * fromIntegral i
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
& itUse . heldParams . randomOffset .~ 10
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
& itType .~ HELD (MINIGUNX i)
& itEffect . ieInv .~ ItemReduceWarmTime
& itEffect . ieOnDrop .~ ItemSetWarmTime 0
-2
View File
@@ -19,8 +19,6 @@ bangCone =
15
(Muzzle (V2 15 0) 0 0.5 0 NoFlare MuzzleShootBullet (UseExactly 1) 0)
& itUse . heldMuzzles . ix 0 . mzFlareType .~ BasicFlare
& itUse . heldParams . muzVel .~ UniRandFloat 0.5 0.8
& itUse . heldParams . rifling .~ UniRandFloat 0.3 0.8
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldParams . randomOffset .~ 12
& itType .~ HELD BANGCONE
-3
View File
@@ -20,9 +20,6 @@ rLauncher =
& itUse . heldMuzzles . ix 0 . mzPos .~ V2 20 0
& itAmmoSlots .~ singleAmmo LauncherAmmo
& itType .~ HELD RLAUNCHER
& itUse . heldParams . muzVel .~ ConstFloat 0
& itUse . heldParams . rifling .~ ConstFloat 0
-- & itUse . heldParams . recoil .~ 0
& itUse . heldParams . torqueAfter .~ 0
-- & itUse . heldParams . bulGunSound ?~ (tap4S, 0)
-1
View File
@@ -18,7 +18,6 @@ import LensHelp
bangRod :: Item
bangRod =
defaultBulletWeapon
& itUse . heldParams . rifling .~ ConstFloat 1
-- & itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.3
-- & itUse . heldParams . bulGunSound ?~ (bangEchoS,0)
+1 -4
View File
@@ -47,10 +47,7 @@ pistol =
& itUse . heldMuzzles . ix 0 . mzInaccuracy %~ const 0.05
& itUse . heldMuzzles . ix 0 . mzFlareType %~ const BasicFlare
& itUse . heldParams
%~ ( (muzVel .~ ConstFloat 0.8)
. (rifling .~ ConstFloat 0.8)
-- . (recoil .~ 10)
. (torqueAfter .~ 0.2)
%~ ( (torqueAfter .~ 0.2)
. (sidePush .~ 50)
)
& itType .~ HELD PISTOL
+1 -1
View File
@@ -23,7 +23,7 @@ import LensHelp
import MaybeHelp
import Padding
import Preload.Update
import qualified SDL as SDL
import qualified SDL
import System.Clipboard
import Text.Read