simplify infinite entity grabbing logic (#1737)

Refactoring towards #1598
This commit is contained in:
Karl Ostmo 2024-01-23 20:53:05 -08:00 committed by GitHub
parent 9320a985e4
commit d1a41de8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1688,13 +1688,11 @@ execConst runChildProg c vs s k = do
(omni || e `hasProperty` Pickable)
`holdsOrFail` ["The", e ^. entityName, "here can't be", verbed <> "."]
-- Remove the entity from the world.
updateEntityAt loc (const Nothing)
flagRedraw
-- Immediately regenerate entities with 'infinite' property.
when (e `hasProperty` Infinite) $
updateEntityAt loc (const (Just e))
-- Entities with 'infinite' property are not removed
unless (e `hasProperty` Infinite) $ do
-- Remove the entity from the world.
updateEntityAt loc (const Nothing)
flagRedraw
-- Possibly regrow the entity, if it is growable and the 'harvest'
-- command was used.