/// <summary> /// Trick the server into sending waypoints to the client even if they don't have their map opened. /// Credit to Novocain. /// </summary> /// <param name="mapManager">The map manager.</param> public static void ForceSendWaypoints(this WorldMapManager mapManager) { var capi = mapManager.GetField <ICoreClientAPI>("capi"); capi.Event.EnqueueMainThreadTask(() => capi.Event.RegisterCallback(dt => mapManager.GetField <IClientNetworkChannel>("clientChannel") .SendPacket(new OnViewChangedPacket()), 500), ""); }
// For some reason, this won't work as an extension method. private void PurgeWaypoints(System.Func <Waypoint, bool> comparer) { TyronThreadPool.QueueTask(() => { var wpLayer = _mapManager.WaypointMapLayer(); var waypoints = new List <int>(); for (var i = 0; i < wpLayer.ownWaypoints.Count; i++) { if (comparer(wpLayer.ownWaypoints[i])) { waypoints.Add(i); } } waypoints.Sort((a, b) => b.CompareTo(a)); foreach (var num in waypoints) { Api.Event.EnqueueMainThreadTask(() => Api.SendChatMessage($"/waypoint remove {num}"), ""); } Api.Event.EnqueueMainThreadTask(() => Api.Event.RegisterCallback(dt => _mapManager.GetField <IClientNetworkChannel>("clientChannel") .SendPacket(new OnViewChangedPacket()), 500), ""); }); }