@@ -137,8 +137,8 @@ const initialCharacter = () =>
137137export const CharacterMachine = Machine . make ( {
138138 id : "PlatformerCharacter" ,
139139 states : CharacterStates . states ,
140- events : Object . values ( Event . cases ) ,
141- internalEvents : Object . values ( InternalEvent . cases ) ,
140+ events : [ Event ] ,
141+ internalEvents : [ InternalEvent ] ,
142142 initial : initialCharacter
143143} ) . handle ( {
144144 Character : {
@@ -151,18 +151,29 @@ export const CharacterMachine = Machine.make({
151151 Grounded : {
152152 on : {
153153 JumpPressed : ( { event, target } ) =>
154- target . branch . Character . locomotion . Airborne (
155- State . cases . Airborne . make ( { originY : event . y } ) ,
156- ( airborne ) =>
157- airborne
158- . motion ( State . cases . Motion . make ( { } ) , ( motion ) =>
159- motion . Jumping (
160- State . cases . Jumping . make ( { startedAt : event . at , push : 0 , kind : "Ground" } )
161- )
162- )
163- . airJump ( State . cases . AirJump . make ( { } ) , ( airJump ) =>
164- airJump . AirJumpGroundLock ( State . cases . AirJumpGroundLock . make ( { } ) )
154+ target . full . Character ( State . cases . Character . make ( { } ) , ( character ) =>
155+ character
156+ . locomotion ( State . cases . Locomotion . make ( { } ) , ( locomotion ) =>
157+ locomotion . Airborne ( State . cases . Airborne . make ( { originY : event . y } ) , ( airborne ) =>
158+ airborne
159+ . motion ( State . cases . Motion . make ( { } ) , ( motion ) =>
160+ motion . Jumping (
161+ State . cases . Jumping . make ( { startedAt : event . at , push : 0 , kind : "Ground" } )
162+ )
163+ )
164+ . airJump ( State . cases . AirJump . make ( { } ) , ( airJump ) =>
165+ airJump . AirJumpGroundLock ( State . cases . AirJumpGroundLock . make ( { } ) )
166+ )
165167 )
168+ )
169+ . facing ( State . cases . Facing . make ( { } ) , ( facing ) => facing . Right ( State . cases . Right . make ( { } ) ) )
170+ . contact ( State . cases . WallContact . make ( { } ) , ( contact ) =>
171+ event . wall === - 1
172+ ? contact . LeftWall ( State . cases . LeftWall . make ( { } ) )
173+ : event . wall === 1
174+ ? contact . RightWall ( State . cases . RightWall . make ( { } ) )
175+ : contact . NoWall ( State . cases . NoWall . make ( { } ) )
176+ )
166177 )
167178 } ,
168179 states : {
0 commit comments