Work on tweak datatypes

This commit is contained in:
2021-11-29 23:05:51 +00:00
parent 02dc7c29e0
commit e75cbdf6cb
5 changed files with 32 additions and 45 deletions
+5 -13
View File
@@ -516,34 +516,26 @@ data AmmoType
{ _amString :: String }
| GenericAmmo
data ItemParams
= UtilityItem
| NoParams
= NoParams
| ShellLauncher
{ _tweakParams :: [TweakParam]
{ _tweakParams :: IM.IntMap TweakParam
, _tweakSel :: Int
, _shellSpinDrag :: Int
, _shellSpinAmount :: Int
, _shellThrustDelay :: Int
}
| Refracting {_phaseVel :: Float}
| MultiBarrel
{ _barrelSpread :: BarrelSpread
, _barrelNum :: Int
}
| SingleBarrel
{_inaccuracy :: Float}
| SingleBarrel {_inaccuracy :: Float}
| AngleWalk
{ _maxWalkAngle :: Float
, _currentWalkAngle :: Float
, _walkSpeed :: Float
}
data TweakParam
= PjExtraUpdate
{ _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World
, _curTweak :: Int
, _pjMaxParam :: Int
, _pjDisplayParam :: Int -> String
}
| TweakItem
data TweakParam = TweakParam
{ _doTweak :: Int -> Item -> Item
, _curTweak :: Int
, _maxTweak :: Int
+10 -10
View File
@@ -112,10 +112,10 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
| invKeyDown -> swapInvDir yi $ stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| otherwise -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
(_, TweakInventory)
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
| invKeyDown && rbDown -> w & moveTweakSel yi
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
| rbDown -> w & changeTweakParam yi
| otherwise -> w & moveYourAmmoSel yi
| otherwise -> w & moveTweakSel yi
(_, _) -> w
where
yi = round $ signum y
@@ -124,18 +124,18 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
lbDown = ButtonLeft `S.member` _mouseButtons w
invKeyDown = ScancodeCapsLock `S.member` _keys w
moveYourAmmoSel :: Int -> World -> World
moveYourAmmoSel i w = case yourItem w ^? itParams . tweakParams of
moveTweakSel :: Int -> World -> World
moveTweakSel i w = case yourItem w ^? itParams . tweakParams of
Just l -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itParams . tweakSel %~ (`mod` length l) . subtract i
_ -> w
changeTweakParam :: Int -> World -> World
changeTweakParam i w =
case yourItem w ^? itParams . tweakParams . ix paramid . pjMaxParam of
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
. itParams . tweakParams . ix paramid . curTweak %~ (`mod` n) . (+ i)
_ -> w
changeTweakParam i w = w
& creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) %~
( (itParams . tweakParams . ix paramid . curTweak .~ x)
. _doTweak params x)
where
it = yourItem w
theparam = it ^? itParams . tweakParams . ix paramid
params = _tweakParams (_itParams it) IM.! paramid
x = (_curTweak params + i) `mod` _maxTweak params
paramid = _tweakSel $ _itParams $ yourItem w
+1
View File
@@ -83,6 +83,7 @@ lasGun = defaultAutoGun
, _itAttachment = ItCharMode $ Seq.fromList "/VZ"
, _itScroll = scrollCharMode
, _itInvDisplay = basicWeaponDisplay
, _itParams = Refracting {_phaseVel = 1}
}
lasGunPic :: Item -> SPic
lasGunPic it =
+14 -20
View File
@@ -82,34 +82,34 @@ launcherPic _ =
, mempty
)
basicAmPjMoves :: [TweakParam]
basicAmPjMoves =
basicAmPjMoves :: IM.IntMap TweakParam
basicAmPjMoves = IM.fromList . zip [0..] $
[spinDrag
,spinStart
,thrustParam
]
spinDrag :: TweakParam
spinDrag = PjExtraUpdate
{ _pjMoveParam = \i _ _ -> reduceSpinBy (1 - fromIntegral i*2 / 200)
spinDrag = TweakParam
{ _doTweak = \i -> itParams . shellSpinDrag .~ i
, _curTweak = 1
, _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show
, _pjMaxParam = 5
, _showTweak = pjPadText "SPIN SLOWDOWN" . show
, _maxTweak = 5
}
pjPadText :: String -> String -> String
pjPadText s = (rightPad 12 ' ' s ++ ) . (' ':)
spinStart :: TweakParam
spinStart = PjExtraUpdate
{ _pjMoveParam = \i _ cr -> pjEffAtTime 35 $ trySpinByCID (_crID cr) i
spinStart = TweakParam
{ _doTweak = \i -> itParams . shellSpinAmount .~ i
, _curTweak = 2
, _pjDisplayParam = pjPadText "SPIN AMOUNT" . show
, _pjMaxParam = 5
, _showTweak = pjPadText "SPIN AMOUNT" . show
, _maxTweak = 5
}
thrustParam :: TweakParam
thrustParam = PjExtraUpdate
{ _pjMoveParam = \i _ _ -> pjThrust i
thrustParam = TweakParam
{ _doTweak = \i -> itParams . shellThrustDelay .~ i
, _curTweak = 1
, _pjDisplayParam = pjPadText "THRUST DELAY" . show
, _pjMaxParam = 5
, _showTweak = pjPadText "THRUST DELAY" . show
, _maxTweak = 5
}
pjThrust :: Int -> Prop -> World -> World
@@ -151,12 +151,6 @@ aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
spindrag = _shellSpinDrag params
spinamount = _shellSpinAmount params
thrustdelay = _shellThrustDelay params
ammoMvs pj w' =
foldr (\pjP -> _pjMoveParam pjP (_curTweak pjP) it cr pj) w'
(filter ispjupdate $ _tweakParams $ _itParams it)
ispjupdate PjExtraUpdate {} = True
ispjupdate _ = False
-- I feel like this might leak...
theShell = defaultShell
{ _pjPos = pos
, _pjStartPos = pos
+2 -2
View File
@@ -76,7 +76,7 @@ topInvCursor col iPos cfig w
ammoTweakStrings :: Item -> [String]
ammoTweakStrings it = case it ^? itParams . tweakParams of
Just l -> map pjTweakString l
Just l -> map pjTweakString $ IM.elems l
_ -> ["NOT TWEAKABLE"]
mCurs :: Item -> Configuration -> World -> Picture
@@ -94,7 +94,7 @@ mCurs it cfig w = case it ^? itParams . tweakSel of
y = 155
pjTweakString :: TweakParam -> String
pjTweakString pj = _pjDisplayParam pj $ _curTweak pj
pjTweakString pj = _showTweak pj $ _curTweak pj
displayMidList :: Configuration -> [String] -> String -> Picture
displayMidList cfig strs s = invHead cfig s