| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.ECS.World.Utils
Synopsis
- processBundleElement :: World -> BundleElement ErasedComponent -> IO ProcessedBundleElement
- processBundleElements :: World -> Set (BundleElement ErasedComponent) -> IO ProcessedBundleData
- combineProcessedBundles :: ProcessedBundleData -> ProcessedBundleData -> ProcessedBundleData
- isInProcessedBundle :: ProcessedBundleData -> ComponentId -> Bool
- removeComponentFromProcessedBundle :: ComponentId -> ProcessedBundleData -> ProcessedBundleData
- tryGetEntityRelCollection :: Component c => World -> Entity -> IO (Maybe (Maybe [Rel c]))
- tryGetEntityComponent :: Component c => World -> Entity -> IO (Maybe (Maybe c))
- tryGetEntityRel :: Component c => Entity -> World -> Entity -> IO (Maybe (Maybe c))
- tryGetRelCollections :: Component c => World -> [ArchetypeId] -> IO [(Entity, [Rel c])]
- tryGetComponents :: Component c => World -> [ArchetypeId] -> IO [(Entity, c)]
- tryGetEntities :: World -> [ArchetypeId] -> IO [Entity]
- tryGetRels :: Component c => Entity -> World -> [ArchetypeId] -> IO [(Entity, Rel c)]
- tryGetRelsMaybe :: Component c => Entity -> World -> [ArchetypeId] -> IO [(Entity, Maybe (Rel c))]
- tryGetComponentsMaybe :: Component c => World -> [ArchetypeId] -> IO [(Entity, Maybe c)]
- tryGetTicks :: ComponentId -> World -> [ArchetypeId] -> IO [Maybe ComponentTick]
- isAlive :: forall m w. MonadSystem w m => Entity -> m Bool
- newtype GetSystem = GetSystem (forall c. Component c => Proxy c -> Entity -> System (Maybe c))
Documentation
processBundleElement :: World -> BundleElement ErasedComponent -> IO ProcessedBundleElement Source #
Process a BundleElement, turning its TypeRep into a ComponentId.
processBundleElements :: World -> Set (BundleElement ErasedComponent) -> IO ProcessedBundleData Source #
Process a set of BundleElements into a ProcessedBundleData.
combineProcessedBundles :: ProcessedBundleData -> ProcessedBundleData -> ProcessedBundleData Source #
Combine two ProcessedBundleDatas, merging their sets of elements.
isInProcessedBundle :: ProcessedBundleData -> ComponentId -> Bool Source #
Check if a ComponentId is inside a ProcessedBundleData.
removeComponentFromProcessedBundle :: ComponentId -> ProcessedBundleData -> ProcessedBundleData Source #
Sets the change tick of certain elements of the bundle to the specified Tick.
setChangedTickOfComponents :: ProcessedBundleData -> (ComponentId -> Bool) -> Tick -> ProcessedBundleData
setChangedTickOfComponents ProcessedBundleData {elements = !elements} !shouldChange !tick =
ProcessedBundleData
{ elements =
map
( ProcessedBundleElement {id = !id, component = ComponentData {value = !value, ticks = ComponentTicks {added = !added, changed = !changed}}} ->
if shouldChange id
then ProcessedBundleElement {id, component = ComponentData {value, ticks = ComponentTicks {added, changed = tick}}}
else ProcessedBundleElement {id, component = ComponentData {value, ticks = ComponentTicks {added, changed}}}
)
elements
}
Sets the added tick of certain elements of the bundle to the specified Tick.
setAddedTickOfComponents :: ProcessedBundleData -> (ComponentId -> Bool) -> Tick -> ProcessedBundleData
setAddedTickOfComponents ProcessedBundleData {elements = !elements} !shouldChange !tick =
ProcessedBundleData
{ elements =
map
( ProcessedBundleElement {id = !id, component = ComponentData {value = !value, ticks = ComponentTicks {added = !added, changed = !changed}}} ->
if shouldChange id
then ProcessedBundleElement {id, component = ComponentData {value, ticks = ComponentTicks {added = tick, changed}}}
else ProcessedBundleElement {id, component = ComponentData {value, ticks = ComponentTicks {added, changed}}}
)
elements
}
tryGetRelCollections :: Component c => World -> [ArchetypeId] -> IO [(Entity, [Rel c])] Source #
tryGetComponents :: Component c => World -> [ArchetypeId] -> IO [(Entity, c)] Source #
tryGetEntities :: World -> [ArchetypeId] -> IO [Entity] Source #
tryGetRels :: Component c => Entity -> World -> [ArchetypeId] -> IO [(Entity, Rel c)] Source #
tryGetRelsMaybe :: Component c => Entity -> World -> [ArchetypeId] -> IO [(Entity, Maybe (Rel c))] Source #
tryGetComponentsMaybe :: Component c => World -> [ArchetypeId] -> IO [(Entity, Maybe c)] Source #
tryGetTicks :: ComponentId -> World -> [ArchetypeId] -> IO [Maybe ComponentTick] Source #