Continue reorganising records into functions

This commit is contained in:
2025-06-03 22:20:42 +01:00
parent a5554f24e4
commit 33ebdcb0de
17 changed files with 171 additions and 153 deletions
+1
View File
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
crSafeDistFromTarg,
) where
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import Control.Lens
import Data.List (find)
+1
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import Control.Monad
import qualified Data.Map.Strict as M
+2
View File
@@ -19,8 +19,10 @@ module Dodge.Data (
module Dodge.Data.CrWlID,
module Dodge.Data.CreatureEffect,
module Dodge.Data.MountedObject,
module Dodge.Data.AimStance,
) where
import Dodge.Data.AimStance
import Dodge.Data.Config
import Dodge.Data.Scenario
import Dodge.Data.WorldEffect
-20
View File
@@ -114,9 +114,6 @@ data AmmoParams
data AimParams = AimParams
{ _aimWeight :: Int
, _aimTurnSpeed :: Float
, _aimRange :: Float
, _aimZoom :: ItZoom
-- , _aimHandlePos :: V2 Float
, _aimMuzzles :: [Muzzle]
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
@@ -179,23 +176,8 @@ data Muzzle = Muzzle
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data AimStance
= TwoHandUnder
| TwoHandOver
| TwoHandFlat
| OneHand
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data ItZoom = ItZoom
{ _izMax :: Float
, _izMin :: Float
, _izFac :: Float
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''ItemUse
makeLenses ''AimParams
makeLenses ''ItZoom
makeLenses ''Muzzle
makeLenses ''HeldParams
makeLenses ''AttachParams
@@ -215,8 +197,6 @@ deriveJSON defaultOptions ''AmmoParams
deriveJSON defaultOptions ''HeldParams
deriveJSON defaultOptions ''AmmoPerShot
deriveJSON defaultOptions ''Muzzle
deriveJSON defaultOptions ''AimStance
deriveJSON defaultOptions ''AttachParams
deriveJSON defaultOptions ''ItZoom
deriveJSON defaultOptions ''AimParams
deriveJSON defaultOptions ''ItemUse
+9 -10
View File
@@ -1,6 +1,6 @@
module Dodge.Default.Item.Use.AimParams (
defaultAimParams,
defaultItZoom,
-- defaultItZoom,
) where
import Dodge.Data.Item.Use
@@ -11,8 +11,7 @@ defaultAimParams =
AimParams
{ _aimWeight = 0
, _aimTurnSpeed = 1
, _aimRange = 0
, _aimZoom = defaultItZoom
-- , _aimZoom = defaultItZoom
--, _aimHandlePos = V2 3 0
, _aimMuzzles =
[ Muzzle
@@ -28,10 +27,10 @@ defaultAimParams =
]
}
defaultItZoom :: ItZoom
defaultItZoom =
ItZoom
{ _izMax = 20
, _izMin = 0.2
, _izFac = 1
}
--defaultItZoom :: ItZoom
--defaultItZoom =
-- ItZoom
-- { _izMax = 20
-- , _izMin = 0.2
-- , _izFac = 1
-- }
+1
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Grammar (
allInvLocs,
) where
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import Control.Applicative
import qualified Data.IntMap.Strict as IM
-2
View File
@@ -59,7 +59,6 @@ laser =
, _itTgActive = False
}
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itType .~ HELD LASER
-- previous attractionPower values: 1, -1, -10, 0
@@ -72,7 +71,6 @@ tractorGun =
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ NoFlare
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleTractor
& itType .~ HELD TRACTORGUN
+3 -6
View File
@@ -31,8 +31,7 @@ volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ getZipList
(ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
<*> ZipList [0..i-1]
@@ -54,8 +53,7 @@ rifle =
defaultBangCane
& itType .~ HELD RIFLE
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 25 0
alteRifle :: Item
@@ -94,8 +92,7 @@ miniGunX i =
autoRifle
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
-- & itUse . heldParams . bulGunSound ?~ (mini1S,2)
& itUse . heldAim . aimTurnSpeed .~ 0.5
-1
View File
@@ -16,7 +16,6 @@ rLauncher =
defaultHeldItem
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleRLauncher
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 20 0
+2 -3
View File
@@ -25,8 +25,7 @@ bangRod =
& itUse . heldDelay . rateMax .~ 12
& itType .~ HELD BANGROD
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ HeavySmokeFlare
@@ -54,7 +53,7 @@ sniperRifle =
elephantGun
& itType .~ HELD SNIPERRIFLE
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1}
--machineGun :: Item
--machineGun =
+2 -2
View File
@@ -40,7 +40,7 @@ flameTorrent :: Item
flameTorrent =
flameThrower
& itType .~ HELD FLAMETORRENT
& itUse . heldAim . aimZoom .~ defaultItZoom
-- & itUse . heldAim . aimZoom .~ defaultItZoom
-- & itParams . sprayNozzles . ix 0
-- %~ ( (nzPressure .~ 10)
-- . (nzMaxWalkAngle .~ 1.5)
@@ -74,7 +74,7 @@ flameThrower =
& itParams .~ NoParams
& itUse . heldDelay .~ NoDelay
& itUse . heldAim . aimWeight .~ 5
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0 NoFlare
MuzzleNozzle
{ _nzPressure = ConstFloat 4
+2 -4
View File
@@ -41,8 +41,7 @@ detector dt =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
& itType .~ DETECTOR dt
@@ -54,8 +53,7 @@ blinker =
defaultHeldItem
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldParams .~ DefaultHeldParams
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleBlink
+1
View File
@@ -7,6 +7,7 @@ module Dodge.Item.HeldOffset (
heldItemOrient2D,
) where
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import qualified Quaternion as Q
import Dodge.Data.Creature
+1
View File
@@ -4,6 +4,7 @@ module Dodge.Item.Info (
itemInfo,
) where
import Dodge.Data.AimStance
import Data.Char
--import qualified Data.Map.Strict as M
import Dodge.Data.Item
+51 -5
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
{- Functions controlling the movement of the screen camera:
'_cameraCenter', '_cameraZoom', _cameraRot';
and the position that the character sees from: '_cameraViewFrom'. -}
@@ -113,7 +114,7 @@ moveZoomCamera cfig theinput cr w campos =
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . imSelectedItem
zoomFromItem <$> (cr ^? crInv . ix i . itUse . heldAim . aimZoom)
getAimZoom <$> (cr ^? crInv . ix i)
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
changeZoom curZoom idealZoom
| curZoom > idealZoom + 0.01 = ((zoomOutSpeed -1) * curZoom + idealZoom) / zoomOutSpeed
@@ -130,6 +131,55 @@ moveZoomCamera cfig theinput cr w campos =
zoomInSpeed = 25
zoomOutSpeed = 15
getAimZoom :: Item -> Float
getAimZoom itm = case itm ^. itType of
HELD hit -> heldAimZoom hit
_ -> 1
heldAimZoom :: HeldItemType -> Float
heldAimZoom = \case
BANGSTICK{} -> 1
REWINDER -> 1
TIMESTOPPER -> 1
TIMESCROLLER -> 1
PISTOL -> 1
MACHINEPISTOL -> 1
AUTOPISTOL -> 1
SMG -> 1
BANGCONE -> 1
BLUNDERBUSS -> 1.5
GRAPECANNON{} -> 1.5
MINIGUNX{} -> 1.5
VOLLEYGUN{} -> 1.5
RIFLE -> 1.5
ALTERIFLE -> 1.5
AUTORIFLE -> 1.5
BURSTRIFLE -> 1.5
BANGROD -> 1.5
ELEPHANTGUN -> 1.5
AMR -> 1.5
AUTOAMR -> 1.5
SNIPERRIFLE -> 0.5
FLAMESPITTER -> 1
FLAMETHROWER -> 1.5
FLAMETORRENT -> 1
FLAMEWALL -> 1
BLOWTORCH -> 1
SPARKGUN -> 1
TESLAGUN -> 1.5
LASER -> 1.5
TRACTORGUN -> 1.5
RLAUNCHER -> 1.5
RLAUNCHERX{} -> 1.5
GLAUNCHER -> 1.5
POISONSPRAYER -> 1
SHATTERGUN -> 1
TORCH -> 1
FLATSHIELD -> 1
KEYCARD {} -> 1
BLINKER -> 1
BLINKERUNSAFE -> 1
-- for example, this should be 400 or so when you have an unsafe blink gun
-- capable of firing, should be expanded when you have a radar of some sort, etc
viewDistanceFromItems :: Creature -> Float
@@ -168,10 +218,6 @@ doWallRotate wl w
b = a * (4 / pi) -- for 8 way cardinal orientation wrt wall
b' = fromIntegral (round b :: Int)
zoomFromItem :: ItZoom -> Float
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
min zMax $ max zMin zFac
clipZoom ::
-- | Furthest viewable distance
Float ->