Add IntMapHelper, locate wall cutting bug
This commit is contained in:
+13
-14
@@ -9,7 +9,6 @@ module Dodge.LevelGen
|
||||
, makeSwitch
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
--import Dodge.Room.Data
|
||||
import Dodge.LevelGen.Block
|
||||
import Dodge.LevelGen.LineBlock
|
||||
@@ -21,6 +20,7 @@ import Dodge.LevelGen.Switch
|
||||
import Dodge.LevelGen.Data
|
||||
import Geometry
|
||||
import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
--import System.Random
|
||||
import Control.Monad.State
|
||||
@@ -29,7 +29,6 @@ import Control.Lens
|
||||
import Data.List.Extra
|
||||
--import Data.Function
|
||||
--import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.Set as S
|
||||
--import qualified Data.Map as M
|
||||
|
||||
@@ -128,9 +127,9 @@ addWalls qs wl wls = foldr (addPane wl) wls pairs
|
||||
pairs = zip (ps ++ [p]) (p:ps)
|
||||
|
||||
addPane :: Wall -> (Point2,Point2) -> IM.IntMap Wall -> IM.IntMap Wall
|
||||
addPane wl (p0,p1) wls = IM.insert (newKey wls) (wl
|
||||
addPane wl (p0,p1) wls = IM.insert (IM.newKey wls) (wl
|
||||
{ _wlLine = (p0,p1)
|
||||
, _wlID = newKey wls
|
||||
, _wlID = IM.newKey wls
|
||||
})
|
||||
wls
|
||||
|
||||
@@ -142,7 +141,7 @@ placeBt
|
||||
-> World
|
||||
placeBt bt p rot = over buttons addBT
|
||||
where
|
||||
addBT bts = IM.insert (newKey bts) (bt {_btPos = p, _btRot = rot, _btID = newKey bts}) bts
|
||||
addBT bts = IM.insert (IM.newKey bts) (bt {_btPos = p, _btRot = rot, _btID = IM.newKey bts}) bts
|
||||
{- Creates a floor item at a given point.
|
||||
Assigns an id correctly. -}
|
||||
placeFlIt
|
||||
@@ -152,11 +151,11 @@ placeFlIt
|
||||
-> World
|
||||
-> World
|
||||
placeFlIt itm p rot = floorItems %~
|
||||
\ fis -> IM.insert (newKey fis)
|
||||
\ fis -> IM.insert (IM.newKey fis)
|
||||
(FlIt
|
||||
{ _flItPos = p
|
||||
, _flItRot = rot
|
||||
, _flItID = newKey fis
|
||||
, _flItID = IM.newKey fis
|
||||
, _flIt = itm
|
||||
}
|
||||
) fis
|
||||
@@ -169,30 +168,30 @@ placePressPlate
|
||||
-> World
|
||||
placePressPlate pp p rot = over pressPlates addPP
|
||||
where
|
||||
addPP pps = IM.insert (newKey pps) (pp {_ppPos = p,_ppRot = rot}) pps
|
||||
addPP pps = IM.insert (IM.newKey pps) (pp {_ppPos = p,_ppRot = rot}) pps
|
||||
|
||||
placeUpdateCr :: Creature -> Point2 -> Float -> World -> (World, PSType)
|
||||
placeUpdateCr scr p rot w = (w & creatures %~ IM.insert cid cr, PutCrit cr)
|
||||
where
|
||||
cid = newKey (_creatures w)
|
||||
cid = IM.newKey (_creatures w)
|
||||
cr = scr {_crPos = p,_crOldPos = p,_crDir = rot,_crID = cid}
|
||||
|
||||
placeCr :: Creature -> Point2 -> Float -> World -> World
|
||||
placeCr crF p rot = over creatures addCr
|
||||
where
|
||||
addCr crs = IM.insert
|
||||
(newKey crs)
|
||||
(crF {_crPos = p,_crOldPos = p,_crDir = rot,_crID = newKey crs})
|
||||
(IM.newKey crs)
|
||||
(crF {_crPos = p,_crOldPos = p,_crDir = rot,_crID = IM.newKey crs})
|
||||
crs
|
||||
|
||||
placeLS :: LightSource -> Picture -> Point2 -> Float -> World -> World
|
||||
placeLS ls dec p rot w = over lightSources addLS $ over decorations addDec w
|
||||
where
|
||||
addLS lss = IM.insert
|
||||
(newKey lss)
|
||||
(ls {_lsPos = p,_lsDir = rot,_lsID = newKey lss})
|
||||
(IM.newKey lss)
|
||||
(ls {_lsPos = p,_lsDir = rot,_lsID = IM.newKey lss})
|
||||
lss
|
||||
addDec decs = IM.insert
|
||||
(newKey decs)
|
||||
(IM.newKey decs)
|
||||
(uncurry translate p $ rotate (negate rot) dec)
|
||||
decs
|
||||
|
||||
Reference in New Issue
Block a user