File tree 4 files changed +69
-249
lines changed
4 files changed +69
-249
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ move = fetch & zipFetchMap (\(Velocity v) (Position p) -> Position $ p + v)
18
18
19
19
run :: SystemT IO ()
20
20
run = do
21
- positions <- query move
21
+ positions <- fromSystem $ query move
22
22
liftIO $ print positions
23
23
24
24
app :: AccessT IO ()
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ module Aztecs.ECS
37
37
EntityID ,
38
38
spawn ,
39
39
system ,
40
- concurrently ,
41
40
World ,
42
41
)
43
42
where
@@ -52,7 +51,7 @@ import Aztecs.ECS.Query hiding
52
51
readQuery ,
53
52
readQueryEntities ,
54
53
)
55
- import Aztecs.ECS.System hiding ( concurrently )
54
+ import Aztecs.ECS.System
56
55
import Aztecs.ECS.World (World )
57
56
import Aztecs.ECS.World.Bundle
58
57
import Aztecs.ECS.World.Bundle.Dynamic
Original file line number Diff line number Diff line change @@ -23,18 +23,16 @@ module Aztecs.ECS.Access
23
23
runAccessT ,
24
24
runAccessT_ ,
25
25
system ,
26
- concurrently ,
27
26
)
28
27
where
29
28
30
29
import Aztecs.ECS.Component
31
30
import Aztecs.ECS.Entity
32
31
import Aztecs.ECS.System (SystemT (.. ), runSystemT )
33
- import qualified Aztecs.ECS.System as S
32
+ import Aztecs.ECS.View
34
33
import Aztecs.ECS.World (World (.. ))
35
34
import qualified Aztecs.ECS.World as W
36
35
import Aztecs.ECS.World.Bundle
37
- import Control.Concurrent.STM
38
36
import Control.DeepSeq
39
37
import Control.Monad.Fix
40
38
import Control.Monad.Identity
@@ -123,28 +121,6 @@ despawn e = AccessT $ do
123
121
system :: (Monad m ) => SystemT m a -> AccessT m a
124
122
system s = AccessT $ do
125
123
! w <- get
126
- let go f = do
127
- es <- get
128
- let es' = f es
129
- put es'
130
- return es'
131
- (a, es) <- lift $ runStateT (runSystemT s go) (entities w)
132
- put w {entities = es}
133
- return a
134
-
135
- -- | Run a `System` concurrently.
136
- --
137
- -- @since 0.11
138
- concurrently :: SystemT IO a -> AccessT IO a
139
- concurrently s = AccessT $ do
140
- ! w <- get
141
- esVar <- lift . newTVarIO $ entities w
142
- let go f = atomically $ do
143
- es <- readTVar esVar
144
- let es' = f es
145
- writeTVar esVar es'
146
- return es'
147
- a <- liftIO $ S. concurrently s go
148
- es <- lift $ readTVarIO esVar
149
- put w {entities = es}
124
+ (a, v) <- lift . runSystemT s $ entities w
125
+ put w {entities = unview v $ entities w}
150
126
return a
You can’t perform that action at this time.
0 commit comments