Move towards working implementation of attachment tree ammo
This commit is contained in:
+9
-3
@@ -3,6 +3,8 @@ module Dodge.Bullet (
|
||||
shootBullet,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Linear
|
||||
import Dodge.Item.Weapon.Bullet
|
||||
import System.Random
|
||||
@@ -56,9 +58,12 @@ updateBulVel bt = case _buTrajectory bt of
|
||||
where
|
||||
t = _buTimer bt
|
||||
|
||||
shootBullet :: [Item] -> Item -> Creature -> World -> World
|
||||
shootBullet ams it cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
|
||||
thebullet <- ams ^? ix 0 . itUse . amagParams . ampBullet
|
||||
shootBullet :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
shootBullet itm cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
|
||||
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
|
||||
leftitms <- itm ^? ldtLeft
|
||||
mag <- lookup (AmmoInLink atype) leftitms
|
||||
thebullet <- mag ^? ldtValue . itUse . amagParams . ampBullet
|
||||
return $ w & cWorld . lWorld . instantBullets
|
||||
.:~ ( thebullet
|
||||
& buPos .~ _crPos cr
|
||||
@@ -67,6 +72,7 @@ shootBullet ams it cr w = fromMaybe (error "cannot find bullet ammo when expecte
|
||||
& buDrag *~ _rifling (_heldParams $ _itUse it)
|
||||
)
|
||||
where
|
||||
it = itm ^. ldtValue
|
||||
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
muzvel = _muzVel $ _heldParams $ _itUse it
|
||||
|
||||
Reference in New Issue
Block a user