71 lines
2.2 KiB
Haskell
71 lines
2.2 KiB
Haskell
module Dodge.Beam where
|
|
|
|
import Data.Maybe
|
|
import Dodge.Data.World
|
|
import Dodge.Flame
|
|
import Dodge.Item.Location
|
|
import Dodge.Tesla.Arc
|
|
import Geometry
|
|
import LensHelp
|
|
import Picture
|
|
|
|
doBeamCombine ::
|
|
BeamCombineType ->
|
|
(Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)) ->
|
|
World ->
|
|
World
|
|
doBeamCombine bct = case bct of
|
|
FlameBeamCombine -> flameBeamCombine
|
|
LasBeamCombine -> lasBeamCombine
|
|
TeslaBeamCombine -> teslaBeamCombine
|
|
SplitBeamCombine -> splitBeamCombine
|
|
NoBeamCombine -> const id
|
|
|
|
flameBeamCombine ::
|
|
(Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)) ->
|
|
World ->
|
|
World
|
|
flameBeamCombine (p, (a, b, _), (x, y, _)) =
|
|
makeFlame p (2 *.* normalizeV (normalizeV (b -.- a) +.+ normalizeV (y -.- x)))
|
|
|
|
lasBeamCombine ::
|
|
(Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)) ->
|
|
World ->
|
|
World
|
|
lasBeamCombine (p, (a, b, _), (x, y, _)) =
|
|
cWorld . lWorld . lasers .:~ lasRayAt yellow 11 1 p (argV (normalizeV (b -.- a) +.+ normalizeV (y -.- x)))
|
|
|
|
splitBeamCombine ::
|
|
(Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)) ->
|
|
World ->
|
|
World
|
|
splitBeamCombine (p, (a, b, _), (x, y, _)) =
|
|
(cWorld . lWorld . lasers .:~ lasRayAt yellow 11 1 p (dir + 0.5 * pi))
|
|
. (cWorld . lWorld . lasers .:~ lasRayAt yellow 11 1 p (dir -0.5 * pi))
|
|
where
|
|
dir = argV (normalizeV (b -.- a) +.+ normalizeV (y -.- x))
|
|
|
|
teslaBeamCombine ::
|
|
(Point2, (Point2, Point2, Beam), (Point2, Point2, Beam)) ->
|
|
World ->
|
|
World
|
|
teslaBeamCombine (p, (a, b, bm), (x, y, _)) w =
|
|
w' & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itid) . itParams . subParams ?~ ip
|
|
where
|
|
itid = fromJust $ _bmOrigin bm
|
|
dir = argV (normalizeV (b -.- a) +.+ normalizeV (y -.- x))
|
|
(w', ip) = makeTeslaArc (fromJust . _subParams $ _itParams it) p dir w
|
|
it = case getItem itid w of
|
|
Nothing -> error "tried to get item use teslaBeamCombine that doesn't exist"
|
|
Just itm -> itm
|
|
|
|
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> LaserStart
|
|
lasRayAt col dam phasev pos dir =
|
|
LaserStart
|
|
{ _lpType = DamageLaser dam
|
|
, _lpPhaseV = phasev
|
|
, _lpPos = pos
|
|
, _lpDir = dir
|
|
, _lpColor = col
|
|
}
|