/// <summary> /// Create new <see cref="Residence"/> for supplied <see cref="Player"/>. /// </summary> public static Residence CreateResidence(Player player) { var residence = new Residence(player); residences.TryAdd(residence.Id, residence); ownerCache.TryAdd(player.Name, residence.Id); return(residence); }
public static ResidenceEntrance GetResidenceEntrance(Residence residence) { HousingPropertyInfoEntry propertyEntry = GameTableManager.HousingPropertyInfo.GetEntry(residence.PropertyInfoId); if (propertyEntry == null) { throw new HousingException(); } WorldLocation2Entry locationEntry = GameTableManager.WorldLocation2.GetEntry(propertyEntry.WorldLocation2Id); return(new ResidenceEntrance(locationEntry)); }
/// <summary> /// Return existing <see cref="Residence"/> by supplied owner name, if not locally cached it will be retrieved from the database. /// </summary> public static async Task <Residence> GetResidence(string name) { if (ownerCache.TryGetValue(name, out ulong residenceId)) { return(GetResidence(residenceId)); } ResidenceModel model = await CharacterDatabase.GetResidence(name); if (model == null) { return(null); } var residence = new Residence(model); residences.TryAdd(residence.Id, residence); ownerCache.TryAdd(name, residence.Id); return(residence); }
/// <summary> /// Return existing <see cref="Residence"/> by supplied residence id, if not locally cached it will be retrieved from the database. /// </summary> public async Task <Residence> GetResidence(ulong residenceId) { Residence residence = GetCachedResidence(residenceId); if (residence != null) { return(residence); } ResidenceModel model = await CharacterDatabase.GetResidence(residenceId); if (model == null) { return(null); } residence = new Residence(model); residences.TryAdd(residence.Id, residence); ownerCache.TryAdd(model.Owner.Name, residence.Id); return(residence); }
public static void HandleCharacterSelect(WorldSession session, ClientCharacterSelect characterSelect) { CharacterModel character = session.Characters.SingleOrDefault(c => c.Id == characterSelect.CharacterId); if (character == null) { session.EnqueueMessageEncrypted(new ServerCharacterSelectFail { Result = CharacterSelectResult.Failed }); return; } if (PlayerCleanupManager.HasPendingCleanup(session.Account)) { session.EnqueueMessageEncrypted(new ServerCharacterSelectFail { Result = CharacterSelectResult.FailedCharacterInWorld }); return; } session.Player = new Player(session, character); WorldEntry entry = GameTableManager.Instance.World.GetEntry(character.WorldId); if (entry == null) { throw new ArgumentOutOfRangeException(); } switch ((MapType)entry.Type) { case MapType.Residence: case MapType.Community: { // characters logging in to a housing map are returned to their own residence Residence residence = session.Player.ResidenceManager.Residence; residence ??= GlobalResidenceManager.Instance.CreateResidence(session.Player); ResidenceEntrance entrance = GlobalResidenceManager.Instance.GetResidenceEntrance(residence.PropertyInfoId); session.Player.Rotation = entrance.Rotation.ToEulerDegrees(); MapManager.Instance.AddToMap(session.Player, new MapPosition { Info = new MapInfo { Entry = entrance.Entry, InstanceId = residence.Parent?.Id ?? residence.Id }, Position = entrance.Position }); break; } default: { session.Player.Rotation = new Vector3(character.RotationX, character.RotationY, character.RotationZ); MapManager.Instance.AddToMap(session.Player, new MapPosition { Info = new MapInfo { Entry = entry }, Position = new Vector3(character.LocationX, character.LocationY, character.LocationZ) }); break; } } }
/// <summary> /// Create a new <see cref="ResidenceManager"/>. /// </summary> public ResidenceManager(Player player) { owner = player; Residence = GlobalResidenceManager.Instance.GetResidenceByOwner(owner.CharacterId); }