/// <inheritdoc /> public void Teleport(IPlayerEntity player, int mapId, float x, float?y, float z, float angle = 0) { if (player.Object.MapId != mapId) { IMapInstance destinationMap = _mapManager.GetMap(mapId); if (destinationMap == null) { _logger.LogError($"Cannot find map with id '{mapId}'."); _textPacketFactory.SendSnoop(player, $"Cannot find map with id '{mapId}'."); return; } if (!destinationMap.ContainsPosition(new Vector3(x, 0, z))) { _logger.LogError($"Cannot teleport. Destination position is out of map bounds."); return; } _visibilitySystem.DespawnEntity(player); player.Object.Spawned = false; player.Object.CurrentMap = _mapManager.GetMap(destinationMap.Id); player.Object.MapId = destinationMap.Id; player.Object.LayerId = destinationMap.DefaultMapLayer.Id; // TODO: get map height at x/z position float positionY = y ?? 100; player.Object.Position = new Vector3(x, positionY, z); player.Object.MovingFlags = ObjectState.OBJSTA_STAND; player.Moves.DestinationPosition.Reset(); player.Battle.Reset(); player.Follow.Reset(); _playerPacketFactory.SendPlayerReplace(player); _worldSpawnPacketFactory.SendPlayerSpawn(player); player.Object.Spawned = true; } else { if (!player.Object.CurrentMap.ContainsPosition(new Vector3(x, 0, z))) { _logger.LogError($"Cannot teleport. Destination position is out of map bounds."); return; } // TODO: get map height at x/z position float positionY = y ?? 100; player.Object.Position = new Vector3(x, positionY, z); player.Object.MovingFlags = ObjectState.OBJSTA_STAND; player.Moves.DestinationPosition.Reset(); player.Battle.Reset(); player.Follow.Reset(); } _playerPacketFactory.SendPlayerTeleport(player); }
/// <inheritdoc /> public override void DeleteEntity(IWorldEntity entityToDelete) { base.DeleteEntity(entityToDelete); _visibilitySystem.DespawnEntity(entityToDelete); }