feat(xanthous) Generate random volume+density for items

Generate random volumes and densities for items based on the ranges for
those two quantities in the raw when building instances of items.

Since this is the first time creating an item is impure, this also lifts
entity generation into a (random) monadic context

Change-Id: I2de4880e8144f7ff9e1304eb32806ed1d7affa18
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3226
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2021-06-19 11:49:20 -04:00 committed by grfn
parent 8b97683f6e
commit d8bd8e7eea
9 changed files with 108 additions and 25 deletions

View file

@ -100,7 +100,7 @@ tutorialMessage cells characterPosition = do
randomEntities
:: forall entity raw m. (MonadRandom m, RawType raw)
=> (raw -> entity)
=> (raw -> m entity)
-> (Float, Float)
-> Cells
-> m (EntityMap entity)
@ -114,7 +114,7 @@ randomEntities newWithType sizeRange cells =
entities <- for [0..numEntities] $ const $ do
pos <- randomPosition cells
raw <- choose raws
let entity = newWithType raw
entity <- newWithType raw
pure (pos, entity)
pure $ _EntityMap # entities