Commit before attempting to unify hammers for used items
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module Dodge.Item.Weapon.BatteryGuns
|
||||
( lasGun
|
||||
, lasDual
|
||||
, dualBeam
|
||||
, lasGunWide
|
||||
, lasWidePulse
|
||||
, lasSway
|
||||
@@ -207,31 +207,35 @@ lasFocus n = lasGunWide n
|
||||
n' = 9 * n
|
||||
xs = [ 0.25 * (fromIntegral x - fromIntegral (n'-1) /2) | x <- [0..n'-1] ]
|
||||
|
||||
lasDual :: Item
|
||||
lasDual = lasGun
|
||||
& itType . iyBase .~ LASGUNDUAL
|
||||
dualBeam :: Item
|
||||
dualBeam = lasGun
|
||||
& itType . iyBase .~ DUALBEAM
|
||||
& itDimension . dimPortage . muzPos .~ 0
|
||||
& itDimension .dimSPic .~ dualBeamPic
|
||||
& itParams .~ DualBeam
|
||||
{ _phaseV = 1
|
||||
, _lasColor = orange
|
||||
, _lasColor2 = blue
|
||||
, _lasColor = red
|
||||
, _lasColor2 = green
|
||||
, _lasCycle = 0
|
||||
, _lasDamage = 11
|
||||
, _lasBeam = BeamCombine lasBeamCombine
|
||||
, _subParams = Nothing
|
||||
, _dbGap = 20
|
||||
}
|
||||
& itUse .~ (ruseInstant shootDualLaser NoHammer
|
||||
[ ammoCheckI
|
||||
-- , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 10) $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 (-10)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 (thegap it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
|
||||
, withItem $ \it -> withMuzPosShift (V2 0 (-thegap it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
|
||||
, withSoundForI tone440sawtoothquietS 2
|
||||
, useAmmoAmount 1
|
||||
]
|
||||
& useAim . aimWeight .~ 6
|
||||
& useAim . aimRange .~ 1
|
||||
& useAim . aimStance .~ TwoHandTwist
|
||||
& useAim . aimStance .~ TwoHandFlat
|
||||
)
|
||||
& itType . iyModules . at ModDualBeam ?~ EMPTYMODULE
|
||||
where
|
||||
thegap = _dbGap . _itParams
|
||||
lasSwing :: Item
|
||||
lasSwing = lasGun
|
||||
& itType . iyBase .~ LASGUNSWING
|
||||
@@ -297,6 +301,19 @@ lasGunPic it =
|
||||
amFrac = fractionLoadedAmmo it
|
||||
col = brightX 2 1.5 $ mixColors amFrac (1-amFrac) green red
|
||||
|
||||
dualBeamPic :: Item -> SPic
|
||||
dualBeamPic it =
|
||||
( colorSH blue $
|
||||
upperPrismPoly 4 (rectNESW gap 3 (-gap) 1)
|
||||
<> upperPrismPoly 4 (rectNESW gap (-1) (-gap) (-3))
|
||||
<> upperPrismPoly 1 (rectNESW gap 3 (-gap) (-3))
|
||||
, setLayer BloomNoZWrite . color col . setDepth 1.1 . polygon $ rectNESW gap 1 (-gap) (-1)
|
||||
)
|
||||
where
|
||||
amFrac = fractionLoadedAmmo it
|
||||
col = brightX 2 1.5 $ mixColors amFrac (1-amFrac) green red
|
||||
gap = _dbGap (_itParams it) - 3
|
||||
|
||||
lasGunTweak :: TweakParam
|
||||
lasGunTweak = TweakParam
|
||||
{ _doTweak = thetweak
|
||||
@@ -380,7 +397,6 @@ shootTeslaArc it cr w = w'
|
||||
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
|
||||
|
||||
shootLaser :: Item -> Creature -> World -> World
|
||||
shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam phasev pos dir
|
||||
where
|
||||
@@ -389,7 +405,6 @@ shootLaser it cr = instantParticles .:~ lasRayAt (_lasColor $ _itParams it) dam
|
||||
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
|
||||
dam = _lasDamage $ _itParams it
|
||||
|
||||
|
||||
shootDualLaser :: Item -> Creature -> World -> World
|
||||
shootDualLaser it cr w = w'
|
||||
& newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
|
||||
@@ -399,8 +414,9 @@ shootDualLaser it cr w = w'
|
||||
dir = _crDir cr
|
||||
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
|
||||
aimlength = aimingMuzzlePos cr it
|
||||
posl = pos +.+ (-10) * vNormal (unitVectorAtAngle dir)
|
||||
posr = pos +.+ 10 * vNormal (unitVectorAtAngle dir)
|
||||
gap = _dbGap . _itParams $ it
|
||||
posl = pos +.+ (-gap) *.* vNormal (unitVectorAtAngle dir)
|
||||
posr = pos +.+ gap *.* vNormal (unitVectorAtAngle dir)
|
||||
mwp = mouseWorldPos w
|
||||
mwp' | dist mwp (_crPos cr) < aimlength + 5 = _crPos cr +.+ (aimlength + 5) *.* unitVectorAtAngle dir
|
||||
| otherwise = mwp
|
||||
|
||||
@@ -22,35 +22,36 @@ reflectLaserAlong phasev sp ep w = case thingHitFilt (const True) _wlDraw sp ep
|
||||
Just (p,Right wl)
|
||||
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev
|
||||
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
|
||||
(p +.+ (dist p ep) *.* unitVectorAtAngle (reflDirWall sp p wl))
|
||||
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
|
||||
w
|
||||
| wlIsSeeThrough wl -> second (p:) $ reflectLaserAlong phasev
|
||||
(p +.+ normalizeV (refract sp ep wl p))
|
||||
(refract sp ep wl p)
|
||||
(p +.+ normalizeV (refract phasev sp ep wl p))
|
||||
(refract phasev sp ep wl p)
|
||||
w
|
||||
| otherwise -> (Just (p,Right wl), [p])
|
||||
Just (p,obj) -> (Just (p,obj), [p])
|
||||
Nothing -> (Nothing, [ep])
|
||||
where
|
||||
refract x y wl p
|
||||
| isEntering = p +.+ rotateV angleRef (normalDist wlNormal)
|
||||
| otherwise = p +.+ rotateV angleRef' (normalDist wlNormal')
|
||||
where
|
||||
wlNormal = vNormal $ uncurry (-.-) $ swap (_wlLine wl)
|
||||
wlNormal' = vNormal $ uncurry (-.-) (_wlLine wl)
|
||||
normalDist wlnormal = magV (p -.- y) *.* normalizeV wlnormal
|
||||
angleInc = piRange $ argV wlNormal - argV (x -.- y)
|
||||
angleRef
|
||||
| reflectExternal = angleInc
|
||||
| otherwise = asin $ sin angleInc / phasev
|
||||
piRange a'
|
||||
| a' > pi = a' - 2 * pi
|
||||
| a' > negate pi = a'
|
||||
| otherwise = a' + 2 * pi
|
||||
isEntering = not $ isLeftOf (x -.- y) (uncurry (-.-) (_wlLine wl))
|
||||
angleInc' = piRange $ argV wlNormal' - argV (x -.- y)
|
||||
angleRef'
|
||||
| reflectInternal = angleInc'
|
||||
| otherwise = asin $ phasev * sin angleInc'
|
||||
reflectInternal = 1 < abs (phasev * sin angleInc')
|
||||
reflectExternal = 1 < abs (sin angleInc / phasev)
|
||||
refract :: Float -> Point2 -> Point2 -> Wall -> Point2 -> Point2
|
||||
{-# INLINE refract #-}
|
||||
refract phasev x y wl p
|
||||
| isEntering = p +.+ rotateV angleRef (normalDist wlNormal)
|
||||
| otherwise = p +.+ rotateV angleRef' (normalDist wlNormal')
|
||||
where
|
||||
wlNormal = vNormal $ uncurry (-.-) $ swap (_wlLine wl)
|
||||
wlNormal' = vNormal $ uncurry (-.-) (_wlLine wl)
|
||||
normalDist wlnormal = magV (p -.- y) *.* normalizeV wlnormal
|
||||
angleInc = piRange $ argV wlNormal - argV (x -.- y)
|
||||
angleRef
|
||||
| reflectExternal = angleInc
|
||||
| otherwise = asin $ sin angleInc / phasev
|
||||
piRange a'
|
||||
| a' > pi = a' - 2 * pi
|
||||
| a' > negate pi = a'
|
||||
| otherwise = a' + 2 * pi
|
||||
isEntering = not $ isLeftOf (x -.- y) (uncurry (-.-) (_wlLine wl))
|
||||
angleInc' = piRange $ argV wlNormal' - argV (x -.- y)
|
||||
angleRef'
|
||||
| reflectInternal = angleInc'
|
||||
| otherwise = asin $ phasev * sin angleInc'
|
||||
reflectInternal = 1 < abs (phasev * sin angleInc')
|
||||
reflectExternal = 1 < abs (sin angleInc / phasev)
|
||||
|
||||
@@ -14,6 +14,7 @@ module Dodge.Item.Weapon.TriggerType
|
||||
, withTempLight
|
||||
, withItem
|
||||
, withItemUpdate
|
||||
, withItemUpdate'
|
||||
, ammoUseCheck
|
||||
, rateIncAB
|
||||
, torqueBefore
|
||||
@@ -367,6 +368,10 @@ shootL f item cr w
|
||||
-- reloadCondition = _laLoaded (_itConsumption item) == 0
|
||||
withItem :: (Item -> ChainEffect) -> ChainEffect
|
||||
withItem g f it = g it f it
|
||||
|
||||
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
||||
withItemUpdate' up f it cr = f it cr . (creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
|
||||
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
|
||||
withItemUpdate up g f it cr = g it f it cr . (creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
|
||||
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
||||
|
||||
Reference in New Issue
Block a user