Пример #1
0
        /// <summary>
        /// moves the entity taking collisions into account
        /// </summary>
        /// <returns><c>true</c>, if move actor was newed, <c>false</c> otherwise.</returns>
        /// <param name="motion">Motion.</param>
        public bool Move(Vector2 motion)
        {
            if (_collider == null)
            {
                return(false);
            }

            var didCollide = false;

            // fetch anything that we might collide with at our new position
            Entity.Transform.Position += motion;

            // fetch anything that we might collide with us at our new position
            var neighbors = Physics.BoxcastBroadphase(_collider.Bounds, _collider.CollidesWithLayers);

            foreach (var neighbor in neighbors)
            {
                if (_collider.Overlaps(neighbor))
                {
                    didCollide = true;
                    NotifyTriggerListeners(_collider, neighbor);
                }
            }

            return(didCollide);
        }
Пример #2
0
        public void Update()
        {
            if (_collider == null)
            {
                return;
            }
            //fetch anything that we might collide with us
            var neighbors = Physics.BoxcastBroadphaseExcludingSelf(_collider, _collider.CollidesWithLayers);

            foreach (var neighbor in neighbors)
            {
                if (_collider.Overlaps(neighbor))
                {
                    NotifyListeners(_collider, neighbor);
                }
            }
        }