InFront() public static method

public static InFront ( Unit unit, Unit target, float distance ) : System.Vector3
unit Unit face
target Unit where
distance float
return System.Vector3
Exemplo n.º 1
0
        public static void Unit_OnModifierAdded(Unit sender, ModifierChangedEventArgs args)
        {
            if (_inTp)
            {
                return;
            }
            var name = args.Modifier.Name;

            if (name.Contains("teleporting"))
            {
                //Printer.Print($"{sender.Name}: teleporting");
                if (sender.ClassID == ClassID.CDOTA_Unit_Hero_Tinker)
                {
                    _teleportCaster = sender;
                }
            }
            else if (name.Contains("modifier_boots_of_travel_incoming"))
            {
                //Printer.Print($"{sender.Name}: boots");
                if (sender.Team == Members.MyTeam)
                {
                    DelayAction.Add(new DelayActionItem(100, () =>
                    {
                        if (_teleportCaster != null)
                        {
                            var blink = Members.MyHero.FindItem("item_blink", true);
                            if (blink != null)
                            {
                                var effect =
                                    sender.AddParticleEffect("materials/ensage_ui/particles/range_display_mod.vpcf");
                                var lense = Members.MyHero.FindItem("item_aether_lens", true);
                                var range = 1150 + (lense != null ? 200 : 0);
                                effect.SetControlPoint(0, sender.Position);
                                effect.SetControlPoint(1, new Vector3(range, 255, 0));
                                effect.SetControlPoint(2, new Vector3(255, 255, 255));
                                Members.TowerRangEffectHelper.AddEffect(sender, effect);
                                //if (sender is Building)
                                //{
                                effect =
                                    sender.AddParticleEffect("materials/ensage_ui/particles/line.vpcf");
                                var frontPoint = Helper.InFront(Members.MyHero, sender, range);
                                effect.SetControlPoint(1, sender.Position);
                                effect.SetControlPoint(2, frontPoint);
                                effect.SetControlPoint(3, new Vector3(255, 50, 0));
                                effect.SetControlPoint(4, new Vector3(255, 255, 255));
                                Members.TowerRangEffectHelper2.AddEffect(sender, effect, range);
                                //}
                                _inTp = true;
                            }
                        }
                    }, CancellationToken.None));
                }
            }
        }
        public void AddEffect(Unit target, ParticleEffect eff, float range)
        {
            var            handle = target.Handle;
            ParticleEffect effect;

            if (!_effectDictionary.TryGetValue(handle, out effect))
            {
                _effectDictionary.Add(handle, eff);
                Printer.Print($"[{_name}][NewEffect]: {target.Name}");
                Game.OnUpdate += args =>
                {
                    if (!Game.IsInGame)
                    {
                        return;
                    }
                    try
                    {
                        if (eff == null || !eff.IsValid || eff.IsDestroyed)
                        {
                            return;
                        }
                        if (target.HasModifier("modifier_boots_of_travel_incoming"))
                        {
                            RemoveEffect(target);
                            return;
                        }
                        var frontPoint = Helper.InFront(Members.MyHero, target, range);
                        eff.SetControlPoint(1, target.Position);
                        eff.SetControlPoint(2, frontPoint);
                    }
                    catch (Exception)
                    {
                    }
                };
            }
            else
            {
                effect.Dispose();
                _effectDictionary.Remove(handle);
                AddEffect(target, eff);
                Printer.Print($"[{_name}][Remove&NewEffect]: {target.Name}");
            }
        }