/// <summary> /// Performs all the actions every HTE /// </summary> public void PerformAllActions() { // Adding new guests foreach (var item in ArivingGuests) { ((Guest)item).RegisterAs(); item.SetPath(GetArea(typeof(Reception))); HotelMovables.Add(item); } ArivingGuests.Clear(); // Performing all actions lock (HotelMovables) { foreach (IMovable item in HotelMovables) { if (!(item is null)) { item.PerformAction(); } } } // Removing guests that have checked out foreach (var item in LeavingGuests) { HotelMovables.Remove(item); } LeavingGuests.Clear(); }
/// <summary> /// Creates a function hotel /// </summary> /// <param name="layout">A file which contains a functioning layout</param> /// <param name="settings">The Settings for the simulation</param> /// <param name="TypeOfBuilder">A type of builder that can handle the provided file</param> public Hotel(List <JsonModel> layout, SettingsModel settings, IHotelBuilder TypeOfBuilder) { // Hotel will handle the CheckIn_events so it can add them to its list // making it possible to keep the list private HotelEventManager.Register(this); _hotelBuilder = TypeOfBuilder; // Build the hotel HotelAreas = _hotelBuilder.BuildHotel(layout, settings); HotelMovables = _hotelBuilder.BuildMovable(settings, this); // Set calculation properties HotelWidth = HotelAreas.OrderBy(X => X.Position.X).Last().Position.X; HotelHeight = HotelAreas.OrderBy(Y => Y.Position.Y).Last().Position.Y; _elevatorCart = (ElevatorCart)HotelMovables.Find(X => X is ElevatorCart); // Methods for final initialization Dijkstra.IntilazeDijkstra(this); HotelEventManager.Start(); }