Make torch use battery power
This commit is contained in:
+23
-14
@@ -4,7 +4,6 @@ module Dodge.Creature.State (
|
||||
) where
|
||||
|
||||
import Dodge.LightSource
|
||||
import Dodge.WorldEvent.Flash
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
@@ -174,7 +173,7 @@ updateRootItem cr = fromMaybe id $ do
|
||||
|
||||
updateRootItem' :: LabelDoubleTree ItemLink Item -> Creature -> World -> World
|
||||
updateRootItem' itmtree cr =
|
||||
ldtPropagateFold
|
||||
ldtPropagateFoldTree
|
||||
chainLinkOrientation
|
||||
chainLinkOrientation
|
||||
(updateItemWithOrientation cr)
|
||||
@@ -193,21 +192,31 @@ chainLinkOrientation mo par (ILink lt f) child = (p + Q.rotate q p1, q * q1)
|
||||
(p, q) = mo
|
||||
(p1, q1) = f par lt child
|
||||
|
||||
updateItemWithOrientation :: Creature -> (Point3, Q.Quaternion Float) -> Item -> World -> World
|
||||
updateItemWithOrientation cr m itm = case _itType itm of
|
||||
HELD TORCH -> testtorch cr itm m
|
||||
updateItemWithOrientation :: Creature -> (Point3, Q.Quaternion Float)
|
||||
-> LabelDoubleTree ItemLink Item
|
||||
-> World -> World
|
||||
updateItemWithOrientation cr m itmtree = case _itType itm of
|
||||
HELD TORCH -> shineTorch cr itmtree m
|
||||
_ -> id
|
||||
|
||||
testtorch :: Creature -> Item -> (Point3, Q.Quaternion Float) -> World -> World
|
||||
testtorch cr itm (p,q) = --createTorchLightOffset cr itm pos' .
|
||||
muzFlareAt yellow pos'' d
|
||||
.( cWorld . lWorld . tempLightSources .:~
|
||||
tlsTimeRadColPos 1 250 0.7 pos''
|
||||
)
|
||||
where
|
||||
--pos = (_crPos cr `v2z` 0 + rotate3 cdir p)
|
||||
itm = itmtree ^. ldtValue
|
||||
|
||||
|
||||
|
||||
shineTorch :: Creature -> LabelDoubleTree ItemLink Item -> (Point3, Q.Quaternion Float) -> World -> World
|
||||
shineTorch cr itmtree (p,q) = fromMaybe id $ do
|
||||
(_,mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
||||
i <- mag ^? ldtValue . itUse . amagLoadStatus . iaLoaded
|
||||
guard $ i >= x
|
||||
invid <- mag ^? ldtValue . itLocation . ilInvID
|
||||
return $
|
||||
(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
|
||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . amagLoadStatus . iaLoaded -~ x)
|
||||
where
|
||||
x = 10
|
||||
isammolink AmmoInLink{} = True
|
||||
isammolink _ = False
|
||||
pos = (_crPos cr `v2z` 0 + rotate3 cdir p)
|
||||
--pos'' = pos
|
||||
pos'' = pos + rotate3 d (V3 8 0 1.5)
|
||||
cdir = _crDir cr
|
||||
a = argV (Q.qToV2 q)
|
||||
|
||||
Reference in New Issue
Block a user