Use function on location to determine laser orientation
This commit is contained in:
@@ -3,6 +3,8 @@ module Dodge.Creature.State (
|
||||
doDamage,
|
||||
) where
|
||||
|
||||
import Data.Bifunctor
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Item.Orientation
|
||||
import Dodge.Item.UseDelay
|
||||
import Control.Applicative
|
||||
@@ -20,7 +22,7 @@ import Dodge.Creature.Test
|
||||
import Dodge.Damage
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.Damage.Type
|
||||
import Dodge.Data.DoubleTree
|
||||
--import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
import Dodge.DoubleTree
|
||||
import Dodge.Euse
|
||||
@@ -308,7 +310,8 @@ updateItemWithOrientation ::
|
||||
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
|
||||
case (ci ^. _1 . itType, ci ^. _2) of
|
||||
(HELD TORCH, _) -> shineTorch cr itmtree m w
|
||||
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m w
|
||||
--(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m w
|
||||
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser' cr loc w
|
||||
(TARGETING tt, _) -> updateItemTargeting tt cr itm w
|
||||
(ARHUD, _) -> drawARHUD loc w
|
||||
_ -> w
|
||||
@@ -324,13 +327,12 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
<>~ fold
|
||||
(drawTargetingAR itm w <|> drawMapperAR itm w)
|
||||
|
||||
shineTargetLaser ::
|
||||
shineTargetLaser' ::
|
||||
Creature ->
|
||||
LDTree ItemLink CItem ->
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
LocationLDT ItemLink CItem ->
|
||||
World ->
|
||||
World
|
||||
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
shineTargetLaser' cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
guard (crIsAiming cr)
|
||||
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
@@ -354,6 +356,8 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
|
||||
, _lpType = TargetingLaser (_itID itm)
|
||||
}
|
||||
where
|
||||
itmtree = loc ^. locLDT
|
||||
(p,q) = orientLocation $ fmap fst loc
|
||||
x = 1
|
||||
isammolink AmmoInLink{} = True
|
||||
isammolink _ = False
|
||||
@@ -365,6 +369,47 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
|
||||
invid = _ilInvID $ _itLocation itm
|
||||
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
|
||||
|
||||
--shineTargetLaser ::
|
||||
-- Creature ->
|
||||
-- LDTree ItemLink CItem ->
|
||||
-- (Point3, Q.Quaternion Float) ->
|
||||
-- World ->
|
||||
-- World
|
||||
--shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
-- guard (crIsAiming cr)
|
||||
-- (_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
-- i <- mag ^. ldtValue . _1 . itConsumables
|
||||
-- guard $ i >= x
|
||||
-- maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||
-- return $
|
||||
-- w
|
||||
-- & worldEventFlags . at InventoryChange ?~ ()
|
||||
-- & cWorld . lWorld . creatures . ix (_crID cr)
|
||||
-- . crInv
|
||||
-- . ix maginvid
|
||||
-- . itConsumables
|
||||
-- . _Just
|
||||
-- -~ x
|
||||
-- & cWorld . lWorld . lasers
|
||||
-- .:~ Laser
|
||||
-- { _lpPhaseV = 1
|
||||
-- , _lpDir = _crDir cr + argV (Q.qToV2 q)
|
||||
-- , _lpPos = pos
|
||||
-- , _lpColor = col
|
||||
-- , _lpType = TargetingLaser (_itID itm)
|
||||
-- }
|
||||
-- where
|
||||
-- x = 1
|
||||
-- isammolink AmmoInLink{} = True
|
||||
-- isammolink _ = False
|
||||
-- pos = _crPos cr + xyV3 (rotate3 cdir (p + V3 5 0 0))
|
||||
-- cdir = _crDir cr
|
||||
-- itm = itmtree ^. ldtValue . _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 ->
|
||||
LDTree ItemLink CItem ->
|
||||
|
||||
Reference in New Issue
Block a user