Move towards unifying (your) creature manipulation with selection
This commit is contained in:
+16
-15
@@ -484,12 +484,12 @@ applySoundCME itm cr = fromMaybe id $ do
|
||||
cid = _crID cr
|
||||
|
||||
applyRecoil :: LocationDT OItem -> Creature -> World -> World
|
||||
applyRecoil loc cr =
|
||||
applyRecoil loc cr w = w &
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos . _xy
|
||||
+~ rotateV (_crDir cr + Q.qToAng q) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0)
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
(_, q) = locOrient loc cr
|
||||
(_, q) = locOrient w loc cr
|
||||
|
||||
recoilAmount :: Item -> Float
|
||||
recoilAmount itm
|
||||
@@ -777,29 +777,29 @@ useLoadedAmmo loc cr mz m w =
|
||||
MuzzleScroller -> useTimeScrollGun itm cr w
|
||||
where
|
||||
o = CrWeaponO $ cr ^. crID
|
||||
pq = muzzlePos loc cr mz
|
||||
(pq', g) = muzzleRandPos loc cr mz `runState` (w ^. randGen)
|
||||
pq = muzzlePos w loc cr mz
|
||||
(pq', g) = muzzleRandPos w loc cr mz `runState` (w ^. randGen)
|
||||
itmtree = loc ^. locDT
|
||||
mitid = magtree ^. dtValue . _1 . itID
|
||||
itm = itmtree ^. dtValue . _1
|
||||
(x, magtree) = fromJust m
|
||||
|
||||
muzzlePos :: LocationDT OItem -> Creature -> Muzzle -> Point3Q
|
||||
muzzlePos m cr muz = (p1, q1) `Q.comp` pq `Q.comp` (p3, q3)
|
||||
muzzlePos :: World -> LocationDT OItem -> Creature -> Muzzle -> Point3Q
|
||||
muzzlePos w m cr muz = (p1, q1) `Q.comp` pq `Q.comp` (p3, q3)
|
||||
where
|
||||
pq = locOrient m cr
|
||||
pq = locOrient w m cr
|
||||
p1 = cr ^. crPos
|
||||
q1 = Q.qz $ cr ^. crDir
|
||||
p3 = addZ 0 $ muz ^. mzPos
|
||||
q3 = Q.qz $ muz ^. mzRot
|
||||
|
||||
muzzleRandPos :: LocationDT OItem -> Creature -> Muzzle -> State StdGen Point3Q
|
||||
muzzleRandPos m cr muz = do
|
||||
muzzleRandPos :: World -> LocationDT OItem -> Creature -> Muzzle -> State StdGen Point3Q
|
||||
muzzleRandPos w m cr muz = do
|
||||
a <- state $ randomR (- inacc, inacc)
|
||||
y <- case muz ^. mzRandomOffset of
|
||||
0 -> return 0
|
||||
i -> state $ randomR (- i, i)
|
||||
return $ muzzlePos m cr muz `Q.comp` (V3 0 y 0, Q.qz a)
|
||||
return $ muzzlePos w m cr muz `Q.comp` (V3 0 y 0, Q.qz a)
|
||||
where
|
||||
inacc = _mzInaccuracy muz
|
||||
|
||||
@@ -1004,7 +1004,7 @@ shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
|
||||
shootBullet :: Bullet -> LocationDT OItem -> Creature -> Muzzle -> World -> World
|
||||
shootBullet bu loc cr mz w = makeBullet bu itm pq . (randGen .~ g) $ w
|
||||
where
|
||||
(pq, g) = muzzleRandPos loc cr mz `runState` (w ^. randGen)
|
||||
(pq, g) = muzzleRandPos w loc cr mz `runState` (w ^. randGen)
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
|
||||
makeBullet :: Bullet -> Item -> Point3Q -> World -> World
|
||||
@@ -1384,10 +1384,10 @@ dropInventoryPath ::
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
dropInventoryPath i ip loc cr = fromMaybe id $ do
|
||||
dropInventoryPath i ip loc cr w = fromMaybe w $ do
|
||||
invid <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
|
||||
j <- getInventoryPath i ip invid cr
|
||||
return $ dropItem cr j
|
||||
j <- getInventoryPath w i ip invid cr
|
||||
return $ dropItem cr j w
|
||||
|
||||
--dropInventoryPath i ip loc cr w = case ip of
|
||||
-- ABSOLUTE -> fromMaybe w $ do
|
||||
@@ -1421,7 +1421,8 @@ useInventoryPath pt i ip loc cr w = case ip of
|
||||
guard $ i `IM.member` (cr ^. crInv . unNIntMap)
|
||||
return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem i pt)
|
||||
RELCURS -> fromMaybe w $ do
|
||||
j <- cr ^? crManipulation . manObject . imSelectedItem . unNInt
|
||||
j <- w ^? hud . manObject . imSelectedItem . unNInt
|
||||
--revise1 j <- cr ^? crManipulation . manObject . imSelectedItem . unNInt
|
||||
guard $ (i + j) `IM.member` (cr ^. crInv . unNIntMap)
|
||||
return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem (i + j) pt)
|
||||
RELITEM -> fromMaybe w $ do
|
||||
|
||||
Reference in New Issue
Block a user