<commit_before>﻿//
// Method IntersectPixels used under Microsoft Permissive License (Ms-PL). (http://create.msdn.com/downloads/?id=15)
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTengine.Core;
using TTengine.Comps;
using TTengine.Util;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Game1.Behaviors;
using Game1.Actors;
using TreeSharp;
using Artemis;
using Artemis.Interface;

namespace Game1.Comps
{
    public enum Faction { GOOD, EVIL };

    public class ThingComp: IComponent
    {
        public bool Active = true;
        public bool Visible = true;

        public Color Color = Color.White;

        public Faction Faction = Faction.GOOD;

        public List<ThingComp> Children = new List<ThingComp>();

        /// <summary>
        /// this ThingComp can be attached to a parent ThingComp, if null then not attached.
        /// </summary>
        public ThingComp Parent = null;

        /// <summary>
        /// if true can pass anything
        /// </summary>
        public bool IsCollisionFree = true;

        /// <summary>
        /// Determines what intensity levels of background pixel color this ThingComp can pass.
        /// Intensity is the sum of R,G,B bytes of pixel. Any background pixel at threshold value or
        /// brighter is passable for this ThingComp.
        /// </summary>
        public int PassableIntensityThreshold;

        /// <summary>
        /// position in the level, in pixels, in sub-pixel resolution
        /// </summary>
        public Vector2 Position = Vector2.Zero;

        /// <summary>
        /// if attached to a parent, the position relative to parent where it is
        /// attached
        /// </summary>
        public Vector2 AttachmentPosition = Vector2.Zero;

        /// <summary>
        /// Position.X as a rounded integer
        /// </summary>
        public int PositionX
        {
            get { return (int)Math.Round(Position.X); }
            set { Position.X = (float)value; }
        }

        /// <summary>
        /// Position.Y as a rounded integer
        /// </summary>
        public int PositionY
        {
            get { return (int)Math.Round(Position.Y); }
            set { Position.Y = (float)value; }
        }


        /// <summary>
        /// Target.X as a rounded integer
        /// </summary>
        public int TargetX
        {
            get { return (int)Math.Round(Target.X); }
            set { Target.X = (float)value; }
        }

        /// <summary>
        /// Target.Y as a rounded integer
        /// </summary>
        public int TargetY
        {
            get { return (int)Math.Round(Target.Y); }
            set { Target.Y = (float)value; }
        }

        /// <summary>
        /// position in the level, in pixels, where the entity's Position should move towards in a smooth fashion
        /// </summary>
        public Vector2 Target = Vector2.Zero;

        /// <summary>
        /// a direction (if any) the Thing is facing towards e.g. up (0,-1), down (0,1) or right (1,0).
        /// </summary>
        public Vector2 FacingDirection = new Vector2(1f, 0f);

        /// <summary>
        /// to set both Position and Target in one go
        /// </summary>
        public Vector2 PositionAndTarget
        {
            set
            {
                Position = value;
                Target = value;
                TTutil.Round(ref Position);
                TTutil.Round(ref Target);
            }
        }

        private Rectangle boundingRectangle = new Rectangle();

        /// <summary>
        /// the bounding rectangle of the sprite of this Thing, based on Position
        /// </summary>
        protected Rectangle BoundingRectangle
        {
            get {
                boundingRectangle.X = PositionX; 
                boundingRectangle.Y = PositionY; 
                return boundingRectangle; 
            }
        }

        public void SetBoundingRectangleWidthHeight(int width, int height)
        {
            boundingRectangle.Width = width;
            boundingRectangle.Height = height;
        }

        /// <summary>
        /// a 'relative to normal' velocity-of-moving factor i.e. 1f == normal velocity
        /// </summary>
        public float Velocity = 1f;

        /// <summary>
        /// relative speed of the smooth motion for moving towards Target. Linear speed defined for Velocity==1.
        /// </summary>
        public float TargetSpeed = 10f;

        /// <summary>
        /// the Toy that is carried by and active for this ThingComp, or null if none
        /// </summary>
        public Toy ToyActive = null;

        // used for the collision detection per-pixel
        protected Color[] textureData;<commit_msg>tidied up<commit_after>﻿//
// Method IntersectPixels used under Microsoft Permissive License (Ms-PL). (http://create.msdn.com/downloads/?id=15)
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTengine.Core;
using TTengine.Comps;
using TTengine.Util;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Game1.Behaviors;
using Game1.Actors;
using TreeSharp;
using Artemis;
using Artemis.Interface;

namespace Game1.Comps
{
    public enum Faction { GOOD, EVIL };

    public class ThingComp: IComponent
    {
        public bool Active = true;
        public bool Visible = true;

        public Color Color = Color.White;

        public Faction Faction = Faction.GOOD;

        /// <summary>
        /// other Things can be attached to this Thing: the Children.
        /// </summary>
        public List<ThingComp> Children = new List<ThingComp>();

        /// <summary>
        /// this Thing can be attached to a parent Thing, if null then not attached.
        /// </summary>
        public ThingComp Parent = null;

        /// <summary>
        /// if true can pass anything without colliding
        /// </summary>
        public bool IsCollisionFree = true;

        /// <summary>
        /// Determines what intensity levels of background pixel color this ThingComp can pass.
        /// Intensity is the sum of R,G,B bytes of pixel. Any background pixel at threshold value or
        /// brighter is passable for this ThingComp.
        /// </summary>
        public int PassableIntensityThreshold;

        /// <summary>
        /// position in the level, in pixels, in sub-pixel resolution
        /// </summary>
        public Vector2 Position = Vector2.Zero;

        /// <summary>
        /// if attached to a parent, the position relative to parent where it is
        /// attached
        /// </summary>
        public Vector2 AttachmentPosition = Vector2.Zero;

        /// <summary>
        /// Position.X as a rounded integer
        /// </summary>
        public int PositionX
        {
            get { return (int)Math.Round(Position.X); }
            set { Position.X = (float)value; }
        }

        /// <summary>
        /// Position.Y as a rounded integer
        /// </summary>
        public int PositionY
        {
            get { return (int)Math.Round(Position.Y); }
            set { Position.Y = (float)value; }
        }

        /// <summary>
        /// Target.X as a rounded integer
        /// </summary>
        public int TargetX
        {
            get { return (int)Math.Round(Target.X); }
            set { Target.X = (float)value; }
        }

        /// <summary>
        /// Target.Y as a rounded integer
        /// </summary>
        public int TargetY
        {
            get { return (int)Math.Round(Target.Y); }
            set { Target.Y = (float)value; }
        }

        /// <summary>
        /// position in the level, in pixels, where the entity's Position should move towards in a smooth fashion
        /// </summary>
        public Vector2 Target = Vector2.Zero;

        /// <summary>
        /// a direction (if any) the Thing is facing towards e.g. up (0,-1), down (0,1) or right (1,0).
        /// </summary>
        public Vector2 FacingDirection = new Vector2(1f, 0f);

        /// <summary>
        /// to set both Position and Target in one go
        /// </summary>
        public Vector2 PositionAndTarget
        {
            set
            {
                Position = value;
                Target = value;
                TTutil.Round(ref Position);
                TTutil.Round(ref Target);
            }
        }

        private Rectangle boundingRectangle = new Rectangle();

        /// <summary>
        /// the bounding rectangle of the sprite of this Thing, based on Position
        /// </summary>
        protected Rectangle BoundingRectangle
        {
            get {
                boundingRectangle.X = PositionX; 
                boundingRectangle.Y = PositionY; 
                return boundingRectangle; 
            }
        }

        /// <summary>
        /// Set width and height of the bounding rectangle of this Thing
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void SetBoundingRectangleWidthHeight(int width, int height)
        {
            boundingRectangle.Width = width;
            boundingRectangle.Height = height;
        }

        /// <summary>
        /// a 'relative to normal' velocity-of-moving factor i.e. 1f == normal velocity
        /// </summary>
        public float Velocity = 1f;

        /// <summary>
        /// relative speed of the smooth motion for moving towards Target. Linear speed defined for Velocity==1.
        /// </summary>
        public float TargetSpeed = 10f;

        /// <summary>
        /// the Toy that is carried by and active for this Thing, or null if none
        /// </summary>
        public Toy ToyActive = null;

        // used for the collision detection per-pixel
        protected Color[] textureData;
{'fraction_non_alphanumeric': 0.10675228253235677, 'fraction_numerical': 0.005417879000702318, 'mean_word_length': 1.6293853864415722, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3841880', 'n_tokens_mistral': 2672, 'n_tokens_neox': 2532, 'n_words': 867}