public SingleTagRenderer(BitTag tag) { Tag = tag; BlendState = BlendState.AlphaBlend; SamplerState = SamplerState.LinearClamp; Camera = new Camera(); }
/// <summary> /// Quick access to entire tag lists of Entities. Result will never be null /// </summary> /// <param name="tag">The tag list to fetch</param> /// <returns></returns> public List <Entity> this[BitTag tag] { get { return(TagLists[tag.ID]); } }
public bool CollideDo(BitTag tag, Action <Entity> action, 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 bool hit = false; var was = Position; Position = at; foreach (var other in Scene[tag]) { if (CollideCheck(other)) { action(other); hit = true; } } Position = was; return(hit); }
public List <Entity> CollideAll(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.All(this, Scene[tag])); }
public Entity CollideFirst(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.First(this, Scene[tag], at)); }
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); }
public Entity Closest(BitTag tag) { var list = Scene[tag]; Entity closest = null; float dist; if (list.Count >= 1) { closest = list[0]; dist = Vector2.DistanceSquared(Position, closest.Position); for (int i = 1; i < list.Count; i++) { float current = Vector2.DistanceSquared(Position, list[i].Position); if (current < dist) { closest = list[i]; dist = current; } } } return(closest); }