Working use of links as placement spots
This commit is contained in:
+6
-6
@@ -7,6 +7,7 @@ import Dodge.LevelGen.Data
|
||||
import Dodge.LevelGen.StaticWalls
|
||||
import Dodge.LevelGen.Pathing
|
||||
import Dodge.Placements.Spot
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.GameRoom
|
||||
@@ -52,21 +53,20 @@ generateLevelFromRoomList gr w
|
||||
where
|
||||
path = pairsToGraph dist pairPath
|
||||
pairPath = concatMap _rmPath rs
|
||||
plmnts = concatMap (\r -> map (_rmShift r ,) (assignPlacementSpots r)) rs
|
||||
plmnts = concat . snd $ mapAccumR assignPlacementSpots (_randGen w) rs
|
||||
rs = zipWith addTile zs . evalState gr $ _randGen w
|
||||
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
|
||||
|
||||
-- the idea is to allow use of link coordinates for placements
|
||||
-- though the implementation is clunky
|
||||
assignPlacementSpots :: Room -> [Placement]
|
||||
assignPlacementSpots rm = plmnts ++ plmnts'
|
||||
assignPlacementSpots :: StdGen -> Room -> (StdGen, [((Point2,Float),Placement)])
|
||||
assignPlacementSpots g rm = (g', map (_rmShift rm,) $ plmnts ++ plmnts')
|
||||
where
|
||||
(lnkplmnts, plmnts) = partition islnk (_rmPS rm)
|
||||
islnk Placement{_placementSpot=PSLnk{}} = True
|
||||
islnk _ = False
|
||||
(_,plmnts') = mapAccumR f (map (invShiftLinkBy lnkTo) $ _rmLinks rm) lnkplmnts
|
||||
(la,lb) = _rmShift rm
|
||||
lnkTo = (la,lb)
|
||||
(shuffledLnks,g') = runState (shuffle $ _rmLinks rm) g
|
||||
(_,plmnts') = mapAccumR f (map (invShiftLinkBy $ _rmShift rm) shuffledLnks) lnkplmnts
|
||||
f lnks plmnt =
|
||||
let (x:xs,ys) = partition (_psLinkTest $ _placementSpot plmnt) lnks
|
||||
thepair = _psLinkShift (_placementSpot plmnt) x
|
||||
|
||||
Reference in New Issue
Block a user