Move towards tweak parameters editing items
This commit is contained in:
+17
-7
@@ -500,12 +500,11 @@ type HitEffect = Particle
|
|||||||
-> (World,Maybe Particle)
|
-> (World,Maybe Particle)
|
||||||
|
|
||||||
data AmmoType
|
data AmmoType
|
||||||
= ShellAmmo
|
= ProjectileAmmo
|
||||||
{ _amPayload :: Point2 -> World -> World
|
{ _amPayload :: Point2 -> World -> World
|
||||||
, _amString :: String
|
, _amString :: String
|
||||||
, _amPjParams :: [PjParam]
|
|
||||||
, _amPjDraw :: Prop -> SPic
|
, _amPjDraw :: Prop -> SPic
|
||||||
, _amParamSel :: Int
|
-- , _aProjectile :: Ammo -> Prop
|
||||||
}
|
}
|
||||||
| BulletAmmo
|
| BulletAmmo
|
||||||
{ _amString :: String
|
{ _amString :: String
|
||||||
@@ -520,7 +519,11 @@ data ItemParams
|
|||||||
= UtilityItem
|
= UtilityItem
|
||||||
| NoParams
|
| NoParams
|
||||||
| ShellLauncher
|
| ShellLauncher
|
||||||
{ _launchParams :: [PjParam]
|
{ _tweakParams :: [TweakParam]
|
||||||
|
, _tweakSel :: Int
|
||||||
|
, _shellSpinDrag :: Int
|
||||||
|
, _shellSpinAmount :: Int
|
||||||
|
, _shellThrustDelay :: Int
|
||||||
}
|
}
|
||||||
| MultiBarrel
|
| MultiBarrel
|
||||||
{ _barrelSpread :: BarrelSpread
|
{ _barrelSpread :: BarrelSpread
|
||||||
@@ -533,12 +536,19 @@ data ItemParams
|
|||||||
, _currentWalkAngle :: Float
|
, _currentWalkAngle :: Float
|
||||||
, _walkSpeed :: Float
|
, _walkSpeed :: Float
|
||||||
}
|
}
|
||||||
data PjParam = PjParam
|
data TweakParam
|
||||||
|
= PjExtraUpdate
|
||||||
{ _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World
|
{ _pjMoveParam :: Int -> Item -> Creature -> Prop -> World -> World
|
||||||
, _pjIntParam :: Int
|
, _curTweak :: Int
|
||||||
, _pjMaxParam :: Int
|
, _pjMaxParam :: Int
|
||||||
, _pjDisplayParam :: Int -> String
|
, _pjDisplayParam :: Int -> String
|
||||||
}
|
}
|
||||||
|
| TweakItem
|
||||||
|
{ _doTweak :: Int -> Item -> Item
|
||||||
|
, _curTweak :: Int
|
||||||
|
, _maxTweak :: Int
|
||||||
|
, _showTweak :: Int -> String
|
||||||
|
}
|
||||||
data Modification
|
data Modification
|
||||||
= ModIDTimerPoint3Bool
|
= ModIDTimerPoint3Bool
|
||||||
{ _mdID :: Int
|
{ _mdID :: Int
|
||||||
@@ -871,7 +881,7 @@ makeLenses ''ItEffect
|
|||||||
makeLenses ''FloorItem
|
makeLenses ''FloorItem
|
||||||
makeLenses ''ItemConsumption
|
makeLenses ''ItemConsumption
|
||||||
makeLenses ''AmmoType
|
makeLenses ''AmmoType
|
||||||
makeLenses ''PjParam
|
makeLenses ''TweakParam
|
||||||
makeLenses ''Prop
|
makeLenses ''Prop
|
||||||
makeLenses ''Modification
|
makeLenses ''Modification
|
||||||
makeLenses ''Particle
|
makeLenses ''Particle
|
||||||
|
|||||||
@@ -114,11 +114,3 @@ defaultItemDimension = ItemDimension
|
|||||||
defaultAutoGun :: Item
|
defaultAutoGun :: Item
|
||||||
defaultAutoGun = defaultGun
|
defaultAutoGun = defaultGun
|
||||||
& itUse . useAim . aimStance .~ TwoHandTwist
|
& itUse . useAim . aimStance .~ TwoHandTwist
|
||||||
defaultShellAmmo :: AmmoType
|
|
||||||
defaultShellAmmo = ShellAmmo
|
|
||||||
{ _amPayload = const id
|
|
||||||
, _amString = "Shell"
|
|
||||||
, _amPjParams = []
|
|
||||||
, _amPjDraw = const mempty
|
|
||||||
, _amParamSel = 0
|
|
||||||
}
|
|
||||||
|
|||||||
+10
-7
@@ -114,7 +114,7 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
|
|||||||
(_, TweakInventory)
|
(_, TweakInventory)
|
||||||
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
|
| invKeyDown && rbDown -> w & moveYourAmmoSel yi
|
||||||
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
|
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ dirInvPos yi w
|
||||||
| rbDown -> w & moveYourAmmoParam yi
|
| rbDown -> w & changeTweakParam yi
|
||||||
| otherwise -> w & moveYourAmmoSel yi
|
| otherwise -> w & moveYourAmmoSel yi
|
||||||
(_, _) -> w
|
(_, _) -> w
|
||||||
where
|
where
|
||||||
@@ -125,14 +125,17 @@ wheelEvent y w = case (_carteDisplay w, _inventoryMode w) of
|
|||||||
invKeyDown = ScancodeCapsLock `S.member` _keys w
|
invKeyDown = ScancodeCapsLock `S.member` _keys w
|
||||||
|
|
||||||
moveYourAmmoSel :: Int -> World -> World
|
moveYourAmmoSel :: Int -> World -> World
|
||||||
moveYourAmmoSel i w = case yourItem w ^? itConsumption . aoType. amPjParams of
|
moveYourAmmoSel 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))
|
||||||
. itConsumption . aoType. amParamSel %~ (`mod` length l) . subtract i
|
. itParams . tweakSel %~ (`mod` length l) . subtract i
|
||||||
_ -> w
|
_ -> w
|
||||||
moveYourAmmoParam :: Int -> World -> World
|
changeTweakParam :: Int -> World -> World
|
||||||
moveYourAmmoParam i w = case yourItem w ^? itConsumption . aoType. amPjParams . ix paramid . pjMaxParam of
|
changeTweakParam i w =
|
||||||
|
case yourItem w ^? itParams . tweakParams . ix paramid . pjMaxParam of
|
||||||
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
Just n -> w & creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
||||||
. itConsumption . aoType. amPjParams . ix paramid . pjIntParam %~ (`mod` n) . (+ i)
|
. itParams . tweakParams . ix paramid . curTweak %~ (`mod` n) . (+ i)
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
paramid = _amParamSel $ _aoType $ _itConsumption $ yourItem w
|
it = yourItem w
|
||||||
|
theparam = it ^? itParams . tweakParams . ix paramid
|
||||||
|
paramid = _tweakSel $ _itParams $ yourItem w
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ autoGun = defaultAutoGun
|
|||||||
, withSoundForI autoBS 5
|
, withSoundForI autoBS 5
|
||||||
--, withSoundForI seagullChatterS 5
|
--, withSoundForI seagullChatterS 5
|
||||||
, useAmmo 1
|
, useAmmo 1
|
||||||
, withRandomDirI (autogunSpread/2)
|
, applyInaccuracy
|
||||||
, withMuzFlareI
|
, withMuzFlareI
|
||||||
, withSmoke 1 black 20 200 5
|
, withSmoke 1 black 20 200 5
|
||||||
]
|
]
|
||||||
@@ -406,7 +406,5 @@ startZoomInLongGun = itAttachment . scopeZoomChange %~ \x -> max 5 (x + 5)
|
|||||||
startZoomOutLongGun :: Item -> Item
|
startZoomOutLongGun :: Item -> Item
|
||||||
startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5)
|
startZoomOutLongGun = itAttachment . scopeZoomChange %~ \x -> min (-5) (x-5)
|
||||||
|
|
||||||
spreadGunSpread :: Float
|
|
||||||
spreadGunSpread = 0.5
|
|
||||||
autogunSpread :: Float
|
autogunSpread :: Float
|
||||||
autogunSpread = 0.07
|
autogunSpread = 0.07
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ launcher = defaultGun
|
|||||||
, _itConsumption = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _aoType = defaultShellAmmo
|
{ _aoType = defaultShellAmmo
|
||||||
{ _amPayload = makeExplosionAt
|
{ _amPayload = makeExplosionAt
|
||||||
, _amString = ""
|
, _amString = "EXPLOSIVE SHELL"
|
||||||
, _amPjParams = basicAmPjMoves
|
|
||||||
, _amPjDraw = shellPic
|
, _amPjDraw = shellPic
|
||||||
}
|
}
|
||||||
, _wpMaxAmmo = 30
|
, _wpMaxAmmo = 30
|
||||||
@@ -59,6 +58,20 @@ launcher = defaultGun
|
|||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
, _itFloorPict = launcherPic
|
, _itFloorPict = launcherPic
|
||||||
, _itEffect = NoItEffect
|
, _itEffect = NoItEffect
|
||||||
|
, _itParams = ShellLauncher
|
||||||
|
{ _tweakSel = 0
|
||||||
|
, _tweakParams = basicAmPjMoves
|
||||||
|
, _shellSpinDrag = 1
|
||||||
|
, _shellSpinAmount = 2
|
||||||
|
, _shellThrustDelay = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultShellAmmo :: AmmoType
|
||||||
|
defaultShellAmmo = ProjectileAmmo
|
||||||
|
{ _amPayload = const id
|
||||||
|
, _amString = "Shell"
|
||||||
|
, _amPjDraw = const mempty
|
||||||
}
|
}
|
||||||
|
|
||||||
launcherPic :: Item -> SPic
|
launcherPic :: Item -> SPic
|
||||||
@@ -69,32 +82,32 @@ launcherPic _ =
|
|||||||
, mempty
|
, mempty
|
||||||
)
|
)
|
||||||
|
|
||||||
basicAmPjMoves :: [PjParam]
|
basicAmPjMoves :: [TweakParam]
|
||||||
basicAmPjMoves =
|
basicAmPjMoves =
|
||||||
[spinDrag
|
[spinDrag
|
||||||
,spinStart
|
,spinStart
|
||||||
,thrustParam
|
,thrustParam
|
||||||
]
|
]
|
||||||
spinDrag :: PjParam
|
spinDrag :: TweakParam
|
||||||
spinDrag = PjParam
|
spinDrag = PjExtraUpdate
|
||||||
{ _pjMoveParam = \i _ _ -> reduceSpinBy (1 - fromIntegral i*2 / 200)
|
{ _pjMoveParam = \i _ _ -> reduceSpinBy (1 - fromIntegral i*2 / 200)
|
||||||
, _pjIntParam = 1
|
, _curTweak = 1
|
||||||
, _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show
|
, _pjDisplayParam = pjPadText "SPIN SLOWDOWN" . show
|
||||||
, _pjMaxParam = 5
|
, _pjMaxParam = 5
|
||||||
}
|
}
|
||||||
pjPadText :: String -> String -> String
|
pjPadText :: String -> String -> String
|
||||||
pjPadText s = (rightPad 12 ' ' s ++ ) . (' ':)
|
pjPadText s = (rightPad 12 ' ' s ++ ) . (' ':)
|
||||||
spinStart :: PjParam
|
spinStart :: TweakParam
|
||||||
spinStart = PjParam
|
spinStart = PjExtraUpdate
|
||||||
{ _pjMoveParam = \i _ cr -> pjEffAtTime 35 $ trySpinByCID (_crID cr) i
|
{ _pjMoveParam = \i _ cr -> pjEffAtTime 35 $ trySpinByCID (_crID cr) i
|
||||||
, _pjIntParam = 2
|
, _curTweak = 2
|
||||||
, _pjDisplayParam = pjPadText "SPIN AMOUNT" . show
|
, _pjDisplayParam = pjPadText "SPIN AMOUNT" . show
|
||||||
, _pjMaxParam = 5
|
, _pjMaxParam = 5
|
||||||
}
|
}
|
||||||
thrustParam :: PjParam
|
thrustParam :: TweakParam
|
||||||
thrustParam = PjParam
|
thrustParam = PjExtraUpdate
|
||||||
{ _pjMoveParam = \i _ _ -> pjThrust i
|
{ _pjMoveParam = \i _ _ -> pjThrust i
|
||||||
, _pjIntParam = 1
|
, _curTweak = 1
|
||||||
, _pjDisplayParam = pjPadText "THRUST DELAY" . show
|
, _pjDisplayParam = pjPadText "THRUST DELAY" . show
|
||||||
, _pjMaxParam = 5
|
, _pjMaxParam = 5
|
||||||
}
|
}
|
||||||
@@ -124,25 +137,26 @@ doThrust pj w = w
|
|||||||
r1 = randInCirc 10 & evalState $ _randGen w
|
r1 = randInCirc 10 & evalState $ _randGen w
|
||||||
smokeGen = shellTrailCloud $ addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos))
|
smokeGen = shellTrailCloud $ addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos))
|
||||||
|
|
||||||
--flameLauncher :: Item
|
--aPJtweakParams :: Prop -> Item -> Creature -> World -> World
|
||||||
--flameLauncher = launcher & wpAmmo . amPayload .~ makeFlameExplosionAt
|
--aPJtweakParams pr it cr w =
|
||||||
--poisonLauncher :: Item
|
|
||||||
--poisonLauncher = launcher & wpAmmo . amPayload .~ makePoisonExplosionAt
|
|
||||||
--teslaLauncher :: Item
|
|
||||||
--teslaLauncher = launcher & wpAmmo . amPayload .~ makeTeslaExplosionAt
|
|
||||||
|
|
||||||
aRocketWithItemParams
|
aRocketWithItemParams :: Item -> Creature -> World -> World
|
||||||
:: Item -- ^ Firing item
|
|
||||||
-> Creature
|
|
||||||
-> World
|
|
||||||
-> World
|
|
||||||
aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
|
aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
|
||||||
where
|
where
|
||||||
am = _itConsumption it
|
am = _itConsumption it
|
||||||
i = IM.newKey $ _props w
|
i = IM.newKey $ _props w
|
||||||
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
ammoMvs pj w' = foldr (\pjP -> _pjMoveParam pjP (_pjIntParam pjP) it cr pj) w' (_amPjParams $ _aoType am)
|
params = _itParams it
|
||||||
|
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
|
theShell = defaultShell
|
||||||
{ _pjPos = pos
|
{ _pjPos = pos
|
||||||
, _pjStartPos = pos
|
, _pjStartPos = pos
|
||||||
@@ -150,7 +164,12 @@ aRocketWithItemParams it cr w = over props (IM.insert i theShell) w
|
|||||||
, _pjAcc = rotateV dir (V2 3 0)
|
, _pjAcc = rotateV dir (V2 3 0)
|
||||||
, _prDraw = _amPjDraw $ _aoType am
|
, _prDraw = _amPjDraw $ _aoType am
|
||||||
, _pjID = i
|
, _pjID = i
|
||||||
, _pjUpdate = \pj -> ammoMvs pj . decTimMvVel pj . moveShell pj
|
--, _pjUpdate = \pj -> ammoMvs pj . decTimMvVel pj . moveShell pj
|
||||||
|
, _pjUpdate = \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||||
|
. pjThrust thrustdelay pj
|
||||||
|
. reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||||
|
. decTimMvVel pj
|
||||||
|
. moveShell pj
|
||||||
, _pjPayload = _amPayload $ _aoType am
|
, _pjPayload = _amPayload $ _aoType am
|
||||||
, _pjTimer = 50
|
, _pjTimer = 50
|
||||||
}
|
}
|
||||||
@@ -242,7 +261,6 @@ remoteLauncher = defaultGun
|
|||||||
{ _aoType = defaultShellAmmo
|
{ _aoType = defaultShellAmmo
|
||||||
{ _amPayload = makeExplosionAt
|
{ _amPayload = makeExplosionAt
|
||||||
, _amString = ""
|
, _amString = ""
|
||||||
, _amPjParams = basicAmPjMoves
|
|
||||||
, _amPjDraw = shellPic
|
, _amPjDraw = shellPic
|
||||||
}
|
}
|
||||||
, _wpMaxAmmo = 30
|
, _wpMaxAmmo = 30
|
||||||
@@ -258,6 +276,10 @@ remoteLauncher = defaultGun
|
|||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
, _itFloorPict = launcherPic
|
, _itFloorPict = launcherPic
|
||||||
, _itAttachment = ItScope (V2 0 0) 0 1 True
|
, _itAttachment = ItScope (V2 0 0) 0 1 True
|
||||||
|
-- , _itParams = ShellLauncher
|
||||||
|
-- { _tweakSel = 0
|
||||||
|
-- , _tweakParams = basicAmPjMoves -- TODO change to allow tweaking rocket speed
|
||||||
|
-- }
|
||||||
}
|
}
|
||||||
|
|
||||||
fireRemoteLauncher :: Creature -> World -> World
|
fireRemoteLauncher :: Creature -> World -> World
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ subInventoryDisplay cfig w = case _inventoryMode w of
|
|||||||
col = itCol it
|
col = itCol it
|
||||||
|
|
||||||
cursorsZ :: Configuration -> Int -> Item -> Picture
|
cursorsZ :: Configuration -> Int -> Item -> Picture
|
||||||
cursorsZ cfig ipos it = case it ^? itConsumption . aoType . amParamSel of
|
cursorsZ cfig ipos it = case it ^? itParams . tweakSel of
|
||||||
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
|
Nothing -> f $ zConnect sp (V2 (155- hw) ( hh - 77.5))
|
||||||
Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5)))
|
Just jpos -> f $ zConnect sp (V2 (155 - hw) ( hh - (20 * fromIntegral jpos + 77.5)))
|
||||||
where
|
where
|
||||||
@@ -75,12 +75,12 @@ topInvCursor col iPos cfig w
|
|||||||
| otherwise = mainListCursor col iPos cfig
|
| otherwise = mainListCursor col iPos cfig
|
||||||
|
|
||||||
ammoTweakStrings :: Item -> [String]
|
ammoTweakStrings :: Item -> [String]
|
||||||
ammoTweakStrings it = case it ^? itConsumption . aoType . amPjParams of
|
ammoTweakStrings it = case it ^? itParams . tweakParams of
|
||||||
Just l -> map pjTweakString l
|
Just l -> map pjTweakString l
|
||||||
_ -> ["NOT TWEAKABLE"]
|
_ -> ["NOT TWEAKABLE"]
|
||||||
|
|
||||||
mCurs :: Item -> Configuration -> World -> Picture
|
mCurs :: Item -> Configuration -> World -> Picture
|
||||||
mCurs it cfig w = case it ^? itConsumption . aoType . amParamSel of
|
mCurs it cfig w = case it ^? itParams . tweakSel of
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just i
|
Just i
|
||||||
| ButtonRight `S.member` _mouseButtons w ->
|
| ButtonRight `S.member` _mouseButtons w ->
|
||||||
@@ -93,8 +93,8 @@ mCurs it cfig w = case it ^? itConsumption . aoType . amParamSel of
|
|||||||
x = 117.5
|
x = 117.5
|
||||||
y = 155
|
y = 155
|
||||||
|
|
||||||
pjTweakString :: PjParam -> String
|
pjTweakString :: TweakParam -> String
|
||||||
pjTweakString pj = _pjDisplayParam pj $ _pjIntParam pj
|
pjTweakString pj = _pjDisplayParam 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