Remove instantBullets
This commit is contained in:
File diff suppressed because one or more lines are too long
+7
-6
@@ -1,4 +1,5 @@
|
|||||||
module AesonHelp where
|
module AesonHelp where
|
||||||
|
|
||||||
import Data.Aeson (ToJSON)
|
import Data.Aeson (ToJSON)
|
||||||
import qualified Data.Aeson.Encode.Pretty as AEP
|
import qualified Data.Aeson.Encode.Pretty as AEP
|
||||||
import Data.ByteString.Lazy.Char8 (unpack)
|
import Data.ByteString.Lazy.Char8 (unpack)
|
||||||
@@ -7,15 +8,15 @@ import Data.Maybe
|
|||||||
getPretty :: ToJSON a => a -> [String]
|
getPretty :: ToJSON a => a -> [String]
|
||||||
getPretty = lines . unpack . AEP.encodePretty' (AEP.Config (AEP.Spaces 2) compare AEP.Generic False)
|
getPretty = lines . unpack . AEP.encodePretty' (AEP.Config (AEP.Spaces 2) compare AEP.Generic False)
|
||||||
|
|
||||||
getPrettyShort :: ToJSON a => a -> [String]
|
prettyShort :: ToJSON a => a -> [String]
|
||||||
getPrettyShort = mapMaybe cullPretty . getPretty
|
prettyShort = mapMaybe cullPretty . getPretty
|
||||||
|
|
||||||
cullPretty :: String -> Maybe String
|
cullPretty :: String -> Maybe String
|
||||||
cullPretty s = case dropWhile (== ' ') s of
|
cullPretty s = case dropWhile (== ' ') s of
|
||||||
']':_ -> Nothing
|
']' : _ -> Nothing
|
||||||
'[':_ -> Nothing
|
'[' : _ -> Nothing
|
||||||
'}':_ -> Nothing
|
'}' : _ -> Nothing
|
||||||
'{':_ -> Nothing
|
'{' : _ -> Nothing
|
||||||
_ -> Just $ filter f s
|
_ -> Just $ filter f s
|
||||||
where
|
where
|
||||||
f '_' = False
|
f '_' = False
|
||||||
|
|||||||
+2
-3
@@ -44,7 +44,6 @@ doMagnetBuBu mg bu = if isclose
|
|||||||
MagnetAttract -> bu & buVel %~ vecTurnTo (10 * pi / (d+40)) bpos mpos
|
MagnetAttract -> bu & buVel %~ vecTurnTo (10 * pi / (d+40)) bpos mpos
|
||||||
MagnetRepulse -> bu & buVel %~ vecTurnTo (10 * pi / (d+40)) bpos (2*bpos - mpos)
|
MagnetRepulse -> bu & buVel %~ vecTurnTo (10 * pi / (d+40)) bpos (2*bpos - mpos)
|
||||||
else bu
|
else bu
|
||||||
|
|
||||||
where
|
where
|
||||||
bvel = bu ^. buVel
|
bvel = bu ^. buVel
|
||||||
mpos = mg ^. mgPos
|
mpos = mg ^. mgPos
|
||||||
@@ -126,7 +125,7 @@ useBulletPayload bu = case _buPayload bu of
|
|||||||
BulBall FlashBall -> Just makeFlashBall
|
BulBall FlashBall -> Just makeFlashBall
|
||||||
|
|
||||||
makeFragBullets :: Point2 -> World -> World
|
makeFragBullets :: Point2 -> World -> World
|
||||||
makeFragBullets p w = w & cWorld . lWorld . instantBullets .++~ bus
|
makeFragBullets p w = w & cWorld . lWorld . bullets .++~ bus
|
||||||
where
|
where
|
||||||
bus = zipWith f (take 10 as) (take 10 ss)
|
bus = zipWith f (take 10 as) (take 10 ss)
|
||||||
as = randomRs (0, 2 * pi) $ _randGen w
|
as = randomRs (0, 2 * pi) $ _randGen w
|
||||||
@@ -141,7 +140,7 @@ makeFragBullets p w = w & cWorld . lWorld . instantBullets .++~ bus
|
|||||||
]
|
]
|
||||||
|
|
||||||
makeFlak :: Bullet -> Point2 -> World -> World
|
makeFlak :: Bullet -> Point2 -> World -> World
|
||||||
makeFlak bu _ w = w & cWorld . lWorld . instantBullets .++~ [f x | x <- xs]
|
makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs]
|
||||||
where
|
where
|
||||||
s = min 10 (0.5 * magV (_buVel bu))
|
s = min 10 (0.5 * magV (_buVel bu))
|
||||||
xs = take 5 $ randomRs (-s,s) $ _randGen w
|
xs = take 5 $ randomRs (-s,s) $ _randGen w
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ data LWorld = LWorld
|
|||||||
, _gusts :: IM.IntMap Gust
|
, _gusts :: IM.IntMap Gust
|
||||||
, _props :: IM.IntMap Prop
|
, _props :: IM.IntMap Prop
|
||||||
, _projectiles :: IM.IntMap Projectile
|
, _projectiles :: IM.IntMap Projectile
|
||||||
, _instantBullets :: [Bullet]
|
-- , _instantBullets :: [Bullet]
|
||||||
, _bullets :: [Bullet]
|
, _bullets :: [Bullet]
|
||||||
, _radarSweeps :: [RadarSweep]
|
, _radarSweeps :: [RadarSweep]
|
||||||
, _energyBalls :: [EnergyBall]
|
, _energyBalls :: [EnergyBall]
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ debugSelectCreatureList cid u =
|
|||||||
|
|
||||||
|
|
||||||
debugList :: (Functor f, ToJSON a) => String -> f a -> f [String]
|
debugList :: (Functor f, ToJSON a) => String -> f a -> f [String]
|
||||||
debugList str = fmap (([str] ++) . getPrettyShort )
|
debugList str = fmap (([str] ++) . prettyShort )
|
||||||
|
|
||||||
|
|
||||||
clickGetCreature :: Universe -> DebugInfo
|
clickGetCreature :: Universe -> DebugInfo
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ defaultLWorld =
|
|||||||
, _itemLocations = IM.empty
|
, _itemLocations = IM.empty
|
||||||
, _props = IM.empty
|
, _props = IM.empty
|
||||||
, _projectiles = IM.empty
|
, _projectiles = IM.empty
|
||||||
, _instantBullets = []
|
-- , _instantBullets = []
|
||||||
, _bullets = []
|
, _bullets = []
|
||||||
, _flames = []
|
, _flames = []
|
||||||
, _radarSweeps = []
|
, _radarSweeps = []
|
||||||
|
|||||||
@@ -478,9 +478,10 @@ makeBullet' bu itm cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
|
|||||||
makeBullet :: Bullet -> Item -> Point2 -> Float -> World -> World
|
makeBullet :: Bullet -> Item -> Point2 -> Float -> World -> World
|
||||||
makeBullet thebullet itm bulpos dir w =
|
makeBullet thebullet itm bulpos dir w =
|
||||||
w & randGen .~ g''
|
w & randGen .~ g''
|
||||||
& cWorld . lWorld . instantBullets
|
& cWorld . lWorld . bullets
|
||||||
.:~ ( thebullet
|
.:~ ( thebullet
|
||||||
& buPos .~ bulpos
|
& buPos .~ bulpos
|
||||||
|
& buOldPos .~ bulpos
|
||||||
& buVel %~ (rotateV dir . (muzvel *.*))
|
& buVel %~ (rotateV dir . (muzvel *.*))
|
||||||
& buDrag *~ drag
|
& buDrag *~ drag
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import qualified Data.Map.Strict as M
|
|||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u =
|
testStringInit u =
|
||||||
(map show $ u ^.. uvWorld . cWorld . lWorld . oldMagnets)
|
(map show $ u ^. uvWorld . cWorld . lWorld . oldMagnets)
|
||||||
<>
|
<>
|
||||||
(map show $ u ^.. uvWorld . cWorld . lWorld . bullets)
|
(foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . bullets)
|
||||||
-- fromMaybe mempty $ do
|
-- fromMaybe mempty $ do
|
||||||
-- cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
|
-- cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
|
||||||
-- let itms = IM.elems $ cr ^. crInv
|
-- let itms = IM.elems $ cr ^. crInv
|
||||||
|
|||||||
+8
-7
@@ -543,7 +543,8 @@ updateRadarBlips = updateObjMapMaybe radarBlips updateRadarBlip
|
|||||||
|
|
||||||
{- Apply internal particle updates, delete 'Nothing's. -}
|
{- Apply internal particle updates, delete 'Nothing's. -}
|
||||||
updateBullets :: World -> World
|
updateBullets :: World -> World
|
||||||
updateBullets w = updateInstantBullets $ set (cWorld . lWorld . bullets) (catMaybes ps) w'
|
--updateBullets w = updateInstantBullets $ set (cWorld . lWorld . bullets) (catMaybes ps) w'
|
||||||
|
updateBullets w = set (cWorld . lWorld . bullets) (catMaybes ps) w'
|
||||||
where
|
where
|
||||||
(w', ps) = mapAccumR updateBullet w $ w ^. cWorld . lWorld . bullets
|
(w', ps) = mapAccumR updateBullet w $ w ^. cWorld . lWorld . bullets
|
||||||
|
|
||||||
@@ -648,12 +649,12 @@ updateClouds = updateObjCatMaybes clouds updateCloud
|
|||||||
-- Just
|
-- Just
|
||||||
-- (intersectSegSegss x y ass)
|
-- (intersectSegSegss x y ass)
|
||||||
--intersectSegsSegss _ _ = Nothing
|
--intersectSegsSegss _ _ = Nothing
|
||||||
updateInstantBullets :: World -> World
|
--updateInstantBullets :: World -> World
|
||||||
updateInstantBullets w = case w ^. cWorld . lWorld . instantBullets of
|
--updateInstantBullets w = case w ^. cWorld . lWorld . instantBullets of
|
||||||
[] -> w
|
-- [] -> w
|
||||||
ps ->
|
-- ps ->
|
||||||
let (w', ps') = mapAccumR updateBullet (w & cWorld . lWorld . instantBullets .~ []) ps
|
-- let (w', ps') = mapAccumR updateBullet (w & cWorld . lWorld . instantBullets .~ []) ps
|
||||||
in updateInstantBullets $ w' & cWorld . lWorld . bullets .++~ catMaybes ps'
|
-- in updateInstantBullets $ w' & cWorld . lWorld . bullets .++~ catMaybes ps'
|
||||||
|
|
||||||
--updateInstantParticles :: World -> World
|
--updateInstantParticles :: World -> World
|
||||||
--updateInstantParticles w = case _instantParticles w of
|
--updateInstantParticles w = case _instantParticles w of
|
||||||
|
|||||||
Reference in New Issue
Block a user