Refactor tesla
This commit is contained in:
+15
-9
@@ -7,6 +7,7 @@ import RandomHelp
|
||||
import Picture
|
||||
import Geometry
|
||||
import LensHelp
|
||||
import Dodge.ArcStep
|
||||
--import Dodge.Data
|
||||
--import Geometry
|
||||
--import LensHelp
|
||||
@@ -54,11 +55,15 @@ moveTeslaArc thearc w pt
|
||||
makeaspark = randSpark ELECTRICAL rspeed rcol rdir lp
|
||||
makesparks = makeaspark . makeaspark . makeaspark
|
||||
(lp,ld) = case last thearc of
|
||||
ArcStep lp' ld' Nothing -> (lp',ld')
|
||||
ArcStep lp' ld' (Just (Left cr)) -> (lp' -.- (_crRad cr + 1) *.* unitVectorAtAngle ld',ld'+pi)
|
||||
ArcStep lp' ld' (Just (Right _)) -> (lp' -.- 2 *.* unitVectorAtAngle ld',ld'+pi)
|
||||
damthings (ArcStep _ _ Nothing) = id
|
||||
damthings (ArcStep p dir (Just crwl)) = damageCrWall (thedamage p dir) crwl
|
||||
ArcStep lp' ld' NothingID -> (lp',ld')
|
||||
ArcStep lp' ld' (CrID crid) -> case w ^? creatures . ix crid of
|
||||
Nothing -> (lp',ld')
|
||||
Just cr -> (lp' -.- (_crRad cr + 1) *.* unitVectorAtAngle ld',ld'+pi)
|
||||
ArcStep lp' ld' (WlID wlid) -> case w ^? walls . ix wlid of
|
||||
Nothing -> (lp',ld')
|
||||
Just _ -> (lp' -.- 2 *.* unitVectorAtAngle ld',ld'+pi)
|
||||
--damthings (ArcStep _ _ NothingID) = id
|
||||
damthings (ArcStep p dir crwl) = damageCrWlID (thedamage p dir) crwl
|
||||
thedamage p dir = Damage ELECTRICAL 50 (p -.- q) p (p +.+ q) NoDamageEffect
|
||||
where
|
||||
q = 5 *.* unitVectorAtAngle dir
|
||||
@@ -84,14 +89,14 @@ createArc arcparams w p dir = updateArc arcparams w p dir
|
||||
createNewArc :: ItemParams -> World -> Point2 -> Float
|
||||
-> State StdGen [ArcStep]
|
||||
createNewArc arcparams w p dir = take (_arcNumber arcparams)
|
||||
<$> unfoldrMID (_newArcStep arcparams arcparams w) (ArcStep p dir Nothing)
|
||||
<$> unfoldrMID (doStep (_newArcStep arcparams) arcparams w) (ArcStep p dir NothingID)
|
||||
|
||||
updateArc :: ItemParams
|
||||
-> World
|
||||
-> Point2
|
||||
-> Float
|
||||
-> State StdGen [ArcStep]
|
||||
updateArc ip w p dir = take (_arcNumber ip) <$> zipArcs ip w (ArcStep p dir Nothing) carc
|
||||
updateArc ip w p dir = take (_arcNumber ip) <$> zipArcs ip w (ArcStep p dir NothingID) carc
|
||||
where
|
||||
carc = tail $ fromJust $ _currentArc ip
|
||||
|
||||
@@ -101,10 +106,11 @@ zipArcs :: ItemParams
|
||||
-> [ArcStep]
|
||||
-> State StdGen [ArcStep]
|
||||
zipArcs ip w x (y:ys) = (x :) <$> do
|
||||
defaultnext <- _newArcStep ip ip w x
|
||||
defaultnext <- doStep (_newArcStep ip) ip w x
|
||||
case defaultnext of
|
||||
Nothing -> return []
|
||||
Just z@(ArcStep _ _ (Just _)) -> return [z]
|
||||
Just z@(ArcStep _ _ (CrID _)) -> return [z]
|
||||
Just z@(ArcStep _ _ (WlID _)) -> return [z]
|
||||
Just z -> do
|
||||
p <- randInCirc 5
|
||||
let csize = _arcSize ip
|
||||
|
||||
Reference in New Issue
Block a user