private void InvalidateOccupantsCount(bool shouldInvalidate = true) { if (shouldInvalidate) { NumberOfOccupants = Occupants.Count(); } }
public async Task CharacterArrives(Character CharacterObject) { CharacterObject.CurrentXYZ = StorageID; Occupants.Add(new Occupant() { DisplayName = CharacterObject.DisplayName, StorageID = CharacterObject.StorageID }); LastVisited = DateTime.Now; LastVisitedBy = CharacterObject.Name; var soul = CharacterObject.ConvertToSoul(); var nearbyPlayers = GetNearbyPlayers(); var request = JSON.Encode(new { Category = "Events", Type = "CharacterArrives", Soul = soul }); foreach (var player in nearbyPlayers) { await player.SendString(request); } foreach (var occupant in Occupants) { Storage.Current.NPCs.Find(occupant.StorageID)?.CheckAwareness(CharacterObject); } }
//Add a renatal property internal void ListARental() { //To skip the highlighted option SkipButton?.Click(); System.Threading.Thread.Sleep(5000); // Populating the data from Excel ExcelLib.PopulateInCollection(Base.ExcelPath, "AddNewProperty"); OwnersSelect.Click(); System.Threading.Thread.Sleep(5000); PropertiesSelect.Click(); ListRental.Click(); //Value set for adding rental property SelectProperty.SendKeys(ExcelLib.ReadData(10, "RentalPropertyValue")); Title.SendKeys(ExcelLib.ReadData(2, "RentalPropertyValue")); MovingCost.SendKeys(ExcelLib.ReadData(3, "RentalPropertyValue")); RentalDescription.SendKeys(ExcelLib.ReadData(7, "RentalPropertyValue")); RentalTargetRent.SendKeys(ExcelLib.ReadData(4, "RentalPropertyValue")); Furnishing.SendKeys(ExcelLib.ReadData(8, "RentalPropertyValue")); AvailableDate.SendKeys(ExcelLib.ReadData(5, "RentalPropertyValue")); IdealTenant.SendKeys(ExcelLib.ReadData(9, "RentalPropertyValue")); Occupants.SendKeys(ExcelLib.ReadData(6, "RentalPropertyValue")); SaveRental.Click(); IAlert alert = Global.Driver.driver.SwitchTo().Alert(); alert.Accept(); }
protected int GetNextPersonId(List <Person> people) { if (Occupants.Count > 0) { return(Occupants.Select(x => x.Id).Max() + 1); } return(people.Count > 0 ? people.Select(x => x.Id).Max() + 1 : IdSeed); }
/// <summary> /// Removes the character. /// </summary> /// <param name="character">The character.</param> /// <param name="leavingDirection">The leaving direction.</param> public virtual void RemoveCharacter(IMob character, AvailableTravelDirections leavingDirection) { if (Occupants.Contains(character)) { Occupants.Remove(character); OnLeaveEvent(character, leavingDirection); } }
public void Occupy(Token TknOccupant) { Occupants.Add(TknOccupant); TknOccupant.TokenPosition = this.fieldId; if (IsOccupied == true && Occupants.Count > 1) { KillEnemy(); } }
public void AddEntity(Entity entity) { if (entity.Cell != null) { entity.Cell.RemoveEntity(entity); } entity.Cell = this; Occupants.Add(entity); }
public void Depart(Player player) { try { Occupants.Remove(player); } catch { // Player already removed. Continue as normal. } OnPropertyChanged("Occupants"); }
/** * Convenience method to remove the first occurence of the INode with the given Id from the children list. * It will simply defer to RemoveContainedNode(long) method. * * * @return True if removed. False otherwise * @param childId The Id of the INode to remove from the children list */ public bool RemoveChild(long childId) { foreach (INode child in Occupants) { if (child.Id == childId) { Occupants.Remove(child); return(true); } } return(false); }
/// <summary> /// Adds the character. /// </summary> /// <param name="character">The character.</param> /// <param name="entryDirection">The entry direction.</param> public virtual void AddCharacter(IMob character, AvailableTravelDirections entryDirection) { if (Occupants.Contains(character)) { return; } else { Occupants.Add(character); OnEnterEvent(character, entryDirection); } }
public void Arrive(Player player) { if (player.Digit != -1) { // This player is not bankrupt, so they can be added to this tile without problem. Occupants.Add(player); // We've landed on this tile! // Call that abstract void that child classes will implement later. Land(player); OnPropertyChanged("Occupants"); } }
public Tuple <bool, string> AddClient(Client _client) { if (Occupants?.Count < MaxOccupancy) { Occupants?.Add(_client); return(Tuple.Create(true, $"Client with ID : {_client.ClientId} was added to Room with RoomId : {RoomId}")); } if ((bool)Occupants?.Any(occupant => occupant.IsInitiator) && _client.IsInitiator) { Occupants?.Add(_client); return(Tuple.Create(true, $"Client with ID : {_client.ClientId} was added to Room with RoomId : {RoomId} as a participant.")); } return(Tuple.Create(false, $"The Room with ID : {RoomId} has reached MAXIMUM Occupancy of {MaxOccupancy}")); }
public Tuple <bool, string> AddClients(Tuple <Client, Client> _clients) { if (Occupants?.Count < MaxOccupancy && Occupants?.Count + 2 < MaxOccupancy) { Occupants?.AddRange(new List <Client> { _clients.Item1, _clients.Item2 }); return(Tuple.Create(true, $"Clients with IDs : {_clients.Item1.ClientId} and {_clients.Item2.ClientId} were added to Room with RoomId : {RoomId}")); } if ((bool)Occupants?.Any(occupant => occupant.IsInitiator) && _clients.Item1.IsInitiator) { return(Tuple.Create(false, $"Client with ID : {_clients.Item1.ClientId} can't be an Initiator to Room with RoomId : {RoomId}.")); } return(Tuple.Create(false, $"The Room with ID : {RoomId} has reached MAXIMUM Occupancy of {MaxOccupancy}")); }
public Tuple <bool, string> UpdateClient(Client _client) { var isOccupant = IsClientAnOccupant(_client); if (isOccupant.Item1) { var removedCount = (int)Occupants?.RemoveAll(client => client.ClientId == _client.ClientId); if (removedCount > 0) { Occupants.Add(_client); return(Tuple.Create(true, $"Client with ID: {_client.ClientId} was updated")); } return(Tuple.Create(false, $"Client with ID: {_client.ClientId} was not updated")); } return(isOccupant); }
//Used to initialize a building's worker count. Vanilla function converted to be universal and compact. public static void AutoSetWorkers(ushort buildingID, ref Building data, Occupants occupants, short[] workersConfig) { short[][] config; if (VanillaData.LevelAutogenWorkers.TryGetValue(subservice, out config)) { int level = (int)@class.m_level; if (config.GetLength(0) >= level) { int num = config[level][0]; int level0 = config[level][1]; int level1 = config[level][2]; int level2 = config[level][3]; int level3 = config[level][4]; if (num != 0) { var r = new Randomizer((int)buildingID); num = Mathf.Max(200, data.Width * data.Length * num + r.Int32(100u)) / 100; int num2 = level0 + level1 + level2 + level3; if (num2 != 0) { level0 = (num * level0 + r.Int32((uint)num2)) / num2; num -= level0; } num2 = level1 + level2 + level3; if (num2 != 0) { level1 = (num * level1 + r.Int32((uint)num2)) / num2; num -= level1; } num2 = level2 + level3; if (num2 != 0) { level2 = (num * level2 + r.Int32((uint)num2)) / num2; num -= level2; } level3 = num; core.occupants.ModifyWorkers((short)level0, (short)level1, (short)level2, (short)level3); core.occupantsUpdated = true; } } } }
public async Task CharacterLeaves(Character CharacterObject) { var soul = CharacterObject.ConvertToSoul(); var nearbyPlayers = GetNearbyPlayers(); CharacterObject.CurrentXYZ = null; CharacterObject.PreviousXYZ = this.StorageID; Occupants.RemoveAll(occ => occ.StorageID == CharacterObject.StorageID); var request = JSON.Encode(new { Category = "Events", Type = "CharacterLeaves", Soul = soul }); foreach (var player in nearbyPlayers) { await player.SendString(request); } }
/// <summary> /// Add a single occupant to the bay /// </summary> /// <param name="work">The occupant to add</param> /// <param name="onFailure">The optional thing to do if it is not possible to add the occupant</param> public void AddOccupant(Citizen work, Action onFailure = null) => Perform(Occupants.CanHold(1), (onFailure, new PopulationExceedsMaximumException( )), () => Occupants.Add(work));
/// <summary> /// Initialises the room settings using the provided fields. /// </summary> /// <param name="fields">Room fields</param> private void IntialiseRoomSettings(IEnumerable <DataField> fields) { foreach (DataField f in fields) { switch (f.Name) { case MucNs.InfoDescription: Description = f.Values.FirstOrDefault(); break; case MucNs.InfoChangeSubject: canChangeSubject = ConvertToBoolean(f.Values.FirstOrDefault()); break; case MucNs.InfoContactJid: contactAddresses.Add(new Jid(f.Values.FirstOrDefault())); break; case MucNs.InfoCreationDate: CreationDate = ConvertToDateTime(f.Values.FirstOrDefault()); break; case MucNs.InfoSubject: Subject = f.Values.FirstOrDefault(); break; case MucNs.InfoSubjectMod: canChangeSubject = ConvertToBoolean(f.Values.FirstOrDefault()); break; case MucNs.InfoOccupants: NumberOfOccupants = ConvertToInteger(f.Values.FirstOrDefault()); break; case MucNs.InfoLdapGroup: LDAPGroup = f.Values.FirstOrDefault(); break; case MucNs.InfoLanguage: Language = ConvertToCultureInfo(f.Values.FirstOrDefault()); break; case MucNs.InfoLogs: LogUrl = f.Values.FirstOrDefault(); break; case MucNs.InfoPubSub: pubSubNode = f.Values.FirstOrDefault(); break; case MucNs.MaxHistoryFetch: maxHistoryFetch = ConvertToInteger(f.Values.FirstOrDefault()); break; default: break; } } InvalidateOccupantsCount(NumberOfOccupants != Occupants.Count()); }
public void RemoveEntity(Entity entity) { Occupants.Remove(entity); }
public Tuple <bool, string> IsClientAnOccupant(Client _client) => (bool)Occupants?.Any(occupant => occupant.ClientId == _client.ClientId) ? Tuple.Create(true, $"Client with ID : {_client.ClientId} is an Occupant of Room with RoomId : {RoomId}") : Tuple.Create(false, $"The Client with ID : {_client.ClientId} is not an Occupant of the Room with RoomId : {RoomId}");
public void Leave(Token Tknleave) { Occupants.Remove(Tknleave); }
public Tuple <bool, string> RemoveClient(Client _client) => (bool)Occupants?.Remove(_client) ? Tuple.Create(true, $"The Client with ID : {_client.ClientId} was added as an occupant of the Room with RoomId : {RoomId}") : Tuple.Create(false, $"The Client with ID : {_client.ClientId} is not an Occupant of the Room with RoomId : {RoomId}");