public override void NetReceive(BinaryReader reader, bool lightReceive) { //PathOfModifiers.Instance.Logger.Info($"NetReceive: {Main.netMode}"); var newTimeLeft = reader.ReadInt32(); bool isBoundsNull = reader.ReadBoolean(); var newBounds = isBoundsNull ? null : (Rectangle?)reader.ReadRectangle(); mapItem = ItemIO.Receive(reader, true); if (timeLeft == 0 && newTimeLeft != 0) { MapBorder.AddActiveBounds(newBounds.Value); } else if (timeLeft != 0 && newTimeLeft == 0) { MapBorder.RemoveActiveBounds(bounds.Value); } timeLeft = newTimeLeft; bounds = newBounds; if (Main.netMode == NetmodeID.MultiplayerClient) { if (MapDevice.activeMD?.Position == Position) { MapDeviceUI.ShowUI(this); } } }
public override void Load(TagCompound tag) { //PathOfModifiers.Log($"Load{Main.netMode}"); timeLeft = tag.GetInt("timeLeft"); bool isBoundsNull = tag.GetBool("isBoundsNull"); bounds = isBoundsNull ? null : (Rectangle?)tag.Get <Rectangle>("bounds"); if (timeLeft > 0 && bounds.HasValue) { MapBorder.AddActiveBounds(bounds.Value); } mapItem = ItemIO.Load(tag.GetCompound("map")); if (Main.netMode != 2) { MapDeviceUI.Instance.UpdateText(); } }
//Should never run on a client. public void OpenMap() { //PathOfModifiers.Instance.Logger.Info($"OpenMap: {Main.netMode}"); if (!CanOpen()) { return; } //TODO: Set timeLeft somewhere else(map settings/config) timeLeft = 10 * 60 * 60; Items.Map mapModItem = ((Items.Map)mapItem.modItem); Rectangle dimensions = new Rectangle(bounds.Value.X + 1, bounds.Value.Y + 1, bounds.Value.Width - 2, bounds.Value.Height - 2); var map = mapModItem.map; map.Open(dimensions); MapBorder.AddActiveBounds(bounds.Value); SendToClients(); }