Skip to content

Commit

Permalink
structure placement order (#1833)
Browse files Browse the repository at this point in the history
It is more intuitive in scenario design for "later" things to be placed "on top of" earlier things.

There were only a small number of scenarios for which placement order was relevant, so I fixed them.
  • Loading branch information
kostmo authored May 10, 2024
1 parent 0968161 commit 5ed37d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ world:
xx
xx
placements:
- src: tiny rectangle
- src: small rectangle
- src: medium rectangle
- src: big rectangle
- src: huge rectangle
- src: big rectangle
- src: medium rectangle
- src: small rectangle
- src: tiny rectangle
map: |
............
............
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ attrs:
- name: portal_out
fg: "#00a2ff"
bg: "#0065ff"
solution: turn left; move; move; turn left; move; move; move; turn left; move; move; move; move; move;
entities:
- name: telepad entrance
display:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ world:
'B': [grass, null, base]
upperleft: [-97, 17]
placements:
- src: green_jewel
offset: [3, -3]
- src: red_jewel
offset: [1, -1]
- src: red_jewel
Expand All @@ -77,6 +75,8 @@ world:
offset: [5, -1]
- src: red_jewel
offset: [5, -5]
- src: green_jewel
offset: [3, -3]
map: |
.........
.........
Expand Down
16 changes: 8 additions & 8 deletions data/scenarios/Vignettes/roadway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ world:
SSSSSS
SSSSSS
placements:
- src: tunnel
offset: [3, -21]
orient:
up: west
- src: tunnel
offset: [71, -21]
orient:
up: east
- src: road segment
offset: [6, -22]
orient:
Expand Down Expand Up @@ -161,6 +153,14 @@ world:
orient:
up: west
flip: true
- src: tunnel
offset: [3, -21]
orient:
up: west
- src: tunnel
offset: [71, -21]
orient:
up: east
upperleft:
- -18
- 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Control.Arrow (left, (&&&))
import Control.Monad (when)
import Data.Coerce
import Data.Either.Extra (maybeToEither)
import Data.Foldable (foldrM)
import Data.Foldable (foldlM)
import Data.Map qualified as M
import Data.Set qualified as Set
import Data.Text (Text)
Expand Down Expand Up @@ -53,8 +53,8 @@ overlaySingleStructure
offsetLoc (coerce loc)
. modifyLoc (reorientLandmark orientation $ getGridDimensions overArea)

-- | Overlays all of the "child placements", such that the children encountered earlier
-- in the YAML file supersede the later ones (due to use of 'foldr' instead of 'foldl').
-- | Overlays all of the "child placements", such that the children encountered later
-- in the YAML file supersede the earlier ones (dictated by using 'foldl' instead of 'foldr').
mergeStructures ::
M.Map StructureName (NamedStructure (Maybe a)) ->
Parentage Placement ->
Expand All @@ -77,8 +77,8 @@ mergeStructures inheritedStrucDefs parentPlacement (Structure origArea subStruct
map wrapPlacement $
filter (\(Placed _ ns) -> isRecognizable ns) overlays

foldrM
(overlaySingleStructure structureMap)
foldlM
(flip $ overlaySingleStructure structureMap)
(MergedStructure origArea wrappedOverlays originatedWaypoints)
overlays
where
Expand Down

0 comments on commit 5ed37d6

Please sign in to comment.