public static void OnServerCheckPin(ZRpc client, ZPackage data) { if (!Store.IsSharingPin()) { return; } data.SetPos(0); Utility.Log("Client checked pin by server"); var pin = ExplorationDatabase.UnpackPin(data); var state = data.ReadBool(); foreach (var clientPin in ExplorationDatabase.ClientPins.ToList()) { if (UtilityPin.ArePinsEqual(clientPin, pin)) { clientPin.Checked = state; var mapPin = UtilityPin.GetMapPin(clientPin); if (mapPin != null) { mapPin.m_checked = state; } } } }
public static void OnServerRemovePin(ZRpc _, ZPackage pinData) { if (!Store.IsSharingPin()) { return; } pinData.SetPos(0); Utility.Log("Client deleted pin by server"); var pin = ExplorationDatabase.UnpackPin(pinData); foreach (var clientPin in ExplorationDatabase.ClientPins.ToList()) { if (UtilityPin.ArePinsEqual(clientPin, pin)) { ExplorationDatabase.ClientPins.Remove(clientPin); } } var mapPin = UtilityPin.GetMapPin(pin); if (mapPin == null) { return; } _Minimap.RemovePin(_Minimap._instance, mapPin); }
// ReSharper disable once InconsistentNaming private static bool Prefix(Chat __instance, InputField ___m_input) { string text = ___m_input.text; if (text.ToLower().Equals("/convertpins ignorelocaldupes")) { UtilityPin.UploadAllPins(true); return(false); } if (text.ToLower().Equals("/convertpins")) { UtilityPin.UploadAllPins(); return(false); } if (text.ToLower().Equals("/deletealllocalpins")) { UtilityPin.DeleteLocalPins(); return(false); } if (text.ToLower().Equals("/downloadpins")) { UtilityPin.DownloadPins(); return(false); } return(true); }
private static void SendPinsToServer(ZRpc client) { var pins = Traverse.Create(_Minimap._instance).Field("m_pins").GetValue() as List <Minimap.PinData>; var filteredPins = new List <PinData>(); foreach (var pin in pins) { if (pin.m_save) { filteredPins.Add(UtilityPin.ConvertPin(pin)); } } var z = ExplorationDatabase.PackPins(filteredPins); if (client == null) { OnClientInitialDataPin(null, z); } else { var znet = Traverse.Create(typeof(ZNet)).Field("m_instance").GetValue() as ZNet; var server = _ZNet.GetServerRPC(znet); server.Invoke("OnClientInitialDataPin", (object)z); } }
public static void SetPinState(PinData needle, bool state) { foreach (var pin in ServerPins.ToList()) { if (UtilityPin.ArePinsEqual(pin, needle)) { pin.Checked = state; } } }
public static void RemovePinEqual(PinData needle) { foreach (var pin in ServerPins.ToList()) { if (UtilityPin.ArePinsEqual(pin, needle)) { ServerPins.Remove(pin); } } }
// ReSharper disable once InconsistentNaming private static void Postfix(Player __instance) { if (Store.HasKeyConvertAll() && Input.GetKeyDown(Store.GetKeyConvertAll())) { Utility.Log("Hotkey: GetKeyConvertAll"); UtilityPin.UploadAllPins(false); } if (Store.HasKeyConvertIgnoreDupes() && Input.GetKeyDown(Store.GetKeyConvertIgnoreDupes())) { Utility.Log("Hotkey: GetKeyConvertIgnoreDupes"); UtilityPin.UploadAllPins(true); } }
// ReSharper disable once InconsistentNaming private static void Postfix(Minimap __instance) { if (LatestClosestPin == null) { return; } var clientPin = UtilityPin.GetClientPin(LatestClosestPin); if (clientPin == null) { return; } RemovePinFromServer(clientPin); }
// ReSharper disable once InconsistentNaming private static void Postfix(Minimap __instance) { if (LatestClosestPin == null) { return; } var clientPin = UtilityPin.GetClientPin(LatestClosestPin); if (clientPin == null) { return; } clientPin.Checked = LatestClosestPin.m_checked; CheckPinOnServer(clientPin, clientPin.Checked); }
private static void ClientAppendPins() { if (!Store.IsSharingPin()) { return; } Utility.Log("ClientAppendPins " + ExplorationDatabase.ClientPins.Count); foreach (var pin in ExplorationDatabase.ClientPins) { var mapPin = UtilityPin.GetMapPin(pin); if (mapPin != null) { _Minimap.RemovePin(_Minimap._instance, mapPin); } _Minimap.AddPin(_Minimap._instance, pin.Pos, pin.Type, pin.Name, false, pin.Checked, 0); } }
// ReSharper disable once InconsistentNaming private static void Postfix(Minimap __instance, ref Minimap.PinData __result, Vector3 pos, float radius) { if (!Store.IsSharingPin()) { return; } LatestClosestPin = __result; var pinData = (PinData)null; var num1 = 999999f; foreach (var p in ExplorationDatabase.ClientPins) { var num2 = Utils.DistanceXZ(pos, p.Pos); if ((double)num2 < (double)radius && ((double)num2 < (double)num1 || pinData == null)) { pinData = p; num1 = num2; } } if (pinData == null) { return; } var pin = UtilityPin.GetMapPin(pinData); if (__result == null) { __result = pin; LatestClosestPin = pin; return; } var distance = Utils.DistanceXZ(pos, __result.m_pos); if (distance > num1) { __result = pin; LatestClosestPin = pin; } }
public static void UploadAllPins(bool removeDupes = false) { var pins = Traverse.Create(_Minimap._instance).Field("m_pins").GetValue() as List <Minimap.PinData>; foreach (var pin in pins.ToList()) { if (!pin.m_save) { continue; } if (removeDupes && LocalPinIsDupe(pin)) { continue; } PinSync.SendPinToServer(pin, false); var pin1 = UtilityPin.ConvertPin(pin); _Minimap.AddPin(_Minimap._instance, pin1.Pos, pin1.Type, pin1.Name, false, pin1.Checked, 0); ExplorationDatabase.ClientPins.Add(pin1); } }
public static void SendPinToServer(Minimap.PinData pin, bool deletePin = true) { if (!Store.IsSharingPin()) { return; } var convertedPin = UtilityPin.ConvertPin(pin); var data = ExplorationDatabase.PackPin(convertedPin); pin.m_save = !deletePin && pin.m_save; ExplorationDatabase.ClientPins.Add(convertedPin); if (!_ZNet.IsServer(_ZNet._instance)) { _ZNet.GetServerRPC(_ZNet._instance).Invoke("OnClientAddPin", data); } else { OnClientAddPin(null, data); } }