Beispiel #1
0
 private void OnTeleport(object sender, TeleportEventArgs e)
 {
     if (sender != null)
     {
          Console.WriteLine("{0} recalled!", ((Obj_AI_Base)sender).CharData.BaseSkinName);
     }
 }
Beispiel #2
0
        /// <summary>
        ///     OnTeleport event.
        /// </summary>
        /// <param name="sender">
        ///     The sender
        /// </param>
        /// <param name="args">
        ///     The event data
        /// </param>
        private static void EventTeleport(Obj_AI_Base sender, GameObjectTeleportEventArgs args)
        {
            var eventArgs = new TeleportEventArgs {
                Status = TeleportStatus.Unknown, Type = TeleportType.Unknown
            };

            if (sender == null || !sender.IsValid)
            {
                FireEvent(eventArgs);
                return;
            }

            if (!TeleportDataByNetworkId.ContainsKey(sender.NetworkId))
            {
                TeleportDataByNetworkId[sender.NetworkId] = eventArgs;
            }

            if (!string.IsNullOrEmpty(args.RecallType))
            {
                ITeleport value;
                if (TypeByString.TryGetValue(args.RecallType, out value))
                {
                    var teleportMethod = value;

                    eventArgs.Status   = TeleportStatus.Start;
                    eventArgs.Duration = teleportMethod.GetDuration(args);
                    eventArgs.Type     = teleportMethod.Type;
                    eventArgs.Start    = Variables.TickCount;
                    eventArgs.IsTarget = teleportMethod.IsTarget(args);
                    eventArgs.Object   = sender;

                    TeleportDataByNetworkId[sender.NetworkId] = eventArgs;
                }
                else
                {
                    Console.WriteLine(
                        @"Teleport type {0} with name {1} is not supported yet. Please report it!",
                        args.RecallType,
                        args.RecallName);
                }
            }
            else
            {
                eventArgs = TeleportDataByNetworkId[sender.NetworkId];
                var shorter = Variables.TickCount - eventArgs.Start < eventArgs.Duration - ErrorBuffer;
                eventArgs.Status = shorter ? TeleportStatus.Abort : TeleportStatus.Finish;
            }

            FireEvent(eventArgs);
        }
        /// <summary>
        ///     OnTeleport event.
        /// </summary>
        /// <param name="sender">
        ///     The sender
        /// </param>
        /// <param name="args">
        ///     The event data
        /// </param>
        private static void EventTeleport(Obj_AI_Base sender, GameObjectTeleportEventArgs args)
        {
            var eventArgs = new TeleportEventArgs { Status = TeleportStatus.Unknown, Type = TeleportType.Unknown };

            if (sender == null || !sender.IsValid)
            {
                FireEvent(eventArgs);
                return;
            }

            if (!TeleportDataByNetworkId.ContainsKey(sender.NetworkId))
            {
                TeleportDataByNetworkId[sender.NetworkId] = eventArgs;
            }

            if (!string.IsNullOrEmpty(args.RecallType))
            {
                ITeleport value;
                if (TypeByString.TryGetValue(args.RecallType, out value))
                {
                    var teleportMethod = value;

                    eventArgs.Status = TeleportStatus.Start;
                    eventArgs.Duration = teleportMethod.GetDuration(args);
                    eventArgs.Type = teleportMethod.Type;
                    eventArgs.Start = Variables.TickCount;
                    eventArgs.IsTarget = teleportMethod.IsTarget(args);
                    eventArgs.Object = sender;

                    TeleportDataByNetworkId[sender.NetworkId] = eventArgs;
                }
                else
                {
                    Console.WriteLine(
                        @"Teleport type {0} with name {1} is not supported yet. Please report it!",
                        args.RecallType,
                        args.RecallName);
                }
            }
            else
            {
                eventArgs = TeleportDataByNetworkId[sender.NetworkId];
                var shorter = Variables.TickCount - eventArgs.Start < eventArgs.Duration - ErrorBuffer;
                eventArgs.Status = shorter ? TeleportStatus.Abort : TeleportStatus.Finish;
            }

            FireEvent(eventArgs);
        }
Beispiel #4
0
 /// <summary>
 ///     Fires the event.
 /// </summary>
 /// <param name="args">
 ///     The event data
 /// </param>
 private static void FireEvent(TeleportEventArgs args)
 {
     OnTeleport?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, args);
 }
 /// <summary>
 ///     Fires the event.
 /// </summary>
 /// <param name="args">
 ///     The event data
 /// </param>
 private static void FireEvent(TeleportEventArgs args)
 {
     OnTeleport?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, args);
 }