Move nozzle walk into item params, cleanup
This commit is contained in:
@@ -12,9 +12,7 @@ import Control.Lens
|
|||||||
--import Dodge.Data.Item.Use.Consumption.Ammo
|
--import Dodge.Data.Item.Use.Consumption.Ammo
|
||||||
|
|
||||||
data CumulativeMuzzleEffect = CME
|
data CumulativeMuzzleEffect = CME
|
||||||
{ _cmeRecoil :: Float
|
{ _cmeSound :: Bool
|
||||||
, _cmeTorque :: Float
|
|
||||||
, _cmeSound :: Bool
|
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show, Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
|
|
||||||
|
|||||||
+7
-14
@@ -138,7 +138,7 @@ heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -
|
|||||||
heldEffectMuzzles t cr w =
|
heldEffectMuzzles t cr w =
|
||||||
doHeldUseEffect t cr .
|
doHeldUseEffect t cr .
|
||||||
uncurry (applyCME (_ldtValue t) cr) .
|
uncurry (applyCME (_ldtValue t) cr) .
|
||||||
foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
|
foldl' (useLoadedAmmo t cr) (CME False, w) $ loadedmuzzles
|
||||||
where
|
where
|
||||||
-- & doWeaponRepetitions upitm cr
|
-- & doWeaponRepetitions upitm cr
|
||||||
|
|
||||||
@@ -558,10 +558,10 @@ useLoadedAmmo ::
|
|||||||
LabelDoubleTree ComposeLinkType Item ->
|
LabelDoubleTree ComposeLinkType Item ->
|
||||||
Creature ->
|
Creature ->
|
||||||
(CumulativeMuzzleEffect, World) ->
|
(CumulativeMuzzleEffect, World) ->
|
||||||
(Int, Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item)) ->
|
Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item) ->
|
||||||
(CumulativeMuzzleEffect, World)
|
(CumulativeMuzzleEffect, World)
|
||||||
useLoadedAmmo _ _ (cme, w) (_, Nothing) = (cme, w)
|
useLoadedAmmo _ _ (cme, w) Nothing = (cme, w)
|
||||||
useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cmeSound .~ True) $
|
useLoadedAmmo itmtree cr (cme, w) (Just (mz, x, magtree)) = (,) (cme & cmeSound .~ True) $
|
||||||
removeAmmoFromMag x mid cr . makeMuzzleFlare mz itmtree cr $ case _mzEffect mz of
|
removeAmmoFromMag x mid cr . makeMuzzleFlare mz itmtree cr $ case _mzEffect mz of
|
||||||
MuzzleShootBullet -> shootBullet itmtree cr (mz, x, magtree) w
|
MuzzleShootBullet -> shootBullet itmtree cr (mz, x, magtree) w
|
||||||
MuzzleLaser -> creatureShootLaser itmtree cr mz w
|
MuzzleLaser -> creatureShootLaser itmtree cr mz w
|
||||||
@@ -576,7 +576,7 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
|
|||||||
mz
|
mz
|
||||||
cr
|
cr
|
||||||
w
|
w
|
||||||
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
|
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mz itm cr w
|
||||||
MuzzleShatter -> shootShatter itm cr w
|
MuzzleShatter -> shootShatter itm cr w
|
||||||
MuzzleDetector ->
|
MuzzleDetector ->
|
||||||
itemDetectorEffect
|
itemDetectorEffect
|
||||||
@@ -615,20 +615,14 @@ itemDetectorEffect itm mitid armitid cr w = fromMaybe w $ do
|
|||||||
f CREATUREDETECTOR = ObCreature
|
f CREATUREDETECTOR = ObCreature
|
||||||
f WALLDETECTOR = ObWall
|
f WALLDETECTOR = ObWall
|
||||||
|
|
||||||
walkNozzle :: Int -> Muzzle -> Item -> Creature -> World -> World
|
walkNozzle :: Muzzle -> Item -> Creature -> World -> World
|
||||||
walkNozzle mzid mz itm cr w = fromMaybe w $ do
|
walkNozzle mz itm cr w = fromMaybe w $ do
|
||||||
invid <- itm ^? itLocation . ilInvID
|
invid <- itm ^? itLocation . ilInvID
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv
|
& cWorld . lWorld . creatures . ix (_crID cr) . crInv
|
||||||
. ix invid
|
. ix invid
|
||||||
. itParams . nzAngle %~ f
|
. itParams . nzAngle %~ f
|
||||||
-- . itUse
|
|
||||||
-- . heldMuzzles
|
|
||||||
-- . ix mzid
|
|
||||||
-- . mzEffect
|
|
||||||
-- . nzCurrentWalkAngle
|
|
||||||
-- .~ wa
|
|
||||||
& randGen .~ g
|
& randGen .~ g
|
||||||
where
|
where
|
||||||
nz = _mzEffect mz
|
nz = _mzEffect mz
|
||||||
@@ -636,7 +630,6 @@ walkNozzle mzid mz itm cr w = fromMaybe w $ do
|
|||||||
aspeed = _nzWalkSpeed nz
|
aspeed = _nzWalkSpeed nz
|
||||||
maxa = _nzMaxWalkAngle nz
|
maxa = _nzMaxWalkAngle nz
|
||||||
f x = min maxa $ max (negate maxa) (x + walkamount)
|
f x = min maxa $ max (negate maxa) (x + walkamount)
|
||||||
-- wa = min maxa $ max (negate maxa) (_nzCurrentWalkAngle nz + walkamount)
|
|
||||||
|
|
||||||
shootTractorBeam :: Creature -> World -> World
|
shootTractorBeam :: Creature -> World -> World
|
||||||
shootTractorBeam cr w =
|
shootTractorBeam cr w =
|
||||||
|
|||||||
Reference in New Issue
Block a user