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

namespace PowerArgs.Games
{
    public class Projectile : WeaponElement
    {
        public static Event<Impact> OnAudibleImpact { get; private set; } = new Event<Impact>();


        public ConsoleString Pen { get; set; } = new ConsoleString("*", ConsoleColor.Red);
        public float Range { get; set; } = -1;

        public Velocity Velocity { get; private set; }
        public bool PlaySoundOnImpact { get; set; }

        private IRectangularF startLocation;
        private Force force;
        public Projectile(Weapon w, float speed, float angle, bool autoLocate = true) : base(w)
        {
            this.ResizeTo(1, 1);

            if (w?.Holder != null)
            {
                this.MoveTo(w.Holder.EffectiveBounds().CenterX() - Width / 2, w.Holder.EffectiveBounds().CenterY() - Height / 2, w.Holder.ZIndex);
                var offset = this.MoveTowards(angle, 1, false);
                this.MoveTo(offset.Left, offset.Top);
            }

            Time.CurrentTime.InvokeNextCycle(() =>
            {
                    if (autoLocate && w?.Holder != null)
                    {
                        this.MoveTo(w.Holder.EffectiveBounds().CenterX() - Width / 2, w.Holder.EffectiveBounds().CenterY() - Height / 2, w.Holder.ZIndex);
                        var offset = this.MoveTowards(angle, 1, false);
                        this.MoveTo(offset.Left, offset.Top);
                    }
                startLocation = this.Bounds;<commit_msg>projectile uses holder's speed<commit_after>﻿using PowerArgs.Cli;
using PowerArgs.Cli.Physics;
using System;

namespace PowerArgs.Games
{
    public class Projectile : WeaponElement
    {
        public static Event<Impact> OnAudibleImpact { get; private set; } = new Event<Impact>();


        public ConsoleString Pen { get; set; } = new ConsoleString("*", ConsoleColor.Red);
        public float Range { get; set; } = -1;

        public Velocity Velocity { get; private set; }
        public bool PlaySoundOnImpact { get; set; }

        private IRectangularF startLocation;
        private Force force;
        public Projectile(Weapon w, float speed, float angle, bool autoLocate = true) : base(w)
        {
            this.ResizeTo(1, 1);

            if (w?.Holder != null)
            {
                if (w.Holder.Velocity.Angle.DiffAngle(angle) < 45)
                {
                    speed += w.Holder.Velocity.Speed;
                }

                this.MoveTo(w.Holder.EffectiveBounds().CenterX() - Width / 2, w.Holder.EffectiveBounds().CenterY() - Height / 2, w.Holder.ZIndex);
                var offset = this.MoveTowards(angle, 1, false);
                this.MoveTo(offset.Left, offset.Top);
            }

            Time.CurrentTime.InvokeNextCycle(() =>
            {
                    if (autoLocate && w?.Holder != null)
                    {
                        this.MoveTo(w.Holder.EffectiveBounds().CenterX() - Width / 2, w.Holder.EffectiveBounds().CenterY() - Height / 2, w.Holder.ZIndex);
                        var offset = this.MoveTowards(angle, 1, false);
                        this.MoveTo(offset.Left, offset.Top);
                    }
                startLocation = this.Bounds;
{'fraction_non_alphanumeric': 0.11478894624962041, 'fraction_numerical': 0.0060734892195566355, 'mean_word_length': 1.8081841432225063, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '6195436', 'n_tokens_mistral': 962, 'n_tokens_neox': 896, 'n_words': 213}