{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
module Aztecs.ECS.World.Archetypes.Internal
( ArchetypeID (..),
Node (..),
Archetypes (..),
)
where
import Aztecs.ECS.Component.Internal (ComponentID)
import Aztecs.ECS.World.Archetype.Internal (Archetype)
import Data.Kind (Type)
import Data.Map.Strict (Map)
import Data.Set (Set)
import GHC.Generics
newtype ArchetypeID = ArchetypeID
{
ArchetypeID -> Int
unArchetypeId :: Int
}
deriving newtype (ArchetypeID -> ArchetypeID -> Bool
(ArchetypeID -> ArchetypeID -> Bool)
-> (ArchetypeID -> ArchetypeID -> Bool) -> Eq ArchetypeID
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArchetypeID -> ArchetypeID -> Bool
== :: ArchetypeID -> ArchetypeID -> Bool
$c/= :: ArchetypeID -> ArchetypeID -> Bool
/= :: ArchetypeID -> ArchetypeID -> Bool
Eq, Eq ArchetypeID
Eq ArchetypeID =>
(ArchetypeID -> ArchetypeID -> Ordering)
-> (ArchetypeID -> ArchetypeID -> Bool)
-> (ArchetypeID -> ArchetypeID -> Bool)
-> (ArchetypeID -> ArchetypeID -> Bool)
-> (ArchetypeID -> ArchetypeID -> Bool)
-> (ArchetypeID -> ArchetypeID -> ArchetypeID)
-> (ArchetypeID -> ArchetypeID -> ArchetypeID)
-> Ord ArchetypeID
ArchetypeID -> ArchetypeID -> Bool
ArchetypeID -> ArchetypeID -> Ordering
ArchetypeID -> ArchetypeID -> ArchetypeID
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ArchetypeID -> ArchetypeID -> Ordering
compare :: ArchetypeID -> ArchetypeID -> Ordering
$c< :: ArchetypeID -> ArchetypeID -> Bool
< :: ArchetypeID -> ArchetypeID -> Bool
$c<= :: ArchetypeID -> ArchetypeID -> Bool
<= :: ArchetypeID -> ArchetypeID -> Bool
$c> :: ArchetypeID -> ArchetypeID -> Bool
> :: ArchetypeID -> ArchetypeID -> Bool
$c>= :: ArchetypeID -> ArchetypeID -> Bool
>= :: ArchetypeID -> ArchetypeID -> Bool
$cmax :: ArchetypeID -> ArchetypeID -> ArchetypeID
max :: ArchetypeID -> ArchetypeID -> ArchetypeID
$cmin :: ArchetypeID -> ArchetypeID -> ArchetypeID
min :: ArchetypeID -> ArchetypeID -> ArchetypeID
Ord, Int -> ArchetypeID -> ShowS
[ArchetypeID] -> ShowS
ArchetypeID -> String
(Int -> ArchetypeID -> ShowS)
-> (ArchetypeID -> String)
-> ([ArchetypeID] -> ShowS)
-> Show ArchetypeID
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArchetypeID -> ShowS
showsPrec :: Int -> ArchetypeID -> ShowS
$cshow :: ArchetypeID -> String
show :: ArchetypeID -> String
$cshowList :: [ArchetypeID] -> ShowS
showList :: [ArchetypeID] -> ShowS
Show)
data Node (m :: Type -> Type) = Node
{
forall (m :: * -> *). Node m -> Set ComponentID
nodeComponentIds :: !(Set ComponentID),
forall (m :: * -> *). Node m -> Archetype m
nodeArchetype :: !(Archetype m)
}
deriving (Int -> Node m -> ShowS
[Node m] -> ShowS
Node m -> String
(Int -> Node m -> ShowS)
-> (Node m -> String) -> ([Node m] -> ShowS) -> Show (Node m)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (m :: * -> *). Int -> Node m -> ShowS
forall (m :: * -> *). [Node m] -> ShowS
forall (m :: * -> *). Node m -> String
$cshowsPrec :: forall (m :: * -> *). Int -> Node m -> ShowS
showsPrec :: Int -> Node m -> ShowS
$cshow :: forall (m :: * -> *). Node m -> String
show :: Node m -> String
$cshowList :: forall (m :: * -> *). [Node m] -> ShowS
showList :: [Node m] -> ShowS
Show, (forall x. Node m -> Rep (Node m) x)
-> (forall x. Rep (Node m) x -> Node m) -> Generic (Node m)
forall x. Rep (Node m) x -> Node m
forall x. Node m -> Rep (Node m) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (m :: * -> *) x. Rep (Node m) x -> Node m
forall (m :: * -> *) x. Node m -> Rep (Node m) x
$cfrom :: forall (m :: * -> *) x. Node m -> Rep (Node m) x
from :: forall x. Node m -> Rep (Node m) x
$cto :: forall (m :: * -> *) x. Rep (Node m) x -> Node m
to :: forall x. Rep (Node m) x -> Node m
Generic)
data Archetypes (m :: Type -> Type) = Archetypes
{
forall (m :: * -> *). Archetypes m -> Map ArchetypeID (Node m)
nodes :: !(Map ArchetypeID (Node m)),
forall (m :: * -> *).
Archetypes m -> Map (Set ComponentID) ArchetypeID
archetypeIds :: !(Map (Set ComponentID) ArchetypeID),
forall (m :: * -> *). Archetypes m -> ArchetypeID
nextArchetypeId :: !ArchetypeID,
forall (m :: * -> *).
Archetypes m -> Map ComponentID (Set ArchetypeID)
componentIds :: !(Map ComponentID (Set ArchetypeID))
}
deriving (Int -> Archetypes m -> ShowS
[Archetypes m] -> ShowS
Archetypes m -> String
(Int -> Archetypes m -> ShowS)
-> (Archetypes m -> String)
-> ([Archetypes m] -> ShowS)
-> Show (Archetypes m)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (m :: * -> *). Int -> Archetypes m -> ShowS
forall (m :: * -> *). [Archetypes m] -> ShowS
forall (m :: * -> *). Archetypes m -> String
$cshowsPrec :: forall (m :: * -> *). Int -> Archetypes m -> ShowS
showsPrec :: Int -> Archetypes m -> ShowS
$cshow :: forall (m :: * -> *). Archetypes m -> String
show :: Archetypes m -> String
$cshowList :: forall (m :: * -> *). [Archetypes m] -> ShowS
showList :: [Archetypes m] -> ShowS
Show, (forall x. Archetypes m -> Rep (Archetypes m) x)
-> (forall x. Rep (Archetypes m) x -> Archetypes m)
-> Generic (Archetypes m)
forall x. Rep (Archetypes m) x -> Archetypes m
forall x. Archetypes m -> Rep (Archetypes m) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (m :: * -> *) x. Rep (Archetypes m) x -> Archetypes m
forall (m :: * -> *) x. Archetypes m -> Rep (Archetypes m) x
$cfrom :: forall (m :: * -> *) x. Archetypes m -> Rep (Archetypes m) x
from :: forall x. Archetypes m -> Rep (Archetypes m) x
$cto :: forall (m :: * -> *) x. Rep (Archetypes m) x -> Archetypes m
to :: forall x. Rep (Archetypes m) x -> Archetypes m
Generic)