/// <summary> /// Fires the event. /// </summary> /// <param name="sender"> /// The sender /// </param> /// <param name="args"> /// The event data /// </param> private static void FireEvent(Obj_AI_Base sender, TeleportEventArgs args) { if (OnTeleport != null) { OnTeleport(sender, args); } }
/// <summary> /// OnTeleport event. /// </summary> /// <param name="sender"> /// The sender /// </param> /// <param name="args"> /// The event data /// </param> private static void OnTeleportEvent(Obj_AI_Base sender, GameObjectTeleportEventArgs args) { var eventArgs = new TeleportEventArgs { Status = TeleportStatus.Unknown, Type = TeleportType.Unknown }; if (sender == null || !sender.IsValid) { FireEvent(sender, 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); 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(sender, eventArgs); }
/// <summary> /// Fires the event. /// </summary> /// <param name="sender"> /// The sender /// </param> /// <param name="args"> /// The event data /// </param> private static void FireEvent(Obj_AI_Base sender, TeleportEventArgs args) { OnTeleport?.Invoke(sender, args); }