Remove unnecessary projectile code

This commit is contained in:
2024-12-28 10:20:17 +00:00
parent 2e67924339
commit 39a76f758a
3 changed files with 7 additions and 17 deletions
+2 -2
View File
@@ -25,8 +25,8 @@ data ProjectileUpdate
| DestroyPU {_pjuScreenID :: Maybe (NewInt ItmInt) | DestroyPU {_pjuScreenID :: Maybe (NewInt ItmInt)
,_pjuTimer :: Int} ,_pjuTimer :: Int}
| TimePU | TimePU
| CollisionEffectPU {_pjuControlID :: Maybe (NewInt ItmInt) | CollisionEffectPU
,_pjuDetonatorID :: Maybe (NewInt ItmInt) {_pjuDetonatorID :: Maybe (NewInt ItmInt)
,_pjuScreenID :: Maybe (NewInt ItmInt) ,_pjuScreenID :: Maybe (NewInt ItmInt)
} }
| ApplyGravityPU | ApplyGravityPU
+1 -1
View File
@@ -36,7 +36,7 @@ createShell homing mdetonator mscreen pjtype payload muz cr w = w
, _prjPayload = payload , _prjPayload = payload
, _prjTimer = lifespan , _prjTimer = lifespan
, _prjUpdates = , _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen [ CollisionEffectPU mdetonator mscreen
, TimePU , TimePU
, StartSpinPU (lifespan - 15) (_crID cr) spinamount , StartSpinPU (lifespan - 15) (_crID cr) spinamount
, RemoteDirectionPU (lifespan - thrustdelay) 0 , RemoteDirectionPU (lifespan - thrustdelay) 0
+4 -14
View File
@@ -26,9 +26,8 @@ updateProjectile pj w = foldl' (\w' pu -> upProjectile pu pj w') w (_prjUpdates
upProjectile :: ProjectileUpdate -> Projectile -> World -> World upProjectile :: ProjectileUpdate -> Projectile -> World -> World
upProjectile pu pj = case pu of upProjectile pu pj = case pu of
CollisionEffectPU mcontrolid mdetonatorid mscreenid -> CollisionEffectPU mdetonatorid mscreenid ->
shellCollisionCheck shellCollisionCheck
mcontrolid
mdetonatorid mdetonatorid
mscreenid mscreenid
pj pj
@@ -82,20 +81,17 @@ applyGravityPU pj w
--shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World --shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
shellCollisionCheck :: shellCollisionCheck ::
Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) -> Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) -> Maybe (NewInt ItmInt) ->
Projectile -> Projectile ->
World -> World ->
World World
shellCollisionCheck controlid detid screenid pj w shellCollisionCheck detid screenid pj w
-- | time > 330 && circOnSomeWall oldPos 4 w = g
-- | time <= 330 && anythingHitCirc 2 oldPos newPos w = g
| anythingHitCirc 2 oldPos newPos w = g | anythingHitCirc 2 oldPos newPos w = g
| time <= 0 = g | time <= 0 = g
| otherwise = w | otherwise = w
where where
g = explodeShell controlid detid screenid pj w g = explodeShell detid screenid pj w
time = _prjTimer pj time = _prjTimer pj
oldPos = _prjPos pj oldPos = _prjPos pj
newPos = oldPos +.+ _prjVel pj newPos = oldPos +.+ _prjVel pj
@@ -188,27 +184,21 @@ decTimMvVel pj =
pjid = _prjID pj pjid = _prjID pj
explodeShell :: explodeShell ::
Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) -> Maybe (NewInt ItmInt) ->
Maybe (NewInt ItmInt) -> Maybe (NewInt ItmInt) ->
Projectile -> Projectile ->
World -> World ->
World World
explodeShell controlid mdetid screenid pj w = explodeShell mdetid screenid pj w =
w w
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU screenid 30] & cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU screenid 30]
-- & cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
& usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj) & usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj)
& stopSoundFrom (ShellSound pjid) & stopSoundFrom (ShellSound pjid)
& updatedetonator & updatedetonator
& updatecontroller
where where
updatedetonator = fromMaybe id $ do updatedetonator = fromMaybe id $ do
detid <- mdetid detid <- mdetid
return $ pointerToItemID detid . itUse . uaParams . apProjectiles %~ delete pjid return $ pointerToItemID detid . itUse . uaParams . apProjectiles %~ delete pjid
deleteif (Just x) | x == pjid = Nothing deleteif (Just x) | x == pjid = Nothing
deleteif x = x deleteif x = x
updatecontroller = fromMaybe id $ do
cid <- controlid
return $ pointerToItemID cid . itUse . uaParams . apLinkedProjectile %~ deleteif
pjid = pj ^. prjID pjid = pj ^. prjID