Improve starting weapon rooms
This commit is contained in:
@@ -35,6 +35,7 @@ data PSType = PutCrit {_unPutCrit :: Creature}
|
|||||||
| PutNothing
|
| PutNothing
|
||||||
| PutID { _putID :: Int}
|
| PutID { _putID :: Int}
|
||||||
-- maybe there is a monadic implementation of this?
|
-- maybe there is a monadic implementation of this?
|
||||||
|
-- add room effect for any placement spot?
|
||||||
data PlacementSpot
|
data PlacementSpot
|
||||||
= PS { _psPos :: Point2 , _psRot :: Float }
|
= PS { _psPos :: Point2 , _psRot :: Float }
|
||||||
| PSPos
|
| PSPos
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ module Dodge.Room.Link
|
|||||||
, changeLinkFrom
|
, changeLinkFrom
|
||||||
, randomiseOutLinks
|
, randomiseOutLinks
|
||||||
, chooseOneInLink
|
, chooseOneInLink
|
||||||
|
, restrictRMInLinksPD
|
||||||
) where
|
) where
|
||||||
import Dodge.Placement.PlaceSpot
|
import Dodge.Placement.PlaceSpot
|
||||||
import Dodge.LevelGen.Data
|
import Dodge.LevelGen.Data
|
||||||
@@ -35,6 +36,9 @@ import qualified Data.Set as S
|
|||||||
chooseOneInLink :: RandomGen g => Room -> State g Room
|
chooseOneInLink :: RandomGen g => Room -> State g Room
|
||||||
chooseOneInLink r = restrictToFstInLink <$> shuffleLinks r
|
chooseOneInLink r = restrictToFstInLink <$> shuffleLinks r
|
||||||
|
|
||||||
|
restrictRMInLinksPD :: ((Point2,Float) -> Bool) -> Room -> Room
|
||||||
|
restrictRMInLinksPD f = rmLinks %~ restrictLinkType InLink f
|
||||||
|
|
||||||
restrictToFstInLink :: Room -> Room
|
restrictToFstInLink :: Room -> Room
|
||||||
restrictToFstInLink = rmLinks %~ f
|
restrictToFstInLink = rmLinks %~ f
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ roomRect x y xn yn = defaultRoom
|
|||||||
lnks = m North nlnks ++ m East elnks ++ m West wlnks ++ m South slnks
|
lnks = m North nlnks ++ m East elnks ++ m West wlnks ++ m South slnks
|
||||||
m edge = map (lnkBothAnd (OnEdge edge))
|
m edge = map (lnkBothAnd (OnEdge edge))
|
||||||
pth = linksAndPath' lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
|
pth = linksAndPath' lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
|
||||||
posps = map (+.+ V2 20 20) $ gridPoints xd xn yd yn
|
posps = map (+.+ V2 20 20) $ gridPoints xd (xn+1) yd (yn+1)
|
||||||
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
|
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
|
||||||
-- it is not clear to me that this works for very small rooms (but it does seem
|
-- it is not clear to me that this works for very small rooms (but it does seem
|
||||||
-- to do so)
|
-- to do so)
|
||||||
|
|||||||
+10
-20
@@ -255,7 +255,6 @@ randFirstWeapon = do
|
|||||||
++ replicate 2 autoGun
|
++ replicate 2 autoGun
|
||||||
++ [launcher]
|
++ [launcher]
|
||||||
|
|
||||||
|
|
||||||
weaponEmptyRoom :: RandomGen g => State g (SubCompTree Room)
|
weaponEmptyRoom :: RandomGen g => State g (SubCompTree Room)
|
||||||
weaponEmptyRoom = do
|
weaponEmptyRoom = do
|
||||||
w <- state $ randomR (220,300)
|
w <- state $ randomR (220,300)
|
||||||
@@ -267,10 +266,9 @@ weaponEmptyRoom = do
|
|||||||
--,sPS (V2 (w/2) (h/2)) 0 putLamp
|
--,sPS (V2 (w/2) (h/2)) 0 putLamp
|
||||||
,mntLightLnkCond unusedLnkToPS
|
,mntLightLnkCond unusedLnkToPS
|
||||||
]
|
]
|
||||||
treeFromTrunk [PassDown corridor]
|
f (V2 x y,a) = (a == pi && x > 25 && x < w - 25) || (a /= 0 && y > w - 30)
|
||||||
<$> ((fmap singleUseAll . randomiseOutLinks) =<<
|
rm <- shuffleLinks $ restrictRMInLinksPD f (roomRect w h 2 2 & rmPmnts .~ plmnts)
|
||||||
changeLinkTo ((\p -> dist p (V2 (w/2) 0) < 10) . fst) (set rmPmnts plmnts $ roomRect w h 2 2)
|
return $ treeFromTrunk [PassDown corridor] (singleUseAll rm )
|
||||||
)
|
|
||||||
|
|
||||||
weaponUnderCrits :: RandomGen g => State g (SubCompTree Room)
|
weaponUnderCrits :: RandomGen g => State g (SubCompTree Room)
|
||||||
weaponUnderCrits = do
|
weaponUnderCrits = do
|
||||||
@@ -312,18 +310,10 @@ weaponBehindPillar = do
|
|||||||
weaponBetweenPillars :: RandomGen g => State g (SubCompTree Room)
|
weaponBetweenPillars :: RandomGen g => State g (SubCompTree Room)
|
||||||
weaponBetweenPillars = do
|
weaponBetweenPillars = do
|
||||||
wpPos <- takeOne [V2 x y | x <- [20,120,220], y <- [20,120,220]]
|
wpPos <- takeOne [V2 x y | x <- [20,120,220], y <- [20,120,220]]
|
||||||
(ps,_) <- takeNMore 2 ([], [V2 x y | x <- [20,220], y <- [20,120,220]])
|
critPlacementSpots <- replicateM 2 $ randDirPS $ unusedSpotAwayFromInLink 100
|
||||||
let crPos1:crPos2:_ = ps
|
let plmnts =
|
||||||
d p = argV $ V2 120 120 -.- p
|
sPS wpPos 0 (RandPS randFirstWeapon) :
|
||||||
plmnts =
|
map (\ps -> sps ps randC1) critPlacementSpots
|
||||||
[sPS wpPos 0 $ RandPS randFirstWeapon
|
|
||||||
, sps (unusedSpotAwayFromInLink 150) randC1
|
|
||||||
, sps (unusedSpotAwayFromInLink 150) randC1
|
|
||||||
, sps (unusedSpotAwayFromInLink 150) randC1
|
|
||||||
, sps (unusedSpotAwayFromInLink 150) randC1
|
|
||||||
--,sPS crPos1 (d crPos1) randC1
|
|
||||||
--,sPS crPos2 (d crPos2) randC1
|
|
||||||
]
|
|
||||||
theRoom = roomPillars & rmPmnts %~ (++ plmnts)
|
theRoom = roomPillars & rmPmnts %~ (++ plmnts)
|
||||||
(fmap singleUseAll . randomiseOutLinks) =<< filterLinks f theRoom
|
(fmap singleUseAll . randomiseOutLinks) =<< filterLinks f theRoom
|
||||||
where
|
where
|
||||||
@@ -362,9 +352,9 @@ deadEndRoom = defaultRoom
|
|||||||
weaponRoom :: RandomGen g => State g (SubCompTree Room)
|
weaponRoom :: RandomGen g => State g (SubCompTree Room)
|
||||||
weaponRoom = join $ takeOne
|
weaponRoom = join $ takeOne
|
||||||
[-- weaponEmptyRoom
|
[-- weaponEmptyRoom
|
||||||
--, weaponUnderCrits
|
weaponUnderCrits
|
||||||
--, weaponBehindPillar
|
-- weaponBehindPillar
|
||||||
weaponBetweenPillars
|
-- weaponBetweenPillars
|
||||||
--, weaponLongCorridor
|
--, weaponLongCorridor
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user