Linting, refactor random angle walk for flamer
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
{- |
|
||||
Extra weapon effects, supplementing explicit use effects.
|
||||
-}
|
||||
module Dodge.Item.Weapon.ExtraEffect
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Item.Weapon.Decoration
|
||||
import Dodge.Item.Weapon.UseEffect
|
||||
import Dodge.WorldEvent.Flash
|
||||
import Dodge.WorldEvent.ThingsHit
|
||||
import Picture
|
||||
import Geometry.Vector
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
{- |
|
||||
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
|
||||
wpRecock :: ItEffect
|
||||
wpRecock = ItInvEffect
|
||||
{_itInvEffect = f
|
||||
,_itEffectCounter = 0
|
||||
}
|
||||
where
|
||||
f cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust fOnIt i
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
moveHammerUp HammerReleased = HammerUp
|
||||
moveHammerUp HammerUp = HammerUp
|
||||
fOnIt it = it & itHammer %~ moveHammerUp
|
||||
{- |
|
||||
Special recock for the bezier gun.
|
||||
Not sure of its purpose at this time... -}
|
||||
bezierRecock :: ItEffect
|
||||
bezierRecock = ItInvEffect
|
||||
{_itInvEffect = f
|
||||
,_itEffectCounter = 0
|
||||
}
|
||||
where
|
||||
f cr i = creatures . ix (_crID cr) . crInv %~ IM.adjust fOnIt i
|
||||
fOnIt it = case _itHammer it of
|
||||
HammerDown -> it & itHammer .~ HammerUp
|
||||
_ -> it & itAttachment .~ Nothing
|
||||
{- |
|
||||
Creates a laser scope and recocks the weapon.
|
||||
-}
|
||||
itemLaserScopeEffect :: ItEffect
|
||||
itemLaserScopeEffect
|
||||
= ItInvEffect {_itInvEffect = f ,_itEffectCounter = 0 }
|
||||
where
|
||||
moveHammerUp !HammerDown = HammerReleased
|
||||
moveHammerUp !_ = HammerUp
|
||||
f cr invid w
|
||||
| invid == _crInvSel cr = w
|
||||
& particles %~ (:) (makeLaserScope sp ep reloadFrac)
|
||||
& creatures . ix (_crID cr) . crInv . ix invid . itHammer %~ moveHammerUp
|
||||
& laserScopeTargetGlow col glowPoint
|
||||
| otherwise = w
|
||||
where
|
||||
p = _crPos cr
|
||||
d = _crDir cr
|
||||
r = _crRad cr
|
||||
sp = p +.+ (r + 3) *.* unitVectorAtAngle d
|
||||
xp = sp +.+ 3000 *.* unitVectorAtAngle d
|
||||
ep = case listToMaybe $ thingsHitLongLine sp xp w of
|
||||
Just (p,_) -> p
|
||||
Nothing -> xp
|
||||
glowPoint = case listToMaybe $ thingsHitLongLine sp xp w of
|
||||
Just (p,E3x2 wl) -> p +.+ 2 *.* wallNormal wl
|
||||
_ -> ep -.- 2 *.* unitVectorAtAngle d
|
||||
it = (cr ^. crInv) IM.! invid
|
||||
reloadFrac
|
||||
| _wpLoadedAmmo it == 0 = 1
|
||||
| otherwise = fromIntegral (_wpReloadState it) / fromIntegral (_wpReloadTime it)
|
||||
col = mixColors reloadFrac (1-reloadFrac) red green
|
||||
{- |
|
||||
Automatically send out radar pulses that detect walls. -}
|
||||
autoRadarEffect :: ItEffect
|
||||
autoRadarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
||||
where
|
||||
f 0 cr i w = aRadarPulse (_crID cr) w
|
||||
& creatures . ix (_crID cr) . crInv . ix i
|
||||
. itEffect . itInvEffect .~ f 100
|
||||
f t cr i w = w
|
||||
& creatures . ix (_crID cr) . crInv . ix i
|
||||
. itEffect . itInvEffect .~ f (t-1)
|
||||
{- |
|
||||
Automatically send out sonar pulses that detect creatures. -}
|
||||
autoSonarEffect :: ItEffect
|
||||
autoSonarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
||||
where f 0 cr i w = aSonarPulse (_crID cr)
|
||||
w & creatures . ix (_crID cr) . crInv . ix i
|
||||
. itEffect . itInvEffect .~ f 140
|
||||
f t cr i w = w & creatures . ix (_crID cr) . crInv . ix i
|
||||
. itEffect . itInvEffect .~ f (t-1)
|
||||
Reference in New Issue
Block a user