Split Dodge.Base
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
module Dodge.Base.Arithmetic where
|
||||
import MaybeHelp
|
||||
|
||||
decreaseToZero :: Int -> Int
|
||||
decreaseToZero = max 0 . subtract 1
|
||||
|
||||
decreaseToNothing' :: (Num a, Ord a) => Maybe' a -> Maybe' a
|
||||
decreaseToNothing' ma = case ma of
|
||||
Just' x | x > 0 -> Just' (x - 1)
|
||||
_ -> Nothing'
|
||||
@@ -14,6 +14,8 @@ module Dodge.Base.Collide
|
||||
, hasLOSIndirect
|
||||
, wlIsOpaque
|
||||
, wlIsSeeThrough
|
||||
, wallsOnCirc
|
||||
, wallsOnLineHit
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Zone
|
||||
@@ -308,3 +310,16 @@ canSeeIndirect i j w = not
|
||||
-- n = normalizeV $ vNormal $ ipos -.- jpos
|
||||
-- ni = _crRad icr *.* n
|
||||
-- nj = _crRad jcr *.* n
|
||||
|
||||
wallsOnLineHit :: Point2 -> Point2 -> IM.IntMap Wall -> IM.IntMap (Point2, Wall)
|
||||
wallsOnLineHit p1 p2 = IM.mapMaybe f
|
||||
where
|
||||
f wl = uncurry (intersectSegSeg p1 p2) (_wlLine wl) <&> (, wl)
|
||||
|
||||
wallsOnCirc :: Point2 -> Float -> IM.IntMap Wall -> IM.IntMap Wall
|
||||
wallsOnCirc p r = IM.filter f
|
||||
where
|
||||
f wl = uncurry circOnSeg (_wlLine wl) p r
|
||||
|
||||
--wallNormal :: Wall -> Point2
|
||||
--wallNormal = normalizeV . vNormal . uncurry (-.-) . _wlLine
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
module Dodge.Base.Item
|
||||
(
|
||||
) where
|
||||
--import Dodge.Data
|
||||
--import Dodge.Base.You
|
||||
--import LensHelp
|
||||
--
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
|
||||
--selectedObject :: World -> Maybe (Either FloorItem Button)
|
||||
--selectedObject w = lookup (_crInvSel ycr) $ zip [n..] $ _closeObjects w
|
||||
-- where
|
||||
-- ycr = you w
|
||||
-- n = length $ _crInv ycr
|
||||
--
|
||||
--crItem :: World -> Int -> Item
|
||||
--crItem w cid = _crInv cr IM.! _crInvSel cr
|
||||
-- where
|
||||
-- cr = _creatures w IM.! cid
|
||||
--
|
||||
--yourItemRef
|
||||
-- :: Applicative f
|
||||
-- => World
|
||||
-- -> (Item -> f Item)
|
||||
-- -> World
|
||||
-- -> f World
|
||||
--yourItemRef w = creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w))
|
||||
@@ -29,3 +29,12 @@ plNew :: ALens' b (IM.IntMap a)
|
||||
-> b
|
||||
-> b
|
||||
plNew l li x = snd . plNewUpID l li x
|
||||
|
||||
-- | place an new object into an intmap using the new id
|
||||
plNewUsing :: ALens' b (IM.IntMap a)
|
||||
-> (Int -> a)
|
||||
-> b
|
||||
-> b
|
||||
plNewUsing l f x = x & l #%~ IM.insert i (f i)
|
||||
where
|
||||
i = IM.newKey $ x ^# l
|
||||
|
||||
Reference in New Issue
Block a user