Beispiel #1
0
            public GroundConstraint(Body body, Fixture bodyFixture, SurfaceMovementControl surfaceMovementControl)
            {
                _body = body;
                _surfaceMovementControl = surfaceMovementControl;
                Add(bodyFixture.CreateContactHandler(HexPhysicTypes.Ground, EnterGroundContact, ExitGroundContact));

                // sensor
                var sensor = _body.AttachCircle(10f, 0);
                sensor.IsSensor = true;
                sensor.SetCollisionType(HexPhysicTypes.GroundSensor);
                _closeHexList = Add(new FixtureContactList(sensor));

                // ground constraint
                _groundConstraintUpdate = new UpdateComponent(UpdateGroundConstraint, UpdateTime.Sim);
                Add(_groundConstraintUpdate);

                // state
                Add(new StateRecorder("groundConstraint",
                    state => { },
                    state =>
                    {
                        _isOnGround = false;
                        _currentHex = null;
                    }));
            }