@@ -68,28 +68,29 @@ module Animator =
6868 let inline untyped ( animation : #IAnimation<'Model> ) =
6969 animation :> IAnimation< 'Model>
7070
71- let tick ( lens : Lens < 'Model , Animator < 'Model >>) ( time : GlobalTime ) ( model : 'Model ) =
72- let getSlots model = ( Optic.get lens model) .Slots
71+ let inline getSlots ( lens : Lens < 'Model , Animator < 'Model >>) ( model : 'Model ) =
72+ HashMap.toValueSeq ( Optic.get lens model) .Slots
7373
74+ let tick ( lens : Lens < 'Model , Animator < 'Model >>) ( time : GlobalTime ) ( model : 'Model ) =
7475 // Set the current tick
75- let animator = { Optic.get lens model with CurrentTick = ValueSome time }
76+ let animator = { Optic.get lens model with CurrentTick = time }
7677 let mutable model = model |> Optic.set lens animator
7778
7879 // Process pending actions
79- for _, s in getSlots model do
80+ for s in getSlots lens model do
8081 model <- s.Commit( model, time)
8182
8283 // Update all running animations by generating and enqueuing Update actions
83- for _, s in getSlots model do
84+ for s in getSlots lens model do
8485 s.Update time
8586
8687 // Process Update actions
87- for _, s in getSlots model do
88+ for s in getSlots lens model do
8889 model <- s.Commit( model, time)
8990
9091 // Reset current tick
9192 model |> Optic.map lens ( fun animator ->
92- { animator with CurrentTick = ValueNone }
93+ { animator with CurrentTick = GlobalTime.infinite }
9394 )
9495
9596 let set ( lens : Lens < 'Model , Animator < 'Model >>)
@@ -99,11 +100,11 @@ module Animator =
99100
100101 let animator = model |> Optic.get lens
101102
102- match animator.Slots |> HashMap.tryFind name with
103- | Some slot ->
103+ match animator.Slots |> HashMap.tryFindV name with
104+ | ValueSome slot ->
104105 slot.Set( animation)
105106 slot.Perform( action)
106- slot.Commit( model, & animator.CurrentTick)
107+ slot.Commit( model, animator.CurrentTick)
107108
108109 | _ ->
109110 let slot = AnimatorSlot( name, animation.Create name)
@@ -114,7 +115,7 @@ module Animator =
114115 )
115116
116117 slot.Perform( action)
117- slot.Commit( model, & animator.CurrentTick)
118+ slot.Commit( model, animator.CurrentTick)
118119
119120 let enqueue ( lens : Lens < 'Model , Animator < 'Model >>)
120121 ( name : Symbol ) ( animation : 'Model -> IAnimation < 'Model >)
@@ -123,10 +124,10 @@ module Animator =
123124
124125 let animator = model |> Optic.get lens
125126
126- match animator.Slots |> HashMap.tryFind name with
127- | Some slot ->
127+ match animator.Slots |> HashMap.tryFindV name with
128+ | ValueSome slot ->
128129 slot.Enqueue( animation, action)
129- slot.Commit( model, & animator.CurrentTick)
130+ slot.Commit( model, animator.CurrentTick)
130131
131132 | _ ->
132133 let slot = AnimatorSlot( name, ( animation model) .Create name)
@@ -137,7 +138,7 @@ module Animator =
137138 )
138139
139140 slot.Perform( action)
140- slot.Commit( model, & animator.CurrentTick)
141+ slot.Commit( model, animator.CurrentTick)
141142
142143 let remove ( lens : Lens < 'Model , Animator < 'Model >>) ( name : Symbol ) ( model : 'Model ) =
143144 model |> Optic.map lens ( fun animator ->
@@ -147,24 +148,24 @@ module Animator =
147148 let perform ( lens : Lens < 'Model , Animator < 'Model >>) ( name : Symbol ) ( action : IAnimationInstance < 'Model > -> unit ) ( model : 'Model ) =
148149 let animator = model |> Optic.get lens
149150
150- match animator.Slots |> HashMap.tryFind name with
151- | Some slot ->
151+ match animator.Slots |> HashMap.tryFindV name with
152+ | ValueSome slot ->
152153 slot.Perform( action)
153- slot.Commit( model, & animator.CurrentTick)
154+ slot.Commit( model, animator.CurrentTick)
154155
155156 | _ ->
156157 model
157158
158159 let iterate ( lens : Lens < 'Model , Animator < 'Model >>) ( action : IAnimationInstance < 'Model > -> unit ) ( model : 'Model ) =
159160 let animator = model |> Optic.get lens
160161
161- for _, s in animator.Slots do
162+ for s in getSlots lens model do
162163 s.Perform( action)
163164
164165 let mutable model = model
165166
166- for _, s in animator.Slots do
167- model <- s.Commit( model, & animator.CurrentTick)
167+ for s in getSlots lens model do
168+ model <- s.Commit( model, animator.CurrentTick)
168169
169170 model
170171
@@ -374,8 +375,8 @@ module Animator =
374375 lens |> Lenses.set
375376 {
376377 Slots = HashMap.empty
377- TickRate = 60
378- CurrentTick = ValueNone
378+ TickRate = 30
379+ CurrentTick = GlobalTime.infinite
379380 }
380381
381382 /// Thread pool that generates real-time tick messages at a fixed rate.
0 commit comments