From 9b8d3185fe6cee9231ed20a1dbf0240d0c459a39 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 3 Jul 2020 20:32:36 -0400 Subject: refactor(xan): Switch to V2 over tuples most places These are generally rather nicer to work due to some typeclass instances, and integrate better with other ecosystems for things like linear algebra etc. Change-Id: I546c8da7b17234648f3d612b28741c1fded25447 Reviewed-on: https://cl.tvl.fyi/c/depot/+/910 Tested-by: BuildkiteCI Reviewed-by: glittershark --- users/glittershark/xanthous/src/Xanthous/Generators.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'users/glittershark/xanthous/src/Xanthous/Generators.hs') diff --git a/users/glittershark/xanthous/src/Xanthous/Generators.hs b/users/glittershark/xanthous/src/Xanthous/Generators.hs index 2801137b699c..ef37070b6ede 100644 --- a/users/glittershark/xanthous/src/Xanthous/Generators.hs +++ b/users/glittershark/xanthous/src/Xanthous/Generators.hs @@ -39,6 +39,7 @@ import Xanthous.Entities.Environment import Xanthous.Entities.Item (Item) import Xanthous.Entities.Creature (Creature) import Xanthous.Game.State (SomeEntity(..)) +import Linear.V2 -------------------------------------------------------------------------------- data Generator @@ -91,18 +92,18 @@ parseGeneratorInput = Opt.subparser showCells :: Cells -> Text showCells arr = - let ((minX, minY), (maxX, maxY)) = bounds arr + let (V2 minX minY, V2 maxX maxY) = bounds arr showCellVal True = "x" showCellVal False = " " showCell = showCellVal . (arr !) - row r = foldMap (showCell . (, r)) [minX..maxX] + row r = foldMap (showCell . (`V2` r)) [minX..maxX] rows = row <$> [minY..maxY] in intercalate "\n" rows cellsToWalls :: Cells -> EntityMap Wall cellsToWalls cells = foldl' maybeInsertWall mempty . assocs $ cells where - maybeInsertWall em (pos@(x, y), True) + maybeInsertWall em (pos@(V2 x y), True) | not (surroundedOnAllSides pos) = let x' = fromIntegral x y' = fromIntegral y -- cgit 1.4.1