<commit_before>﻿using PowerArgs.Cli;
using PowerArgs.Cli.Physics;
using System;
using System.Collections.Generic;

namespace PowerArgs.Games
{

    public class SniperRifleHitEventArgs
    {
        public SniperRifle Rifle { get; set; }
        public SpacialElement ElementHit { get; set; }
    }

    public class SniperRifle : Weapon
    {
        public static Event<SniperRifle> OnMiss { get; private set; } = new Event<SniperRifle>();
        public static Event<SniperRifleHitEventArgs> OnHit { get; private set; } = new Event<SniperRifleHitEventArgs>();

        public override WeaponStyle Style => WeaponStyle.Primary;
        public override void FireInternal()
        {
            if (Holder.Target != null)
            {
                DamageBroker.Instance.ReportImpact(new Impact()
                {
                    HitType = HitType.Obstacle,
                    ObstacleHit = Holder.Target,
                    MovingObject= Holder,
                    Angle = Holder.CalculateAngleTo(Holder.Target)
                });
                OnHit.Fire(new SniperRifleHitEventArgs() { Rifle = this, ElementHit = Holder.Target });
            }
            else
            {
                OnMiss.Fire(this);
            }
        }
    }

    public class AimLineOptions
    {
        public IRectangularF From { get; set; }
        public IRectangularF To { get; set; }
        public ILifetimeManager LifetimeManager { get; set; }
        public int Z { get; set; } = -34543;
    }



    public class AimLineSegment : SpacialElement
    {
        public AimLineSegment(int z, ConsoleCharacter pen)
        {
            this.Pen = pen;
            this.ResizeTo(1, 1);
            this.MoveTo(0, 0, z);
        }
    }

    [SpacialElementBinding(typeof(AimLineSegment))]
    public class AimLineSegmentRenderer : SpacialElementRenderer
    {
        protected override void OnPaint(ConsoleBitmap context) => context.DrawPoint((Element as AimLineSegment).Pen.Value, 0, 0);
    }

    public class AimLineHandle
    {
        private List<AimLineSegment> elements;
        public AimLineHandle(List<AimLineSegment> elements)
        {
            this.elements = elements;
        }
    }

    public static class AimLine
    {
        public const char DefaultWireChar = '.';

        public static AimLineHandle Connect(AimLineOptions options)
        {
            var aimLineSegments = new List<AimLineSegment>();

            var d = Geometry.CalculateDistanceTo(options.From, options.To) - 1;
            var angle = options.From.CalculateAngleTo(options.To);
            for (var i = 1; i < d; i++)
            {
                var location = options.From.MoveTowards(angle, Geometry.NormalizeQuantity(i,angle,true));
                var segment = SpaceTime.CurrentSpaceTime.Add(new AimLineSegment(options.Z, new ConsoleCharacter(DefaultWireChar, ConsoleColor.Cyan)));
                segment.MoveTo(location.Left, location.Top);
                aimLineSegments.Add(segment);
            }

            options.LifetimeManager.OnDisposed(() =>
            {
                foreach (var segment in aimLineSegments)
                {
                    segment.Lifetime.Dispose();
                }
            });
<commit_msg>char change<commit_after>﻿using PowerArgs.Cli;
using PowerArgs.Cli.Physics;
using System;
using System.Collections.Generic;

namespace PowerArgs.Games
{

    public class SniperRifleHitEventArgs
    {
        public SniperRifle Rifle { get; set; }
        public SpacialElement ElementHit { get; set; }
    }

    public class SniperRifle : Weapon
    {
        public static Event<SniperRifle> OnMiss { get; private set; } = new Event<SniperRifle>();
        public static Event<SniperRifleHitEventArgs> OnHit { get; private set; } = new Event<SniperRifleHitEventArgs>();

        public override WeaponStyle Style => WeaponStyle.Primary;
        public override void FireInternal()
        {
            if (Holder.Target != null)
            {
                DamageBroker.Instance.ReportImpact(new Impact()
                {
                    HitType = HitType.Obstacle,
                    ObstacleHit = Holder.Target,
                    MovingObject= Holder,
                    Angle = Holder.CalculateAngleTo(Holder.Target)
                });
                OnHit.Fire(new SniperRifleHitEventArgs() { Rifle = this, ElementHit = Holder.Target });
            }
            else
            {
                OnMiss.Fire(this);
            }
        }
    }

    public class AimLineOptions
    {
        public bool IsHot { get; set; }
        public IRectangularF From { get; set; }
        public IRectangularF To { get; set; }
        public ILifetimeManager LifetimeManager { get; set; }
        public int Z { get; set; } = -34543;
    }



    public class AimLineSegment : SpacialElement
    {
        public AimLineSegment(int z, ConsoleCharacter pen)
        {
            this.Pen = pen;
            this.ResizeTo(1, 1);
            this.MoveTo(0, 0, z);
        }
    }

    [SpacialElementBinding(typeof(AimLineSegment))]
    public class AimLineSegmentRenderer : SpacialElementRenderer
    {
        protected override void OnPaint(ConsoleBitmap context) => context.DrawPoint((Element as AimLineSegment).Pen.Value, 0, 0);
    }

    public class AimLineHandle
    {
        private List<AimLineSegment> elements;
        public AimLineHandle(List<AimLineSegment> elements)
        {
            this.elements = elements;
        }
    }

    public static class AimLine
    {
        public const char DefaultWireChar = '-';

        public static AimLineHandle Connect(AimLineOptions options)
        {
            var aimLineSegments = new List<AimLineSegment>();

            var d = Geometry.CalculateDistanceTo(options.From, options.To) - 1;
            var angle = options.From.CalculateAngleTo(options.To);
            for (var i = 1; i < d; i++)
            {
                var location = options.From.MoveTowards(angle, Geometry.NormalizeQuantity(i,angle,true));
                var segment = SpaceTime.CurrentSpaceTime.Add(new AimLineSegment(options.Z, new ConsoleCharacter(DefaultWireChar, options.IsHot ? ConsoleColor.Cyan : ConsoleColor.Gray)));
                segment.MoveTo(location.Left, location.Top);
                aimLineSegments.Add(segment);
            }

            options.LifetimeManager.OnDisposed(() =>
            {
                foreach (var segment in aimLineSegments)
                {
                    segment.Lifetime.Dispose();
                }
            });

{'fraction_non_alphanumeric': 0.08770864946889226, 'fraction_numerical': 0.0039453717754172985, 'mean_word_length': 1.9073665637406263, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6975124', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1734, 'n_words': 396}