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; }
public static void RemovePinEqual(PinData needle) { foreach (var pin in ServerPins.ToList()) { if (UtilityPin.ArePinsEqual(pin, needle)) { ServerPins.Remove(pin); } } }
public static void SetPinState(PinData needle, bool state) { foreach (var pin in ServerPins.ToList()) { if (UtilityPin.ArePinsEqual(pin, needle)) { pin.Checked = state; } } }
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); }
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); }
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); }
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); } }
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); }
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); } }
public static void AddPin(PinData pin) { ServerPins.Add(pin); }
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)); }
public static bool ArePinsDupes(Minimap.PinData pin1, PinData pin2, float radius) { return(Utils.DistanceXZ(pin1.m_pos, pin2.Pos) < radius); }
public static bool ArePinsEqual(PinData pin1, PinData pin2) { return(pin1.Name == pin2.Name && pin1.Type == pin2.Type && pin1.Pos.Equals(pin2.Pos)); }