Пример #1
0
        private static void RPC_PlayerAddedPin(long sender, Vector3 pos, string type, string name, string player)
        {
            Plugin.logger.LogDebug($"{nameof(RPC_PlayerAddedPin)}: {player} shared {name} at ({pos.x},{pos.z})");
            if (Settings.SharePinsWithOtherPlayers.Value)
            {
                Minimap.PinType pinType = (Minimap.PinType)Enum.Parse(typeof(Minimap.PinType), type);

                if (Player.m_localPlayer.GetPlayerID() == sender)
                {
                    return;
                }
                var pins = Minimap.instance.GetPrivateField <List <Minimap.PinData> >("m_pins");
                if (Plugin.SimilarPinExists(pos, pinType, pins, out Minimap.PinData match))
                {
                    if (match.m_name != name)
                    {
                        Plugin.AddString($"{player} changed the name pin: \"{match.m_name}\" at ({Mathf.RoundToInt(pos.x)}, {Mathf.RoundToInt(pos.y)}) to {name}.");
                        match.m_name = name;
                    }
                }
                else
                {
                    Plugin.AddString($"{player} added pin: \"{name}\" at ({Mathf.RoundToInt(pos.x)}, {Mathf.RoundToInt(pos.y)}).");
                    Minimap.instance.AddPin(pos, pinType, name, true, false);
                }
            }
        }
 public static bool SimilarPinExists(
     Vector3 pos,
     Minimap.PinType type,
     List <Minimap.PinData> pins,
     string aName,
     Sprite aIcon,
     out Minimap.PinData match)
 {
     foreach (Minimap.PinData pin in pins)
     {
         if (pos == pin.m_pos)
         {
             match = pin;
             return(true);
         }
         else
         //Mod.Log.LogInfo(string.Format("[AMP] Checking Distance between Pins {0} & {1}: {2}", aName, pin.m_name, (double)Utils.DistanceXZ(pos, pin.m_pos)));
         if ((double)Utils.DistanceXZ(pos, pin.m_pos) < pinOverlapDistance.Value &&
             type == pin.m_type &&
             (aName == pin.m_name || aIcon == pin.m_icon))
         {
             //Mod.Log.LogInfo(string.Format("[AMP] Duplicate pins for {0} found", aName));
             match = pin;
             return(true);
         }
     }
     match = null;
     return(false);
 }
Пример #3
0
 public bool HaveSimilarPin(Vector3 pos, Minimap.PinType type, string name, bool save)
 {
     if (_mm == null)
     {
         return(false);
     }
     return((bool)reflected_HaveSimilarPin.Invoke(_mm, new object[] { pos, type, name, save }));
 }
Пример #4
0
 public static Minimap.PinData AddPin(Minimap instance, Vector3 pos,
                                      Minimap.PinType type,
                                      string name,
                                      bool save,
                                      bool isChecked,
                                      long owner)
 {
     throw new NotImplementedException();
 }
Пример #5
0
        public static void AddSinglePin(Vector3 position, Minimap.PinType pinType, string name)
        {
            // Check for exisiting pin
            MethodInfo dynMethod       = Minimap.instance.GetType().GetMethod("HaveSimilarPin", BindingFlags.NonPublic | BindingFlags.Instance);
            bool       haveSimiliarPin = (bool)dynMethod.Invoke(Minimap.instance, new object[] { position, pinType, name, true });

            if (!haveSimiliarPin)
            {
                Minimap.instance.AddPin(position, pinType, name, true, false);
            }
        }
Пример #6
0
 public static void AddPin(ref Minimap __instance)
 {
     Minimap.PinType pintype  = iconSelected.value == 4 ? Minimap.PinType.Icon4 : (Minimap.PinType)iconSelected.value;
     Minimap.PinData addedPin = __instance.AddPin(pinPos, pintype, pinName.text, true, false);
     if (Configuration.Current.Map.shareablePins && sharePin.isOn && !Configuration.Current.Map.shareAllPins)
     {
         VPlusMapPinSync.SendMapPinToServer(addedPin);
     }
     pinEditorPanel.SetActive(false);
     __instance.m_wasFocused = false;
 }
 private static bool Minimap_AddPin(
     ref Minimap __instance,
     List <Minimap.PinData> ___m_pins,
     Vector3 pos,
     Minimap.PinType type,
     string name,
     bool save,
     bool isChecked)
 {
     return(((type != Minimap.PinType.Death ? 0 : (Mod.SimilarPinExists(pos, type, ___m_pins, name, PinnedObject.aIcon, out Minimap.PinData _) ? 1 : 0)) & (save ? 1 : 0)) == 0);
 }
Пример #8
0
        /// <summary>
        ///     Create PinData objects without adding them to the map directly
        /// </summary>
        public static Minimap.PinData CreatePinData(Vector3 pos, Minimap.PinType type, string name, bool save, bool isChecked)
        {
            var pinData = new Minimap.PinData();

            pinData.m_type    = type;
            pinData.m_name    = name;
            pinData.m_pos     = pos;
            pinData.m_icon    = Minimap.instance.GetSprite(type);
            pinData.m_save    = save;
            pinData.m_checked = isChecked;
            return(pinData);
        }
Пример #9
0
 public static bool SimilarPinExists(Vector3 pos, Minimap.PinType type, List <Minimap.PinData> pins, out Minimap.PinData match)
 {
     foreach (Minimap.PinData pinData in pins)
     {
         if (Utils.DistanceXZ(pos, pinData.m_pos) < Settings.SharedPinOverlapDistance.Value && type == pinData.m_type)
         {
             match = pinData;
             return(true);
         }
     }
     match = null;
     return(false);
 }
Пример #10
0
 public static Minimap.PinData CreatePin(
     Vector3 pos,
     Minimap.PinType type,
     string name,
     bool save,
     bool isChecked)
 {
     Minimap.PinData pinData = new Minimap.PinData();
     pinData.m_type    = type;
     pinData.m_name    = name;
     pinData.m_pos     = pos;
     pinData.m_save    = save;
     pinData.m_checked = isChecked;
     return(pinData);
 }
Пример #11
0
 public static void Minimap_AddPin_Prefix(ref Minimap __instance, Vector3 pos, Minimap.PinType type, string name, bool save, bool isChecked)
 {
     LogManager.Instance.Log(BepInEx.Logging.LogLevel.Info, $"[AddPin] {pos} {type} {name} {save} {isChecked}");
 }
Пример #12
0
 private static bool Minimap_AddPin(ref Minimap __instance, List <Minimap.PinData> ___m_pins, Vector3 pos, Minimap.PinType type, string name, bool save, bool isChecked)
 {
     // Skip readding stacked death markers
     if (type == Minimap.PinType.Death && Plugin.SimilarPinExists(pos, type, ___m_pins, out var match) && save)
     {
         return(false);
     }
     return(true);
 }