Add newtype for item id int

This commit is contained in:
2024-09-28 23:34:32 +01:00
parent 241191ee1b
commit 7d72fa3c5d
14 changed files with 274 additions and 267 deletions
+7 -6
View File
@@ -3,6 +3,7 @@ module Dodge.Projectile.Update
( updateProjectile
) where
import NewInt
import Dodge.Payload
import Control.Lens
import Data.Maybe
@@ -42,7 +43,7 @@ upProjectile pu pj = case pu of
time = _prjTimer pj
act st et = time <= st && time >= et
shellCollisionEffect :: Maybe Int -> Projectile -> World -> World
shellCollisionEffect :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
shellCollisionEffect mscreenid = shellCollisionCheck
$ \pj -> explodeShell mscreenid (_prjID pj)
@@ -57,12 +58,12 @@ shellCollisionCheck f pj w
oldPos = _prjPos pj
newPos = oldPos +.+ _prjVel pj
destroyProjectile :: Maybe Int -> Int -> World -> World
destroyProjectile :: Maybe (NewInt ItmInt) -> Int -> World -> World
destroyProjectile mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
& removelink
where
removelink = fromMaybe id $ do
itid <- mitid
itid <- fmap _unNInt mitid
loc <- w ^? cWorld . lWorld . itemLocations . ix itid
itm <- w ^? pointerToItemLocation loc . itUse . atLinkedProjectile . _Just
guard $ itm == pjid
@@ -107,9 +108,9 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
spinFactor = 5 * (6 - fromIntegral i)
-- note this only allows YOU to remotely track projectiles
pjRemoteSetDirection :: Maybe Int -> Projectile -> World -> World
pjRemoteSetDirection :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
screenid <- mscreenid
screenid <- fmap _unNInt mscreenid
let newdir
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
== w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
@@ -133,7 +134,7 @@ decTimMvVel pj =
vel = _prjVel pj
pjid = _prjID pj
explodeShell :: Maybe Int -> Int -> World -> World
explodeShell :: Maybe (NewInt ItmInt) -> Int -> World -> World
explodeShell mitid pjid w =
w
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU mitid 30]