File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -350,7 +350,13 @@ public static void MoveAllPlayers(ReducerContext ctx, MoveAllPlayersTimer timer)
350350 //Handle player input
351351 foreach ( var circle in ctx . Db . circle . Iter ( ) )
352352 {
353- var circle_entity = ctx . Db . entity . entity_id . Find ( circle . entity_id ) ?? throw new Exception ( "Circle has no entity" ) ;
353+ var check_entity = ctx . Db . entity . entity_id . Find ( circle . entity_id ) ;
354+ if ( check_entity == null )
355+ {
356+ // This can happen if the circle has been eaten by another circle.
357+ continue ;
358+ }
359+ var circle_entity = check_entity . Value ;
354360 var circle_radius = MassToRadius ( circle_entity . mass ) ;
355361 var direction = circle_directions [ circle . entity_id ] ;
356362 var new_pos = circle_entity . position + direction * MassToMaxMoveSpeed ( circle_entity . mass ) ;
Original file line number Diff line number Diff line change @@ -406,7 +406,12 @@ pub fn move_all_players(ctx: &ReducerContext, _timer: MoveAllPlayersTimer) -> Re
406406
407407 // Handle player input
408408 for circle in ctx. db . circle ( ) . iter ( ) {
409- let mut circle_entity = ctx. db . entity ( ) . entity_id ( ) . find ( & circle. entity_id ) . unwrap ( ) ;
409+ let circle_entity = ctx. db . entity ( ) . entity_id ( ) . find ( & circle. entity_id ) ;
410+ if !circle_entity. is_some ( ) {
411+ // This can happen if a circle is eaten by another circle
412+ continue ;
413+ }
414+ let mut circle_entity = circle_entity. unwrap ( ) ;
410415 let circle_radius = mass_to_radius ( circle_entity. mass ) ;
411416 let direction = * circle_directions. get ( & circle. entity_id ) . unwrap ( ) ;
412417 let new_pos =
You can’t perform that action at this time.
0 commit comments