Allow for yet more complex placement positioning
This commit is contained in:
+20
-11
@@ -2,6 +2,7 @@ module Dodge.PlacementSpot where
|
|||||||
import Dodge.LevelGen.Data
|
import Dodge.LevelGen.Data
|
||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
import Data.Bifunctor
|
import Data.Bifunctor
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
import System.Random
|
import System.Random
|
||||||
@@ -9,21 +10,29 @@ import System.Random
|
|||||||
setDirPS :: Float -> PlacementSpot -> PlacementSpot
|
setDirPS :: Float -> PlacementSpot -> PlacementSpot
|
||||||
setDirPS a ps = case ps of
|
setDirPS a ps = case ps of
|
||||||
PS p _ -> PS p a
|
PS p _ -> PS p a
|
||||||
PSPos f re fb -> undefined
|
PSPos f re fb -> PSPos (\rp r -> fmap (first (setDirPS a)) (f rp r)) re fb
|
||||||
_ -> error "TODO write this in"
|
PSRoomRand i f -> PSRoomRand i (fmap (setDirPS a) f)
|
||||||
|
|
||||||
randDirPS :: RandomGen g => PlacementSpot -> State g PlacementSpot
|
randDirPS :: RandomGen g => PlacementSpot -> State g PlacementSpot
|
||||||
randDirPS (PSPos f ef fb) = do
|
randDirPS ps = do
|
||||||
a <- state $ randomR (0,pi*2)
|
a <- state $ randomR (0,pi*2)
|
||||||
return $ PSPos (g a) ef fb
|
return $ setDirPS a ps
|
||||||
where
|
|
||||||
g a rp r = fmap (first (setDirPS a)) $ f rp r
|
|
||||||
|
|
||||||
--unusedSpotAwayFromInLinkRD :: RandomGen g => Float -> State g PlacementSpot
|
unusedSpotAwayFromInLink :: Float -> PlacementSpot
|
||||||
--unusedSpotAwayFromInLinkRD x = do
|
unusedSpotAwayFromInLink x = PSPos f (const id) Nothing
|
||||||
-- a <- state $ randomR (0.2*pi)
|
where
|
||||||
-- return PSPos (f a) (const id) Nothing
|
f rp r = case rp of
|
||||||
-- where
|
UnusedSpot p a | all ( (>x) . dist p ) inlinkposs -> Just (PS p a,UsedSpot p a)
|
||||||
|
_ -> Nothing
|
||||||
|
where
|
||||||
|
inlinkposs = usedRoomInLinkPoss r
|
||||||
|
|
||||||
|
usedRoomInLinkPoss :: Room -> [Point2]
|
||||||
|
usedRoomInLinkPoss r = mapMaybe f $ _rmPos r
|
||||||
|
where
|
||||||
|
f rp = case rp of
|
||||||
|
UsedInLink {} -> Just $ _rpPos rp
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
-- TODO rename to any unused link facing out
|
-- TODO rename to any unused link facing out
|
||||||
anyLnkOutPS :: PlacementSpot
|
anyLnkOutPS :: PlacementSpot
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Room.Room where
|
module Dodge.Room.Room where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
|
import Dodge.PlacementSpot
|
||||||
import Dodge.RoomLink
|
import Dodge.RoomLink
|
||||||
import Dodge.Default.Room
|
import Dodge.Default.Room
|
||||||
import Dodge.Item.Weapon.BulletGuns
|
import Dodge.Item.Weapon.BulletGuns
|
||||||
@@ -316,8 +317,12 @@ weaponBetweenPillars = do
|
|||||||
d p = argV $ V2 120 120 -.- p
|
d p = argV $ V2 120 120 -.- p
|
||||||
plmnts =
|
plmnts =
|
||||||
[sPS wpPos 0 $ RandPS randFirstWeapon
|
[sPS wpPos 0 $ RandPS randFirstWeapon
|
||||||
,sPS crPos1 (d crPos1) randC1
|
, sps (unusedSpotAwayFromInLink 150) randC1
|
||||||
,sPS crPos2 (d crPos2) 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
|
||||||
|
|||||||
Reference in New Issue
Block a user