Allow more general detection of item use focus

This commit is contained in:
2024-12-25 21:26:25 +00:00
parent aec56f4977
commit c788af47bd
12 changed files with 28 additions and 32 deletions
+12 -14
View File
@@ -25,7 +25,8 @@ updateProjectile pj w = foldl' (\w' pu -> upProjectile pu pj w') w (_prjUpdates
upProjectile :: ProjectileUpdate -> Projectile -> World -> World
upProjectile pu pj = case pu of
CollisionEffectPU mscreenid -> shellCollisionEffect mscreenid pj
CollisionEffectPU mscreenid -> shellCollisionCheck
mscreenid pj
TimePU -> decTimMvVel pj
ThrustPU st et
| act st et -> doThrust pj
@@ -45,17 +46,15 @@ upProjectile pu pj = case pu of
time = _prjTimer pj
act st et = time <= st && time >= et
shellCollisionEffect :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
shellCollisionEffect mscreenid = shellCollisionCheck $
\pj -> explodeShell mscreenid (_prjID pj)
shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
--shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
shellCollisionCheck :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
shellCollisionCheck f pj w
| time > 330 && circOnSomeWall oldPos 4 w = f pj w
| time <= 330 && anythingHitCirc 2 oldPos newPos w = f pj w
| time <= 0 = f pj w
| time > 330 && circOnSomeWall oldPos 4 w = g
| time <= 330 && anythingHitCirc 2 oldPos newPos w = g
| time <= 0 = g
| otherwise = w
where
g = explodeShell f pj w
time = _prjTimer pj
oldPos = _prjPos pj
newPos = oldPos +.+ _prjVel pj
@@ -155,13 +154,12 @@ decTimMvVel pj =
vel = _prjVel pj
pjid = _prjID pj
explodeShell :: Maybe (NewInt ItmInt) -> Int -> World -> World
explodeShell mitid pjid w =
explodeShell :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
explodeShell mitid pj w =
w
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU mitid 30]
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
& usePayload (_prjPayload thepj) (_prjPos thepj) (_prjVel thepj)
& usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj)
& stopSoundFrom (ShellSound pjid)
where
-- itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid-- _itemLocations (_cWorld w) IM.! itid
thepj = w ^?! cWorld . lWorld . projectiles . ix pjid
pjid = pj ^. prjID