Fix incorrect creation of unused links pos

This commit is contained in:
2022-03-08 09:48:45 +00:00
parent 59e6f433ff
commit 8179a2aa4f
8 changed files with 35 additions and 35 deletions
+5 -3
View File
@@ -20,6 +20,8 @@ branchRectWith t = do
x <- state $ randomR (100,200)
y <- state $ randomR (100,200)
b <- t
root <- randomiseOutLinks $ roomRectAutoLinks x y
return $ Node (PassDown root) [Node (UseAll door) [], changeToPassDown <$>
treeFromTrunk [PassDown door] b]
root <- shuffleLinks $ roomRectAutoLinks x y
return $ Node (PassDown root)
[ Node (UseAll door) []
, changeToPassDown <$> treeFromTrunk [PassDown door] b
]
+5 -14
View File
@@ -14,7 +14,6 @@ module Dodge.Room.Link
, randomiseAllLinks
, shuffleLinks
, filterLinks
, randomiseOutLinks
, chooseOneInLink
, restrictRMInLinksPD
) where
@@ -47,13 +46,6 @@ restrictToFstInLink = rmLinks %~ f
| otherwise = rl : f xs
f [] = []
{- Shuffle the initial links of a room randomly. -}
randomiseOutLinks :: RandomGen g => Room -> State g Room
randomiseOutLinks r = do
let (outs,xs) = partition (S.member OutLink . _rlType) $ _rmLinks r
newLinks <- shuffle outs
return $ r {_rmLinks = newLinks ++ xs }
sortOutLinksOn :: Ord b => ((Point2,Float) -> b) -> Room -> Room
sortOutLinksOn f = overLnkType OutLink $ sortOn (f . lnkPosDir)
@@ -95,8 +87,8 @@ shiftRoomBy shift r = r
& rmShift %~ shiftPosDirBy shift
& rmFloor . tiles %~ map
( (tilePoly %~ map (shiftPointBy shift))
. (tileZero %~ shiftPointBy shift )
. (tileX %~ shiftPointBy shift )
. (tileZero %~ shiftPointBy shift )
. (tileX %~ shiftPointBy shift )
)
& rmViewpoints %~ map (shiftPointBy shift)
@@ -109,8 +101,8 @@ moveRoomBy shift r = r
& rmPmnts %~ map (shiftPlacement shift)
& rmFloor . tiles %~ map
( (tilePoly %~ map (shiftPointBy shift))
. (tileZero %~ shiftPointBy shift )
. (tileX %~ shiftPointBy shift )
. (tileZero %~ shiftPointBy shift )
. (tileX %~ shiftPointBy shift )
)
& rmViewpoints %~ map (shiftPointBy shift)
@@ -124,8 +116,7 @@ shiftRoomShiftToLink l inlink r
(p,a) = inlink
-- NOTE placements, when placed, will be shifted by the value _rmShift
shiftRoomShiftBy :: (Point2,Float) -> Room -> Room
shiftRoomShiftBy shift r = r
& rmShift %~ shiftPosDirBy shift
shiftRoomShiftBy shift = rmShift %~ shiftPosDirBy shift
shiftPosDirBy :: (Point2,Float) -> (Point2,Float) -> (Point2,Float)
shiftPosDirBy (pos,rot) (p,r) = (shiftPointBy (pos,rot) p, r + rot)
+3 -3
View File
@@ -25,7 +25,7 @@ import Dodge.Item.Weapon.Utility
import Geometry
--import Padding
import Color
--import Shape
import Shape
import LensHelp
--import Data.Maybe
@@ -96,11 +96,11 @@ startRoom' = do
h <- state $ randomR (200,400)
let plmnts =
[ sPS (V2 0 0) 0 $ PutShape $ girderV 40 20 10 (V2 0 (h/2)) (V2 w (h/2))
--, mntLS jShape (V2 0 (h/3)) (V3 40 (h/3) 70)
-- , mntLS jShape (V2 0 (h/3)) (V3 40 (h/3) 70)
, tankSquareEmboss4 (dim orange) 50 (h-60)
, tankSquare (dim orange) 50 50
, tankSquare (dim orange) 50 120
--, sps0 $ PutShape $ colorSH orange $ pipePP 2 (V3 50 50 25) (V3 50 120 25)
, sps0 $ PutShape $ colorSH orange $ pipePP 2 (V3 50 50 25) (V3 50 120 25)
]
thecol <- rezColor
treeFromPost [PassDown $ rezBox thecol, PassDown door] . UseAll