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