protected override void Handle(Client client, AtPacket packet) { if (client.Character == null) { return; } Character character = client.Character; if (packet.CharacterId != character.Id) { return; } Map map = _mapFactory.CreateMap(packet.MapId); Map source = character.Map; bool mapChange = character.Map == null || character.Map.Id != packet.MapId; map.AddEntity(character); character.Position = new Position(packet.PositionX, packet.PositionY); if (mapChange) { _eventManager.Emit(new MapChangeEvent(client) { Character = client.Character, Source = source, Destination = map }); } }
protected override void Handle(Client client, CMapPacket packet) { if (!packet.IsBaseMap) { _logger.Debug("Is base map"); return; } Map destination = _mapFactory.CreateMap(packet.MapId); if (client.Character.Map?.Id == destination.Id) { return; } Map source = client.Character.Map; destination.AddEntity(client.Character); if (source != null) { _eventManager.Emit(new MapChangeEvent(client) { Character = client.Character, Source = source, Destination = destination }); } }
public void Map_Factory_Create_Correct_Map() { Map map = _mapFactory.CreateMap(1); Check.That(map).IsNotNull(); Check.That(map.Id).Is(1); Check.That(map.Name).Is("NosVille"); Check.That(map.Height).Is <short>(180); Check.That(map.Width).Is <short>(160); }
/// <summary> /// Initializes maps with startup values like mobs, npc, areas, obelisks etc. /// </summary> private void InitMaps() { _mapDefinitions = _mapsLoader.LoadMapDefinitions(); foreach (var mapDefinition in _mapDefinitions.Maps) { var config = _mapsLoader.LoadMapConfiguration(mapDefinition.Id); if (mapDefinition.CreateType == CreateType.Default) { config.Obelisks = _mapsLoader.GetObelisks(mapDefinition.Id); var map = _mapFactory.CreateMap(mapDefinition.Id, mapDefinition, config); if (Maps.TryAdd(mapDefinition.Id, map)) { _logger.LogInformation($"Map {map.Id} was successfully loaded."); } } } }
/// <summary> /// Initializes maps with startup values like mobs, npc, areas, obelisks etc. /// </summary> private void InitMaps() { _mapDefinitions = _mapsLoader.LoadMapDefinitions(); foreach (var mapDefinition in _mapDefinitions.Maps) { var config = _mapsLoader.LoadMapConfiguration(mapDefinition.Id); if (mapDefinition.CreateType == CreateType.Default) { var map = _mapFactory.CreateMap(mapDefinition.Id, mapDefinition, config, _mapsLoader.GetObelisks(mapDefinition.Id)); map.GameWorld = this; if (Maps.TryAdd(mapDefinition.Id, map)) { _logger.LogInformation("Map {id} was successfully loaded.", map.Id); } } AvailableMapIds.Add(mapDefinition.Id); } }
protected override void Handle(Client client, CMapPacket packet) { if (!packet.IsBaseMap) { _logger.Debug("Is base map"); return; } Map destination = _mapFactory.CreateMap(packet.MapId); if (client.Character?.Map?.Id == destination.Id) { return; } Map source = client.Character.Map; destination.AddEntity(client.Character); if (source != null) { _eventManager.Emit(new MapChangeEvent(client) { Character = client.Character, Source = source, Destination = destination }); } Raid raid = client.Character.Raid; if (raid != null && raid.Status == RaidStatus.Successful && !raid.TeleportedAway) { raid.TeleportedAway = true; _eventManager.Emit(new RaidStatusChangedEvent(client) { Raid = raid }); } }
protected override void Process(IClient client, At packet) { IMap map = mapFactory.CreateMap(packet.MapId); if (map == null) { Logger.Error($"Failed to create map {packet.MapId}"); return; } IMap currentMap = client.Character.Map; if (currentMap != null) { eventPipeline.Emit(new MapLeaveEvent(client, currentMap)); } client.Character.Position = packet.Position; client.Character.Direction = packet.Direction; map.AddEntity(client.Character); eventPipeline.Emit(new MapJoinEvent(client, map)); }
public void FileNew() { var dialog = _newFileDialogFactory(); if (_windowManager.ShowDialog(dialog) != true || dialog.Height <= 0 || dialog.Width <= 0) { return; } _logger.LogInformation("New map [{width};{height}]", dialog.Width, dialog.Height); var tab = _editorTabFactory(); tab.Map = _mapFactory.CreateMap(dialog.Width, dialog.Height); tab.DisplayName = $"Untitled{++untitledIndex}.map"; Items.Add(tab); ActivateItem(tab); if (Items.Count == 1) { NotifyOfPropertyChange(nameof(HasOpenTabs)); } }