Ejemplo n.º 1
0
        public bool CollideCheck <T, Exclude>() where T : Entity where Exclude : Entity
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Entity type");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(Exclude)))
            {
                throw new Exception("Excluded type is an untracked Entity type!");
            }
#endif

            var exclude = Scene.Tracker.Entities[typeof(Exclude)];
            foreach (var e in Scene.Tracker.Entities[typeof(T)])
            {
                if (!exclude.Contains(e))
                {
                    if (Collide.Check(this, e))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public Entity CollideFirst(BitTag tag)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif
            return(Collide.First(this, Scene[tag]));
        }
Ejemplo n.º 3
0
        public bool CollideCheck(int tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif
            return(Collide.Check(this, Scene[tag], at));
        }
Ejemplo n.º 4
0
        public List <Entity> CollideAll(BitTag tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif
            return(Collide.All(this, Scene[tag], at));
        }
Ejemplo n.º 5
0
        static public bool RectToCircle(float rX, float rY, float rW, float rH, Vector2 cPosition, float cRadius)
        {
            //Check if the circle contains the rectangle's center-point
            if (Collide.CircleToPoint(cPosition, cRadius, new Vector2(rX + rW / 2, rY + rH / 2)))
            {
                return(true);
            }

            //Check the circle against the relevant edges
            Vector2      edgeFrom;
            Vector2      edgeTo;
            PointSectors sector = GetSector(rX, rY, rW, rH, cPosition);

            if ((sector & PointSectors.Top) != 0)
            {
                edgeFrom = new Vector2(rX, rY);
                edgeTo   = new Vector2(rX + rW, rY);
                if (CircleToLine(cPosition, cRadius, edgeFrom, edgeTo))
                {
                    return(true);
                }
            }

            if ((sector & PointSectors.Bottom) != 0)
            {
                edgeFrom = new Vector2(rX, rY + rH);
                edgeTo   = new Vector2(rX + rW, rY + rH);
                if (CircleToLine(cPosition, cRadius, edgeFrom, edgeTo))
                {
                    return(true);
                }
            }

            if ((sector & PointSectors.Left) != 0)
            {
                edgeFrom = new Vector2(rX, rY);
                edgeTo   = new Vector2(rX, rY + rH);
                if (CircleToLine(cPosition, cRadius, edgeFrom, edgeTo))
                {
                    return(true);
                }
            }

            if ((sector & PointSectors.Right) != 0)
            {
                edgeFrom = new Vector2(rX + rW, rY);
                edgeTo   = new Vector2(rX + rW, rY + rH);
                if (CircleToLine(cPosition, cRadius, edgeFrom, edgeTo))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        public T CollideFirst <T>(Vector2 at) where T : Entity
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Entity type");
            }
#endif
            return(Collide.First(this, Scene.Tracker.Entities[typeof(T)], at) as T);
        }
Ejemplo n.º 7
0
        public List <T> CollideAll <T>() where T : Entity
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Entity type");
            }
#endif

            return(Collide.All(this, Scene.Tracker.Entities[typeof(T)]) as List <T>);
        }
Ejemplo n.º 8
0
        public List <Entity> CollideAll <T>(Vector2 at, List <Entity> into) where T : Entity
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Entity type");
            }
#endif

            into.Clear();
            return(Collide.All(this, Scene.Tracker.Entities[typeof(T)], into, at));
        }
Ejemplo n.º 9
0
        public Entity CollideFirstOutside(BitTag tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif

            foreach (var entity in Scene[tag])
            {
                if (!Collide.Check(this, entity) && Collide.Check(this, entity, at))
                {
                    return(entity);
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
        public bool CollideCheckOutside(int tag, Vector2 at)
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against a tag list when it is not a member of a Scene");
            }
#endif

            foreach (var entity in Scene[tag])
            {
                if (!Collide.Check(this, entity) && Collide.Check(this, entity, at))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 11
0
        public T CollideFirstOutsideByComponent <T>(Vector2 at) where T : Component
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Components.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Component type");
            }
#endif

            foreach (var component in Scene.Tracker.Components[typeof(T)])
            {
                if (!Collide.Check(this, component.Entity) && Collide.Check(this, component.Entity, at))
                {
                    return(component as T);
                }
            }
            return(null);
        }
Ejemplo n.º 12
0
        public bool CollideCheckByComponent <T>() where T : Component
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Component type");
            }
#endif

            foreach (var c in Scene.Tracker.Components[typeof(T)])
            {
                if (Collide.Check(this, c.Entity))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 13
0
        public bool CollideCheckOutside <T>(Vector2 at) where T : Entity
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Entities.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Entity type");
            }
#endif

            foreach (var entity in Scene.Tracker.Entities[typeof(T)])
            {
                if (!Collide.Check(this, entity) && Collide.Check(this, entity, at))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 14
0
        public List <T> CollideAllByComponent <T>() where T : Component
        {
#if DEBUG
            if (Scene == null)
            {
                throw new Exception("Can't collide check an Entity against tracked Entities when it is not a member of a Scene");
            }
            else if (!Scene.Tracker.Components.ContainsKey(typeof(T)))
            {
                throw new Exception("Can't collide check an Entity against an untracked Component type");
            }
#endif

            List <T> list = new List <T>();
            foreach (var component in Scene.Tracker.Components[typeof(T)])
            {
                if (Collide.Check(this, component.Entity))
                {
                    list.Add(component as T);
                }
            }
            return(list);
        }
Ejemplo n.º 15
0
 public bool CollideCheck(Entity other, Vector2 at)
 {
     return(Collide.Check(this, other, at));
 }
Ejemplo n.º 16
0
 public bool CollideCheck(CollidableComponent other, Vector2 at)
 {
     return(Collide.Check(this, other, at));
 }
Ejemplo n.º 17
0
 public bool CollideCheckOutside(Entity other, Vector2 at)
 {
     return(!Collide.Check(this, other) && Collide.Check(this, other, at));
 }
Ejemplo n.º 18
0
 public bool CollidePoint(Vector2 point, Vector2 at)
 {
     return(Collide.CheckPoint(this, point, at));
 }
Ejemplo n.º 19
0
 public bool CollideCheck <T>(Vector2 at) where T : Entity
 {
     return(Collide.Check(this, Scene.Tracker.Entities[typeof(T)], at));
 }
Ejemplo n.º 20
0
 public bool CollideCheck(CollidableComponent other)
 {
     return(Collide.Check(this, other));
 }
Ejemplo n.º 21
0
 public bool CollideCheck(Entity other)
 {
     return(Collide.Check(this, other));
 }
Ejemplo n.º 22
0
 public bool CollideRect(Rectangle rect, Vector2 at)
 {
     return(Collide.CheckRect(this, rect, at));
 }
Ejemplo n.º 23
0
 public bool CollideLine(Vector2 from, Vector2 to, Vector2 at)
 {
     return(Collide.CheckLine(this, from, to, at));
 }