Move towards introducing pipes, generalise blocks

This commit is contained in:
2022-06-16 02:18:22 +01:00
parent f404f32241
commit a7201b8fb6
13 changed files with 154 additions and 65 deletions
+5
View File
@@ -0,0 +1,5 @@
module Dodge.Placement.Instance.Pipe where
import Shape
verticalPipe :: Float -> Shape
verticalPipe = flip upperPrismPoly $ polyCirc 4 5
+9 -4
View File
@@ -6,6 +6,7 @@ module Dodge.Placement.PlaceSpot.Block
where
import Dodge.Data
import Dodge.Path
import Dodge.Block.Debris
--import Dodge.LevelGen.LevelStructure
import Dodge.Base
import Dodge.Zone
@@ -31,7 +32,9 @@ addBlock (p:ps) wl hp hps bm w
& wallsZone . znObjects %~ flip (IM.foldl' $ flip wallInZone) panes
& walls %~ IM.union panes
& blocks %~ IM.insert blid Block
{_blID = blid,_blWallIDs = IS.fromList is, _blHPs = hp:hps, _blShadows=[], _blMaterial = bm}
{_blID = blid,_blWallIDs = IS.fromList is, _blHPs = hp:hps, _blShadows=[], _blMaterial = bm
, _blFootprint = p:ps, _blPos = centroid (p:ps), _blDraw = const mempty
, _blDeath = makeBlockDebris bm}
where
blid = IM.newKey $ _blocks w
lns = zip (p:ps) (ps ++ [p])
@@ -85,10 +88,12 @@ placeLineBlock basePane bm blockWidth depth a b gw = ( 0
linesAt p = loopPairs $ cornersAt p
wlid = IM.newKey $ _walls gw
blid = IM.newKey $ _blocks gw
insertBlock i = over blocks $ IM.insert (i+blid) Block
insertBlock (i,p) = over blocks $ IM.insert (i+blid) Block
{ _blID = i + blid, _blWallIDs = IS.fromList $ ksAtI i
, _blHPs = [5,5], _blShadows = shadowsAt i, _blMaterial = bm}
insertBlocks = flip (foldr insertBlock) is
, _blHPs = [5,5], _blShadows = shadowsAt i, _blMaterial = bm
, _blFootprint = cornersAt p -- TODO check winding (clockwise, anticlockwise)
, _blPos = p, _blDraw = const mempty , _blDeath = const id}
insertBlocks = flip (foldr insertBlock) $ zip is blockCenPs
ksAtI i = map ( + (wlid + i*4) ) [0,1,2,3]
visibilityAt i
| i == 0 = [False,True,True ,True]