Copyright | (c) axionbuster 2025 |
---|---|
License | BSD-3-Clause |
Safe Haskell | None |
Language | GHC2021 |
Provides the core collision detection and resolution system with effects. Handles block-based collision detection, movement resolution, and ground contact states.
Parts
- The
GetBlock
effect - The
Resolve
data type andresolve
function (the main part) - The
NewlyTouchingGround
data type andupdonground
function
Usage
- Use
getblock
to get a block's shape at integer coordinates - Use
resolve
to detect and resolve collision - Use
updonground
to update the on-ground status (from #2)
Synopsis
- data GetBlock (f :: Type -> Type) a (b :: Type -> Type) c where
- getblock :: forall f a (ef :: [Effect]). (HasCallStack, GetBlock f a :> ef) => V3 Int -> Eff ef (Maybe (f a))
- data Resolve a = Resolve {
- respos :: !(V3 a)
- resdis :: !(V3 a)
- restou :: !NewlyTouchingGround
- resolve :: forall s n (ef :: [Effect]). (Shape s, RealFloat n, Epsilon n, Typeable n, GetBlock s n :> ef) => s n -> V3 n -> Eff ef (Resolve n)
- _respos :: forall a f. Functor f => (V3 a -> f (V3 a)) -> Resolve a -> f (Resolve a)
- _resdis :: forall a f. Functor f => (V3 a -> f (V3 a)) -> Resolve a -> f (Resolve a)
- _restou :: forall a f. Functor f => (NewlyTouchingGround -> f NewlyTouchingGround) -> Resolve a -> f (Resolve a)
- newtype NewlyTouchingGround = NewlyTouchingGround {}
- updonground :: NewlyTouchingGround -> Bool -> Bool
- islanding :: NewlyTouchingGround -> Bool
- istakingoff :: NewlyTouchingGround -> Bool
Documentation
data GetBlock (f :: Type -> Type) a (b :: Type -> Type) c where Source #
get a block's shape at integer coordinates (dynamic effect)
GetBlock :: forall (f :: Type -> Type) a (b :: Type -> Type). !(V3 Int) -> GetBlock f a b (Maybe (f a)) | get a block's shape at integer coordinates |
Instances
type DispatchOf (GetBlock f a) Source # | |
Defined in M.Collision.Effectful type DispatchOf (GetBlock f a) = 'Dynamic |
:: forall f a (ef :: [Effect]). (HasCallStack, GetBlock f a :> ef) | |
=> V3 Int | integer coordinates |
-> Eff ef (Maybe (f a)) | if (relevant) block exists, return its shape what block is "relevant" is up to the implementation |
get a block's shape at integer coordinates
collision resolution data type
Resolve | |
|
Instances
Functor Resolve Source # | |||||
Data a => Data (Resolve a) Source # | |||||
Defined in M.Collision.Effectful gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Resolve a -> c (Resolve a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Resolve a) # toConstr :: Resolve a -> Constr # dataTypeOf :: Resolve a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Resolve a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Resolve a)) # gmapT :: (forall b. Data b => b -> b) -> Resolve a -> Resolve a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Resolve a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Resolve a -> r # gmapQ :: (forall d. Data d => d -> u) -> Resolve a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Resolve a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Resolve a -> m (Resolve a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Resolve a -> m (Resolve a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Resolve a -> m (Resolve a) # | |||||
Generic (Resolve a) Source # | |||||
Defined in M.Collision.Effectful
| |||||
Show a => Show (Resolve a) Source # | |||||
Eq a => Eq (Resolve a) Source # | |||||
Hashable a => Hashable (Resolve a) Source # | |||||
Defined in M.Collision.Effectful | |||||
type Rep (Resolve a) Source # | |||||
Defined in M.Collision.Effectful type Rep (Resolve a) = D1 ('MetaData "Resolve" "M.Collision.Effectful" "mmm-0.1.0.0-oCDsNp3EBL2JzoyA6cTai" 'False) (C1 ('MetaCons "Resolve" 'PrefixI 'True) (S1 ('MetaSel ('Just "respos") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V3 a)) :*: (S1 ('MetaSel ('Just "resdis") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (V3 a)) :*: S1 ('MetaSel ('Just "restou") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 NewlyTouchingGround)))) |
:: forall s n (ef :: [Effect]). (Shape s, RealFloat n, Epsilon n, Typeable n, GetBlock s n :> ef) | |
=> s n | shape of the object who is moving |
-> V3 n | attempted displacement |
-> Eff ef (Resolve n) | new resolution unless it got stuck, the new displacement should be zero |
detect and resolve collision
_respos :: forall a f. Functor f => (V3 a -> f (V3 a)) -> Resolve a -> f (Resolve a) Source #
lens for Resolve
position
_resdis :: forall a f. Functor f => (V3 a -> f (V3 a)) -> Resolve a -> f (Resolve a) Source #
lens for Resolve
displacement
_restou :: forall a f. Functor f => (NewlyTouchingGround -> f NewlyTouchingGround) -> Resolve a -> f (Resolve a) Source #
lens for Resolve
newly touching ground
newtype NewlyTouchingGround Source #
newly touching ground?
Instances
updonground :: NewlyTouchingGround -> Bool -> Bool Source #
'update' the on-ground status
islanding :: NewlyTouchingGround -> Bool Source #
is it landing?
istakingoff :: NewlyTouchingGround -> Bool Source #
is it taking off?