Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+11 -25
View File
@@ -1,23 +1,9 @@
--{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.LevelGen.Data where
import Dodge.Data
--import Picture
import Geometry
--import Color
--import Shape.Data
--import Data.Tile
--import qualified Data.Set as S
--import qualified Data.Map.Strict as M
import Control.Lens
--import Control.Monad.State
--import System.Random
import Data.Maybe
--import qualified IntMapHelp as IM
--import Data.Bifunctor
import Dodge.Data.GenWorld
import Geometry
spNoID :: PlacementSpot -> PSType -> Placement
spNoID ps pst = Placement 10 ps pst Nothing (const . const Nothing)
@@ -71,8 +57,8 @@ jps0' :: PSType -> (Placement -> Maybe Placement) -> Maybe Placement
jps0' pst = Just . Placement 10 (PS (V2 0 0) 0) pst Nothing . const
jps0PushPS :: PSType -> (Int -> Maybe Placement) -> Maybe Placement
jps0PushPS pst f = Just . Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing
$ \_ plmnt -> f (fromJust $ _plMID plmnt) <&> plSpot .~ _plSpot plmnt
jps0PushPS pst f = Just . Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing $
\_ plmnt -> f (fromJust $ _plMID plmnt) <&> plSpot .~ _plSpot plmnt
ps0j :: PSType -> Placement -> Placement
ps0j pst plmnt = Placement 10 (PS (V2 0 0) 0) pst Nothing (\_ -> const $ Just plmnt)
@@ -82,24 +68,24 @@ psj ps pst plmnt = Placement 10 ps pst Nothing (\_ -> const $ Just plmnt)
-- the NoShiftCont is necessary when shifting then combining rooms
ps0jPushPS :: PSType -> Placement -> Placement
ps0jPushPS pst plmnt = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing
$ \_ p -> Just $ plmnt & plSpot .~ _plSpot p
ps0jPushPS pst plmnt = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing $
\_ p -> Just $ plmnt & plSpot .~ _plSpot p
-- the NoShiftCont is necessary when shifting then combining rooms
ps0PushPS :: PSType -> (Placement -> Maybe Placement) -> Placement
ps0PushPS pst f = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing
$ \_ pl -> f pl & _Just . plSpot %~ const (_plSpot pl)
ps0PushPS pst f = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing $
\_ pl -> f pl & _Just . plSpot %~ const (_plSpot pl)
ps0PushPSw :: PSType -> (World -> Placement -> Maybe Placement) -> Placement
ps0PushPSw pst f = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing
$ \w pl -> f w pl & _Just . plSpot %~ const (_plSpot pl)
ps0PushPSw pst f = Placement 10 (PSNoShiftCont (V2 0 0) 0) pst Nothing $
\w pl -> f w pl & _Just . plSpot %~ const (_plSpot pl)
addPlmnt :: Placement -> Placement -> Placement
addPlmnt pl pl2 = case pl2 of
(PlacementUsingPos p f) -> PlacementUsingPos p (fmap (addPlmnt pl) f)
(RandomPlacement rp) -> RandomPlacement $ fmap (addPlmnt pl) rp
(Placement i ps pt mi f) -> Placement i ps pt mi (fmap (fmap g) f)
PickOnePlacement {} -> error "not written how to combine PickOnePlacement with others yet"
PickOnePlacement{} -> error "not written how to combine PickOnePlacement with others yet"
where
g Nothing = Just pl
g (Just pl') = Just $ addPlmnt pl pl'
+20 -24
View File
@@ -1,34 +1,30 @@
--{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.LevelGen.LevelStructure
( module Dodge.LevelGen.Data
, worldToGenWorld
) where
import Dodge.LevelGen.Data
--import Dodge.Tree.Compose.Data
import Dodge.Data
import RandomHelp
import Color
import LensHelp
module Dodge.LevelGen.LevelStructure (
module Dodge.LevelGen.Data,
worldToGenWorld,
) where
--import Data.Tree
import qualified IntMapHelp as IM
import Color
import qualified Data.Map.Strict as M
--import Control.Lens
import Dodge.Data.GenWorld
import Dodge.LevelGen.Data
import qualified IntMapHelp as IM
import LensHelp
import RandomHelp
worldToGenWorld :: IM.IntMap Room -> World -> GenWorld
worldToGenWorld rms w = GenWorld
{ _gwWorld = w & cWorld . genParams .~ evalState generateGenParams (_randGen w)
, _genRooms = rms
, _genPlacements = mempty
}
worldToGenWorld rms w =
GenWorld
{ _gwWorld = w & cWorld . genParams .~ evalState generateGenParams (_randGen w)
, _genRooms = rms
, _genPlacements = mempty
}
generateGenParams :: RandomGen g => State g GenParams
generateGenParams = do
cols <- shuffle [RED .. ORANGE]
shps <- shuffle [PLUS ..]
return
. GenParams
. M.fromList
. zip [FLAMING,LASERING,ELECTRICAL]
return
. GenParams
. M.fromList
. zip [FLAMING, LASERING, ELECTRICAL]
$ zip cols shps
+2 -1
View File
@@ -4,7 +4,8 @@ module Dodge.LevelGen.Switch
, makeSwitchSPic
, drawSwitchWire
) where
import Dodge.Data
import Dodge.Data.Button
import Dodge.Data.WorldEffect
import Dodge.Default
import Dodge.SoundLogic
import Picture