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