예제 #1
0
        public static void SetMapData(ZPackage mapData)
        {
            ServerPins.Clear();

            var version = mapData.ReadInt();
            var mapSize = mapData.ReadInt();

            var explored = new bool[mapSize * mapSize];

            for (var i = 0; i < mapSize * mapSize; i++)
            {
                explored[i] = mapData.ReadBool();
            }

            var pinCount = mapData.ReadInt();

            for (var i = 0; i < pinCount; i++)
            {
                var pin = new PinData
                {
                    Name    = mapData.ReadString(),
                    Pos     = mapData.ReadVector3(),
                    Type    = (Minimap.PinType)mapData.ReadInt(),
                    Checked = mapData.ReadBool()
                };
                ServerPins.Add(pin);
            }

            Explored = explored;
        }
예제 #2
0
 public static void RemovePinEqual(PinData needle)
 {
     foreach (var pin in ServerPins.ToList())
     {
         if (UtilityPin.ArePinsEqual(pin, needle))
         {
             ServerPins.Remove(pin);
         }
     }
 }
예제 #3
0
 public static void SetPinState(PinData needle, bool state)
 {
     foreach (var pin in ServerPins.ToList())
     {
         if (UtilityPin.ArePinsEqual(pin, needle))
         {
             pin.Checked = state;
         }
     }
 }
예제 #4
0
        public static PinData UnpackPin(ZPackage z)
        {
            var pin = new PinData
            {
                Name    = z.ReadString(),
                Pos     = z.ReadVector3(),
                Type    = (Minimap.PinType)z.ReadInt(),
                Checked = z.ReadBool()
            };

            return(pin);
        }
예제 #5
0
        public static Minimap.PinData GetMapPin(PinData needle)
        {
            var pins = Traverse.Create(_Minimap._instance).Field("m_pins").GetValue() as List <Minimap.PinData>;

            foreach (var pin in pins)
            {
                if (ArePinsEqual(needle, pin))
                {
                    return(pin);
                }
            }
            return(null);
        }
예제 #6
0
        public static ZPackage PackPin(PinData pin, bool skipSetPos = false)
        {
            var z = new ZPackage();

            z.Write(pin.Name);
            z.Write(pin.Pos);
            z.Write((int)pin.Type);
            z.Write(pin.Checked);
            if (!skipSetPos)
            {
                z.SetPos(0);
            }
            return(z);
        }
예제 #7
0
        public static void RemovePinFromServer(PinData pin)
        {
            if (!Store.IsSharingPin())
            {
                return;
            }

            var data = ExplorationDatabase.PackPin(pin);

            ExplorationDatabase.ClientPins.Remove(pin);

            if (!_ZNet.IsServer(_ZNet._instance))
            {
                _ZNet.GetServerRPC(_ZNet._instance).Invoke("OnClientRemovePin", data);
            }
            else
            {
                OnClientRemovePin(null, data);
            }
        }
예제 #8
0
        public static List <PinData> UnpackPins(ZPackage z)
        {
            var pins = new List <PinData>();

            var pinCount = z.ReadInt();

            for (var i = 0; i < pinCount; i++)
            {
                var pin = new PinData
                {
                    Name    = z.ReadString(),
                    Pos     = z.ReadVector3(),
                    Type    = (Minimap.PinType)z.ReadInt(),
                    Checked = z.ReadBool()
                };
                pins.Add(pin);
            }

            return(pins);
        }
예제 #9
0
        public static void CheckPinOnServer(PinData pin, bool state)
        {
            if (!Store.IsSharingPin())
            {
                return;
            }

            var data = ExplorationDatabase.PackPin(pin, true);

            data.Write(state);
            data.SetPos(0);

            if (!_ZNet.IsServer(_ZNet._instance))
            {
                _ZNet.GetServerRPC(_ZNet._instance).Invoke("OnClientCheckPin", data);
            }
            else
            {
                OnClientCheckPin(null, data);
            }
        }
예제 #10
0
 public static void AddPin(PinData pin)
 {
     ServerPins.Add(pin);
 }
예제 #11
0
 public static bool ArePinsEqual(PinData pin1, Minimap.PinData pin2)
 {
     return(pin1.Name == pin2.m_name && pin1.Type == pin2.m_type && pin1.Pos.Equals(pin2.m_pos));
 }
예제 #12
0
 public static bool ArePinsDupes(Minimap.PinData pin1, PinData pin2, float radius)
 {
     return(Utils.DistanceXZ(pin1.m_pos, pin2.Pos) < radius);
 }
예제 #13
0
 public static bool ArePinsEqual(PinData pin1, PinData pin2)
 {
     return(pin1.Name == pin2.Name && pin1.Type == pin2.Type && pin1.Pos.Equals(pin2.Pos));
 }