More nesting of fields in CWorld

This commit is contained in:
2022-08-19 11:41:07 +01:00
parent 3b7841677a
commit 2e34481ab1
9 changed files with 58 additions and 40 deletions
+9 -7
View File
@@ -1,13 +1,15 @@
module Dodge.Clock
( clockCycle
) where
module Dodge.Clock (
clockCycle,
) where
import Control.Lens
import qualified Data.Vector as V
import Dodge.Data.World
import qualified Data.Vector as V
clockCycle :: Int -> V.Vector a -> World -> a
{-# INLINABLE clockCycle #-}
clockCycle tPeriod xs w = xs V.! i
{-# INLINEABLE clockCycle #-}
clockCycle tPeriod xs w = xs V.! i
where
l = V.length xs
t = _worldClock (_cWorld w) `mod` (l * tPeriod)
t = (w ^. cWorld . cwTime . worldClock) `mod` (l * tPeriod)
i = t `div` tPeriod