| License | BSD-3-Clause |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Game.Scenario.Topography.Structure.Recognition.Registry
Description
Registry of found structures. This datatype contains two maps that must be kept in sync. Uses smart constructors to maintain this invariant.
Synopsis
- data FoundRegistry b a
- emptyFoundStructures :: FoundRegistry b a
- populateStaticFoundStructures :: [FoundStructure b a] -> FoundRegistry b a
- foundByName :: FoundRegistry b a -> Map OriginalName (NEMap (Cosmic Location) (StructureWithGrid b a))
- foundByLocation :: FoundRegistry b a -> Map (Cosmic Location) (FoundStructure b a)
- addFound :: FoundStructure b a -> FoundRegistry b a -> FoundRegistry b a
- removeStructure :: FoundStructure b a -> FoundRegistry b a -> FoundRegistry b a
Documentation
data FoundRegistry b a Source #
The authoritative source of which built structures currently exist.
The two type parameters, b and a, correspond
to StructureCells and Entity, respectively.
Instantiation
emptyFoundStructures :: FoundRegistry b a Source #
populateStaticFoundStructures :: [FoundStructure b a] -> FoundRegistry b a Source #
Bulk insertion of found structures.
Each of these shall have been re-checked in case a subsequent placement occludes them.
Read-only accessors
foundByName :: FoundRegistry b a -> Map OriginalName (NEMap (Cosmic Location) (StructureWithGrid b a)) Source #
We use a NEMap here so that we can use the
safe-indexing function indexWrapNonEmpty in the implementation
of the structure command.
foundByLocation :: FoundRegistry b a -> Map (Cosmic Location) (FoundStructure b a) Source #
This is a worldwide "mask" that prevents members of placed structures from participating in new structures and facilitates deletion of structures when their elements are removed from the world.
Each recognized structure instance will have MxN entries in this map.
Mutation
addFound :: FoundStructure b a -> FoundRegistry b a -> FoundRegistry b a Source #
removeStructure :: FoundStructure b a -> FoundRegistry b a -> FoundRegistry b a Source #