Refactor wall zoning, remove streaming
This commit is contained in:
+9
-8
@@ -2,6 +2,7 @@ module Dodge.Bullet
|
||||
( updateBullet
|
||||
, useAmmoParams
|
||||
) where
|
||||
import qualified ListHelp as List
|
||||
import Dodge.EnergyBall
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Data
|
||||
@@ -87,12 +88,12 @@ bulletSpawn bu = case _buSpawn bu of
|
||||
BulBall TeslaBall -> Just makeStaticBall
|
||||
|
||||
hitEffFromBul :: Float -> Bullet
|
||||
-> StreamOf (Point2, Either Creature Wall)
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
-> World
|
||||
-> (World,Maybe Bullet)
|
||||
hitEffFromBul x bu hitstream w = case _buEffect bu of
|
||||
PenetrateBullet -> movePenBullet x bu hitstream w
|
||||
BounceBullet -> case runIdentity (S.head_ hitstream) of
|
||||
BounceBullet -> case List.safeHead hitstream of
|
||||
Nothing -> (w, moveBullet x bu)
|
||||
Just (hp,crwl) -> fromMaybe (expireAndDamage x bu hitstream w) $ do
|
||||
dir <- bounceDir (hp,crwl)
|
||||
@@ -118,10 +119,10 @@ damageThingHit bu (p,crwl) = case crwl of
|
||||
|
||||
expireAndDamage :: Float
|
||||
-> Bullet
|
||||
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
-> World
|
||||
-> (World, Maybe Bullet)
|
||||
expireAndDamage y bt things w = case runIdentity $ S.head_ things of
|
||||
expireAndDamage y bt things w = case List.safeHead things of
|
||||
Nothing -> (w, moveBullet y bt)
|
||||
Just x -> (damageThingHit bt x w, destroyAt (fst x) bt)
|
||||
|
||||
@@ -139,11 +140,11 @@ destroyAt hitp pt = Just $ pt
|
||||
where
|
||||
p = _buPos pt
|
||||
|
||||
movePenBullet :: Float -> Bullet -> StreamOf (Point2, Either Creature Wall)
|
||||
movePenBullet :: Float -> Bullet -> [(Point2, Either Creature Wall)]
|
||||
-> World -> (World, Maybe Bullet)
|
||||
movePenBullet x bu hitstream w = case runIdentity (S.next hitstream) of
|
||||
Left _ -> (w,moveBullet x bu)
|
||||
Right ((p,crwl),strm) -> if penThing crwl
|
||||
movePenBullet x bu hitstream w = case hitstream of
|
||||
[] -> (w,moveBullet x bu)
|
||||
((p,crwl):strm) -> if penThing crwl
|
||||
then first (damageThingHit bu (p,crwl)) $ movePenBullet x bu strm w
|
||||
else expireAndDamage x bu hitstream w
|
||||
|
||||
|
||||
Reference in New Issue
Block a user