/// <summary> /// Create a new <see cref="ZoneMapManager"/> from supplied <see cref="MapZoneEntry"/>. /// </summary> public ZoneMap(MapZoneEntry mapZone, Player owner) { player = owner; entry = mapZone; width = (ushort)(mapZone.HexLimX - mapZone.HexMinX + 1); height = (ushort)(mapZone.HexLimY - mapZone.HexMinY + 1); ushort wh = (ushort)(width * height); size = (ushort)((wh % 8u > 0u ? 8u : 0u) + wh); maxHexGroups = (ushort)GameTableManager.Instance.MapZoneHexGroup.Entries.Count(m => m.MapZoneId == entry.Id); zoneMapBits = new NetworkBitArray(size, NetworkBitArray.BitOrder.LeastSignificantBit); }
/// <summary> /// Invoked when <see cref="Player"/> moves to a new zone. /// </summary> public void OnZoneUpdate() { // maybe there is a more efficient lookup method @sub_1406FB130 - this works for all zones though WorldZoneEntry worldZoneEntry = player.Zone; MapZoneEntry zoneMap = null; do { if (worldZoneEntry == null) { break; } zoneMap = GameTableManager.Instance.MapZone.Entries.FirstOrDefault(m => m.WorldZoneId == worldZoneEntry.Id); if (zoneMap != null) { break; } worldZoneEntry = GameTableManager.Instance.WorldZone.GetEntry(worldZoneEntry.ParentZoneId); }while (worldZoneEntry != null); if (zoneMap == null) { MapZoneWorldJoinEntry mapZoneWorldJoin = GameTableManager.Instance.MapZoneWorldJoin.Entries.FirstOrDefault(m => m.WorldId == player.Map.Entry.Id); if (mapZoneWorldJoin != null) { zoneMap = GameTableManager.Instance.MapZone.GetEntry(mapZoneWorldJoin.MapZoneId); } } if (zoneMap == null) { currentZoneMap = 0; return; } if (zoneMap.Id == currentZoneMap) { return; } if (!zoneMaps.ContainsKey((ushort)zoneMap.Id)) { zoneMaps.Add((ushort)zoneMap.Id, new ZoneMap(zoneMap, player)); } currentZoneMap = (ushort)zoneMap.Id; }
/// <summary> /// Create a new <see cref="ZoneMapManager"/> from existing <see cref="Character"/> database model. /// </summary> public ZoneMapManager(Player owner, Character characterModel) { player = owner; foreach (CharacterZonemapHexgroup hexGroupModel in characterModel.CharacterZonemapHexgroup) { if (!zoneMaps.TryGetValue(hexGroupModel.ZoneMap, out ZoneMap zoneMap)) { MapZoneEntry entry = GameTableManager.Instance.MapZone.GetEntry(hexGroupModel.ZoneMap); zoneMap = new ZoneMap(entry, player); zoneMaps.Add(hexGroupModel.ZoneMap, zoneMap); } zoneMap.AddHexGroup(hexGroupModel.HexGroup, false); } }