// // Mates.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections; using System.Collections.Concurrent; using NosSmooth.Game.Data.Characters; namespace NosSmooth.Game.Data.Mates; /// /// Game mates state. /// public class Mates : IEnumerable { private ConcurrentDictionary _partners; private ConcurrentDictionary _pets; /// /// Initializes a new instance of the class. /// public Mates() { _partners = new ConcurrentDictionary(); _pets = new ConcurrentDictionary(); } /// /// Gets all of the partners belonging to the character. /// public IEnumerable Partners => _partners.Values; /// /// Gets all of the pets belonging to the character. /// public IEnumerable Pets => _pets.Values; /// /// Gets the current skill of pet, if there is any. /// public Skill? PetSkill { get; internal set; } /// /// Get sthe current skills of partner(' sp). /// public IReadOnlyList? PartnerSkills { get; internal set; } /// /// Gets the current pet of the client. /// public PartyPet? CurrentPet { get; internal set; } /// /// Gets the current partner of the client. /// public PartyPartner? CurrentPartner { get; internal set; } /// public IEnumerator GetEnumerator() => _partners.Values.Cast().Concat(_pets.Values.Cast()).GetEnumerator(); /// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); /// /// Sets pet of the given id. /// /// The pet. internal void SetPet(Pet pet) { _pets[pet.MateId] = pet; } /// /// Sets partner of the given id. /// /// The partner. internal void SetPartner(Partner partner) { _partners[partner.MateId] = partner; } /// /// Clears partners and pets. /// internal void Clear() { _partners.Clear(); _pets.Clear(); } }