Continue removing LDTs
This commit is contained in:
@@ -18,25 +18,25 @@ import qualified IntMapHelp as IM
|
||||
useItem :: Int -> PressType -> World -> Maybe World
|
||||
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
useItemLoc cr itmloc pt w
|
||||
itmloc <- invIndents (_crInv cr) ^? ix invid . _2
|
||||
useItemLoc cr (itmloc) pt w
|
||||
|
||||
useItemLoc :: Creature -> LocationLDT ItemLink OItem -> PressType -> World -> Maybe World
|
||||
useItemLoc :: Creature -> LocationDT OItem -> PressType -> World -> Maybe World
|
||||
useItemLoc cr loc pt w
|
||||
| HeldPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
|
||||
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
|
||||
, Aiming{} <- cr ^. crStance . posture =
|
||||
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
|
||||
return $ gadgetEffect pt loc cr w
|
||||
| LaserWeaponSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
|
||||
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
|
||||
, Aiming{} <- cr ^. crStance . posture =
|
||||
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
|
||||
return $ gadgetEffect pt (loc) cr w
|
||||
| GadgetPlatformSF <- sf =
|
||||
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
|
||||
return $ gadgetEffect pt (loc) cr w
|
||||
| UnderBarrelPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
|
||||
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
|
||||
, Aiming{} <- cr ^. crStance . posture =
|
||||
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
|
||||
return $ gadgetEffect pt (loc) cr w
|
||||
| RemoteDetonatorSF <- sf
|
||||
, pt == InitialPress =
|
||||
return $ activateDetonator ldt w
|
||||
@@ -53,12 +53,12 @@ useItemLoc cr loc pt w
|
||||
, pt == InitialPress
|
||||
, Just invid' <- itm ^? itLocation . ilInvID =
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp loc
|
||||
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp' loc
|
||||
-- ie try location above
|
||||
where
|
||||
sf = loc ^. locLDT . ldtValue . _2
|
||||
ldt = loc ^. locLDT
|
||||
itm = ldt ^. ldtValue . _1
|
||||
sf = loc ^. locDT . dtValue . _2
|
||||
ldt = loc ^. locDT
|
||||
itm = ldt ^. dtValue . _1
|
||||
|
||||
--chooseUseLocation :: LocationLDT ItemLink OItem -> LocationLDT ItemLink OItem
|
||||
--chooseUseLocation loc
|
||||
@@ -78,9 +78,9 @@ useItemLoc cr loc pt w
|
||||
-- MapperSF -> True
|
||||
-- _ -> False
|
||||
|
||||
activateDetonator :: LDTree ItemLink OItem -> World -> World
|
||||
activateDetonator :: DTree OItem -> World -> World
|
||||
activateDetonator det = fromMaybe id $ do
|
||||
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
|
||||
pjid <- det ^? dtValue . _1 . itUse . uaParams . apProjectiles . ix 0
|
||||
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
|
||||
+28
-28
@@ -147,18 +147,18 @@ invRootItemEffs :: Creature -> World -> World
|
||||
invRootItemEffs cr =
|
||||
appEndo $
|
||||
foldMap
|
||||
(reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
|
||||
(invLDT' (_crInv cr))
|
||||
(reduceLocDT (Endo . invItemLocUpdate cr) . LocDT TopDT)
|
||||
(invDT' (_crInv cr))
|
||||
|
||||
invItemLocUpdate :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
invItemLocUpdate :: Creature -> LocationDT OItem -> World -> World
|
||||
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> trySynthBullet loc w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent (locLDTToLocDT loc) w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent (loc) w
|
||||
COPIER _ -> copierItemUpdate itm cr w
|
||||
HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w
|
||||
HELD MINIGUNX{} -> coolMinigun itm w
|
||||
HELD MACHINEPISTOL{} -> coolMachinePistol cr itm w
|
||||
HELD LASER | loc ^. locLDT . ldtValue . _2 == WeaponTargetingSF
|
||||
HELD LASER | loc ^. locDT . dtValue . _2 == WeaponTargetingSF
|
||||
, itm ^? itLocation . ilIsAttached == Just True -> shineTargetLaser cr loc w
|
||||
HELD TORCH
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> shineTorch cr loc w
|
||||
@@ -171,7 +171,7 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
haspulse =
|
||||
w ^? cWorld . lWorld . creatures . ix 0 . crType . avatarPulse . pulseProgress
|
||||
== Just 0
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
|
||||
coolMinigun :: Item -> World -> World
|
||||
coolMinigun itm
|
||||
@@ -219,9 +219,9 @@ copierItemUpdate itm cr w = fromMaybe w $ do
|
||||
v <- getItemValue itm' w cr
|
||||
return $ w & pointerToItem itm . itUse . uValue .~ v
|
||||
|
||||
doAnyEquipmentEffect :: LocationLDT ItemLink OItem -> Creature -> World -> World
|
||||
doAnyEquipmentEffect :: LocationDT OItem -> Creature -> World -> World
|
||||
doAnyEquipmentEffect loc cr = maybe id (equipBackgroundEffect loc cr)
|
||||
$ loc ^? locLDT . ldtValue . _1 . itLocation . ilEquipSite . _Just
|
||||
$ loc ^? locDT . dtValue . _1 . itLocation . ilEquipSite . _Just
|
||||
|
||||
tryUseParent :: LocationDT OItem -> World -> World
|
||||
tryUseParent loc w = fromMaybe w $ do
|
||||
@@ -229,13 +229,13 @@ tryUseParent loc w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ gadgetEffect InitialPress t cr w
|
||||
|
||||
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
|
||||
trySynthBullet :: LocationDT OItem -> World -> World
|
||||
trySynthBullet loc w = fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
x <- itm ^? itUse . uaParams . apInt
|
||||
if x < 100
|
||||
then do
|
||||
bat <- loc ^? locLDT . ldtLeft . ix 0 . _2 . ldtValue . _1
|
||||
bat <- loc ^? locDT . dtLeft . ix 0 . dtValue . _1
|
||||
j <- bat ^? itLocation . ilInvID
|
||||
y <- bat ^. itConsumables
|
||||
guard $ y > 0
|
||||
@@ -257,7 +257,7 @@ trySynthBullet loc w = fromMaybe w $ do
|
||||
. _Just
|
||||
-~ 1
|
||||
else do
|
||||
mag <- loc ^? locLdtContext . cldtParent . _1
|
||||
mag <- loc ^? locDtContext . cdtParent . _1
|
||||
j <- mag ^? itLocation . ilInvID
|
||||
y <- mag ^. itConsumables
|
||||
ymax <- maxAmmo mag
|
||||
@@ -280,24 +280,24 @@ trySynthBullet loc w = fromMaybe w $ do
|
||||
. _Just
|
||||
+~ 1
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
|
||||
drawARHUD :: LocationLDT ItemLink OItem -> World -> World
|
||||
drawARHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
itm <- con ^? cldtParent . _1
|
||||
drawARHUD :: LocationDT OItem -> World -> World
|
||||
drawARHUD (LocDT con _) w = fromMaybe w $ do
|
||||
itm <- con ^? cdtParent . _1
|
||||
return $
|
||||
w & cWorld . lWorld . flares
|
||||
<>~ fold
|
||||
(drawTargetingAR itm w <|> drawMapperAR itm w)
|
||||
|
||||
shineTargetLaser :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
shineTargetLaser :: Creature -> LocationDT OItem -> World -> World
|
||||
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
guard (crIsAiming cr)
|
||||
-- (_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
(_, mag) <- find (isammolink . (^. _2 . ldtValue . _2)) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
( mag) <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft)
|
||||
i <- mag ^. dtValue . _1 . itConsumables
|
||||
guard $ i >= x
|
||||
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||
maginvid <- mag ^? dtValue . _1 . itLocation . ilInvID
|
||||
return $
|
||||
w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
@@ -316,33 +316,33 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
|
||||
, _lpType = TargetingLaser (_itID itm)
|
||||
}
|
||||
where
|
||||
o = locOrient (locLDTToLocDT loc) cr
|
||||
itmtree = loc ^. locLDT
|
||||
o = locOrient (loc) cr
|
||||
itmtree = loc ^. locDT
|
||||
(p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
|
||||
x = 1
|
||||
isammolink AmmoMagSF{} = True
|
||||
isammolink _ = False
|
||||
pos = _crPos cr + xyV3 (rotate3 cdir p)
|
||||
cdir = _crDir cr
|
||||
itm = itmtree ^. ldtValue . _1
|
||||
itm = itmtree ^. dtValue . _1
|
||||
pointittarg = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itTargeting
|
||||
cid = _crID cr
|
||||
invid = _ilInvID $ _itLocation itm
|
||||
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
|
||||
|
||||
shineTorch :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
shineTorch :: Creature -> LocationDT OItem -> World -> World
|
||||
shineTorch cr loc = fromMaybe id $ do
|
||||
(_, mag) <- find (isammolink . (^. _2 . ldtValue . _2)) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
( mag) <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft)
|
||||
i <- mag ^. dtValue . _1 . itConsumables
|
||||
guard $ crIsAiming cr
|
||||
guard $ i >= x
|
||||
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||
invid <- mag ^? dtValue . _1 . itLocation . ilInvID
|
||||
return $
|
||||
(cWorld . lWorld . lights .:~ LSParam pos 250 0.7)
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x)
|
||||
where
|
||||
itmtree = loc ^. locLDT
|
||||
(p, q) = locOrient (locLDTToLocDT loc) cr
|
||||
itmtree = loc ^. locDT
|
||||
(p, q) = locOrient (loc) cr
|
||||
x = 10
|
||||
isammolink AmmoMagSF{} = True
|
||||
isammolink _ = False
|
||||
|
||||
@@ -24,7 +24,6 @@ module Dodge.Creature.Test (
|
||||
crSafeDistFromTarg,
|
||||
) where
|
||||
|
||||
import Dodge.DoubleTree
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Creature.Radius
|
||||
import Dodge.Data.Equipment.Misc
|
||||
@@ -97,8 +96,8 @@ crInAimStance as cr = crIsAiming cr && mitstance == Just as
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
--itm <- invRootTrees' (cr ^. crInv) ^? ix i
|
||||
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invRootTrees (cr ^. crInv) ^? ix i
|
||||
return $ aimStance $ ldtToDT itm
|
||||
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invIMDT (cr ^. crInv) ^? ix i
|
||||
return $ aimStance $ itm
|
||||
--cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
oneH :: Creature -> Bool
|
||||
|
||||
Reference in New Issue
Block a user