Add shrinkability and cursed items
This commit is contained in:
@@ -8,10 +8,8 @@ import Dodge.Data
|
||||
import Dodge.Path
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.Default.Wall
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import Color
|
||||
|
||||
import Control.Lens
|
||||
import Data.List
|
||||
@@ -19,16 +17,15 @@ import qualified Data.IntSet as IS
|
||||
|
||||
addBlock
|
||||
:: [Point2] -- ^ Block polygon
|
||||
-> Wall -- ^ Base Pane
|
||||
-> Int -- ^ First layer of health
|
||||
-> Color
|
||||
-> Opacity -- ^ Is the block see through?
|
||||
-> [Int] -- ^ Extra layers of health
|
||||
-> BlockMaterial
|
||||
-> World
|
||||
-> World
|
||||
addBlock (p:ps) hp col opacity hps bm w
|
||||
addBlock (p:ps) wl hp hps bm w
|
||||
| hp <= 0 && null hps = w
|
||||
| hp <= 0 = addBlock (p:ps) (head hps + hp) col opacity (tail hps) bm w
|
||||
| hp <= 0 = addBlock (p:ps) wl (head hps + hp) (tail hps) bm w
|
||||
| otherwise = w
|
||||
& wallsZone . znObjects %~ flip (IM.foldl' $ flip wallInZone) panes
|
||||
& walls %~ IM.union panes
|
||||
@@ -40,31 +37,28 @@ addBlock (p:ps) hp col opacity hps bm w
|
||||
i = IM.newKey $ _walls w
|
||||
is = [i.. i + length lns-1]
|
||||
panes = IM.fromList $ zipWith
|
||||
(\j (a,b) -> (,) j defaultWall
|
||||
(\j (a,b) -> (,) j wl
|
||||
{ _wlLine = (a,b)
|
||||
, _wlID = j
|
||||
, _wlColor = col
|
||||
, _wlOpacity = opacity
|
||||
, _wlStructure = BlockPart blid
|
||||
, _wlFireThrough = True
|
||||
}
|
||||
) is lns
|
||||
wallInZone wl
|
||||
| uncurry dist (_wlLine wl) <= 2*zoneSize
|
||||
= insertIMInZone x y wlid wl
|
||||
| otherwise = flip (foldl' $ flip (\(a,b) -> insertIMInZone a b wlid wl)) ips
|
||||
wallInZone wl'
|
||||
| uncurry dist (_wlLine wl') <= 2*zoneSize
|
||||
= insertIMInZone x y wlid wl'
|
||||
| otherwise = flip (foldl' $ flip (\(a,b) -> insertIMInZone a b wlid wl')) ips
|
||||
where
|
||||
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl)
|
||||
wlid = _wlID wl
|
||||
ips = map zoneOfPoint $ uncurry (divideLine (2*zoneSize)) (_wlLine wl)
|
||||
addBlock _ _ _ _ _ _ _ = error "Trying to add a block with incomplete polygon"
|
||||
addBlock _ _ _ _ _ _ = error "Trying to add a block with incomplete polygon"
|
||||
|
||||
placeBlock :: [Point2] -> Int -> Color -> Opacity -> [Int] -> BlockMaterial -> World -> (Int,World)
|
||||
placeBlock poly i c opac is bm w
|
||||
placeBlock :: [Point2] -> Int -> Wall -> [Int] -> BlockMaterial -> World -> (Int,World)
|
||||
placeBlock poly i wl is bm w
|
||||
= (0, foldr (uncurry removePathsCrossing) wWithBlock pairs)
|
||||
where
|
||||
pairs = loopPairs poly
|
||||
wWithBlock = addBlock poly i c opac is bm w
|
||||
wWithBlock = addBlock poly wl i is bm w
|
||||
|
||||
{- | Splits a line into many four cornered blocks. -}
|
||||
placeLineBlock
|
||||
|
||||
Reference in New Issue
Block a user