Cleanup
This commit is contained in:
@@ -31,64 +31,26 @@ updateProjectile :: Proj -> World -> World
|
||||
updateProjectile pj = case pj of
|
||||
Shell{} -> upsProjectile pj
|
||||
|
||||
--explodeRemoteRocket' ::
|
||||
-- -- | Item id
|
||||
---- Maybe Int ->
|
||||
-- Proj ->
|
||||
-- World ->
|
||||
-- World
|
||||
--explodeRemoteRocket' thepj w =
|
||||
-- w
|
||||
-- & cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||
-- & updateitem
|
||||
-- where
|
||||
-- mitid = _prjMITID thepj
|
||||
-- updateitem = fromMaybe (cWorld . projectiles . at pjid .~ Nothing) $ do
|
||||
-- itid <- mitid
|
||||
-- itpos <- w ^? cWorld . itemLocations . ix itid
|
||||
-- return $
|
||||
-- (pointerToItemLocation itpos . itUse . heldUse .~ HeldDoNothing)
|
||||
-- . (cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid])
|
||||
-- pjid = _prjID thepj
|
||||
shellCollisionCheck :: (Proj -> World -> World) -> Proj -> World -> World
|
||||
shellCollisionCheck doExplode pj w
|
||||
| time > 340 && circOnSomeWall oldPos 4 w = doExplode pj w
|
||||
| time <= 340 && anythingHitCirc 2 oldPos newPos w = doExplode pj w
|
||||
| time <= 0 = doExplode pj w
|
||||
| otherwise = w
|
||||
where
|
||||
time = _prjTimer pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
|
||||
remoteShellCollisionCheck :: Proj -> World -> World
|
||||
remoteShellCollisionCheck pj w
|
||||
| time > 340 =
|
||||
if circOnSomeWall oldPos 4 w
|
||||
then doExplode
|
||||
else w
|
||||
| anythingHitCirc 2 oldPos newPos w = doExplode
|
||||
| time > 0 = w
|
||||
| otherwise = doExplode
|
||||
where
|
||||
time = _prjTimer pj
|
||||
doExplode = explodeRemoteRocket (fromJust (_prjMITID pj)) (_prjID pj) w
|
||||
i = _prjID pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
remoteShellCollisionCheck = shellCollisionCheck $ \pj -> explodeRemoteRocket (fromJust (_prjMITID pj)) (_prjID pj)
|
||||
|
||||
updateShell :: Proj -> World -> World
|
||||
updateShell pj w
|
||||
| time > 340 =
|
||||
if circOnSomeWall oldPos 4 w
|
||||
then doExplode
|
||||
else w
|
||||
| anythingHitCirc 2 oldPos newPos w = doExplode
|
||||
| time > 0 = w
|
||||
| otherwise = doExplode
|
||||
where
|
||||
time = _prjTimer pj
|
||||
doExplode =
|
||||
w
|
||||
& usePayload (_prjPayload pj) oldPos
|
||||
& stopSoundFrom (ShellSound i)
|
||||
& cWorld . projectiles %~ IM.delete i
|
||||
i = _prjID pj
|
||||
oldPos = _prjPos pj
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
plainShellCollisionCheck :: Proj -> World -> World
|
||||
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
(usePayload (_prjPayload pj) (_prjPos pj))
|
||||
. (stopSoundFrom (ShellSound (_prjID pj)))
|
||||
. (cWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
|
||||
upsProjectile :: Proj -> World -> World
|
||||
upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
||||
@@ -96,31 +58,31 @@ upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
||||
upProjectile :: ProjectileUpdate -> Proj -> World -> World
|
||||
upProjectile pu pj = case pu of
|
||||
PJRemoteShellCollisionCheck -> remoteShellCollisionCheck pj
|
||||
PJShellCollisionCheck -> updateShell pj
|
||||
PJShellCollisionCheck -> plainShellCollisionCheck pj
|
||||
PJDecTimMvVel -> decTimMvVel pj
|
||||
PJThrust st et
|
||||
| act st et -> doThrust pj
|
||||
| otherwise -> id
|
||||
PJSpin t cid spinamount
|
||||
| ain t -> trySpinByCID' cid spinamount pj
|
||||
| ain t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
PJTrack st et itid
|
||||
| act st et -> pjTrack' itid pj
|
||||
| act st et -> pjTrack itid pj
|
||||
| otherwise -> id
|
||||
PJReduceSpin x -> reduceSpinBy' x pj
|
||||
PJReduceSpin x -> reduceSpinBy x pj
|
||||
PJRemoteDirection st et cid itid
|
||||
| act st et -> setRemoteDir cid itid pj
|
||||
| otherwise -> id
|
||||
PJSetScope itid -> setRemoteScope itid (_prjPos pj)
|
||||
PJRetireRemote itid 0 pjid -> retireRemoteProj'' itid pjid
|
||||
PJRetireRemote itid 0 pjid -> retireRemoteProj itid pjid
|
||||
PJRetireRemote _ _ pjid -> cWorld . projectiles . ix pjid . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
where
|
||||
time = _prjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
ain t = time == t
|
||||
|
||||
retireRemoteProj'' :: Int -> Int -> World -> World
|
||||
retireRemoteProj'' itid pjid w =
|
||||
retireRemoteProj :: Int -> Int -> World -> World
|
||||
retireRemoteProj itid pjid w =
|
||||
w
|
||||
& pointerToItemLocation (_itemLocations (_cWorld w) IM.! itid)
|
||||
%~ ( (itScope . scopePos .~ V2 0 0)
|
||||
@@ -135,8 +97,8 @@ setRemoteDir cid itid pj w = w & cWorld . projectiles . ix (_prjID pj) . prjAcc
|
||||
--i = _prjID pj
|
||||
newdir
|
||||
| SDL.ButtonRight `M.member` _mouseButtons w
|
||||
-- && w ^? cWorld . creatures . ix cid . crInvSel . iselPos
|
||||
-- == w ^? cWorld . itemLocations . ix itid . ipInvID
|
||||
&& w ^? cWorld . creatures . ix cid . crInvSel . iselPos
|
||||
== w ^? cWorld . itemLocations . ix itid . ipInvID
|
||||
= _cameraRot (_cWorld w) + argV (_mousePos w)
|
||||
| otherwise = _prjDir pj
|
||||
|
||||
@@ -158,7 +120,7 @@ doThrust pj w =
|
||||
(sparkD, _) = randomR (-0.2, 0.2) $ _randGen w
|
||||
r1 = randInCirc 10 & evalState $ _randGen w
|
||||
|
||||
trySpinByCID' ::
|
||||
trySpinByCID ::
|
||||
-- | creature id
|
||||
Int ->
|
||||
-- | Spin amount
|
||||
@@ -166,7 +128,7 @@ trySpinByCID' ::
|
||||
Proj ->
|
||||
World ->
|
||||
World
|
||||
trySpinByCID' cid i pj w = w & cWorld . projectiles . ix pjid . prjSpin .~ newSpin
|
||||
trySpinByCID cid i pj w = w & cWorld . projectiles . ix pjid . prjSpin .~ newSpin
|
||||
where
|
||||
pjid = _prjID pj
|
||||
dir = argV $ _prjVel pj
|
||||
@@ -175,8 +137,8 @@ trySpinByCID' cid i pj w = w & cWorld . projectiles . ix pjid . prjSpin .~ newSp
|
||||
_ -> 0
|
||||
spinFactor = 5 * (6 - fromIntegral i)
|
||||
|
||||
pjTrack' :: Int -> Proj -> World -> World
|
||||
pjTrack' itid pj w = rotateToTarget pj w
|
||||
pjTrack :: Int -> Proj -> World -> World
|
||||
pjTrack itid pj w = rotateToTarget pj w
|
||||
where
|
||||
rotateToTarget _ = fromMaybe id $ do
|
||||
tpos <- w ^? itPoint . itTargeting . tgPos . _Just
|
||||
@@ -189,5 +151,5 @@ pjTrack' itid pj w = rotateToTarget pj w
|
||||
(argV $ _prjAcc pj)
|
||||
itPoint = pointerToItemLocation $ _itemLocations (_cWorld w) IM.! itid
|
||||
|
||||
reduceSpinBy' :: Float -> Proj -> World -> World
|
||||
reduceSpinBy' x pj = cWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
reduceSpinBy :: Float -> Proj -> World -> World
|
||||
reduceSpinBy x pj = cWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
|
||||
Reference in New Issue
Block a user