public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_Room = (Room)reader.ReadInt(); }
public ExperimentalRoomBlocker( Room room ) : base(7107) { m_Room = room; Visible = false; Movable = false; }
void OnRoomEmpty(object sender, Room e) { e.OnEmpty -= OnRoomEmpty; Rooms.Remove(e); }
public ExperimentalRoomDoor( Room room, DoorFacing facing ) : base(facing) { m_Room = room; }
public async Task ProcessPackage(User user, RoomCreatePackage package) { var room = new Room(); room.Name = package.Name; mServer.Rooms.TryAdd(room.ID, room); var result = new RoomCreatePackage(); result.ID = room.ID; await mServer.ClientListener.Send(user, result); }
void IConnectionMessageHandler.HandleMessage(Player player, string json) { Message.IsType<ClientMessage.RequestRoomList>(json, (data) => { Logger.Log(this, "Recieved a request from {0} for a list a rooms.", player); var rooms = Rooms.Select(x => x.RoomData).ToList(); player.SendMessage(new ServerMessage.RoomList(rooms)); }); Message.IsType<ClientMessage.JoinRoom>(json, (data) => { Logger.Log(this, "Recieved a request from {0} to join room {1}.", player.Data, data.RoomId); var roomHasPlayer = Rooms.Find(x => x.HasPlayer(player.Data)); if (roomHasPlayer != null) roomHasPlayer.Leave(player.Data); var targetRoom = Rooms.Find(x => x.RoomData.ID == data.RoomId); if (targetRoom != null) { targetRoom.Join(player, data.Password); } else { player.SendRoomJoinNotice(RoomNotice.RoomDoesNotExist); } }); Message.IsType<ClientMessage.LeaveRoom>(json, (data) => { var containingRoom = Rooms.Find(x => x.HasPlayer(player.Data)); if (containingRoom != null) { Logger.Log(this, "Remove {0} from room", player); containingRoom.Leave(player.Data); } else { Logger.Warn(this, "Cannot remove {0} from room as they are not in that room", player); } }); Message.IsType<ClientMessage.CreateRoom>(json, (data) => { if (Rooms.Count != SettingsLoader.Values.Server.MaxRooms) { Logger.Log(this, "Create room for {0} with password {1}", player, data.Password); var playerCurrentRoom = FindRoomContainingPlayer(player.Data); if (playerCurrentRoom != null) playerCurrentRoom.Leave(player.Data); var room = new Room(ConnectionsHandler, player, SettingsLoader, data.Password); room.OnEmpty += OnRoomEmpty; Rooms.Add(room); } else { Logger.Log(this, "Cannot create room for {0} as the maximum room limit has been reached", player); player.SendRoomJoinNotice(RoomNotice.MaxRoomsLimitReached); } }); }
public ExperimentalGem() : base(6463) { m_LastIndex = -1; m_IsExtremeHue = false; m_CurrentHue = Neutral; m_CurrentRoom = Room.RoomZero; m_Active = false; m_Expire = DateTime.MaxValue; m_Span = 0; m_Completed = 0; m_ToComplete = 0; Hue = Neutral; }
private void Reset() { if(m_Timer != null) { m_Timer.Stop(); m_Timer = null; } m_Complete = false; m_Completed = 0; m_ToComplete = 0; m_IsExtremeHue = false; m_Active = false; m_CurrentRoom = Room.RoomOne; m_LastIndex = -1; m_Expire = DateTime.MaxValue; m_CurrentHue = Neutral; Hue = Neutral; InvalidateProperties(); }
private void CompletePuzzle(Mobile m) { if(m_Timer != null) { m_Timer.Stop(); m_Timer = null; } m_Complete = true; Hue = Neutral; m_CurrentHue = Hue; m_CurrentRoom = Room.RoomFour; }
public void Activate(Mobile from) { m_Active = true; StartTimer(); m_CurrentRoom = Room.RoomOne; m_ToComplete = Utility.RandomMinMax(5, 8); Timer.DelayCall(TimeSpan.FromSeconds(5), new TimerCallback(BeginRoom_Callback)); from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1113405); // Your gem is now active. You may enter the Experimental Room. InvalidateProperties(); }
public void CloseMeeting(string topic, string coordinatorUsername) { Server.freezeHandle.WaitOne(); // For Freeze command this.Delay(); // For induced delay #region Validate arguments if (topic == null || topic == "") { throw new ApplicationException("Topic cannot be empty!"); } else if (coordinatorUsername == null || coordinatorUsername == "") { throw new ApplicationException("You don't have a username!"); } else if (Server.meetingPropList.Where(mp => mp.Topic == topic).Count() == 0) { throw new ApplicationException("Topic does not exist!"); } else if (Server.clients.Where(c => c.Username == coordinatorUsername).Count() == 0) { throw new ApplicationException("You are not registered in the server!"); } #endregion foreach (MeetingProposal mp in Server.meetingPropList) { //Closing wanted meeting and client closing is coordinator and meeting is not yet closed if (mp.Topic == topic && mp.CoordinatorUsername == coordinatorUsername) { //Causal and Total Order Check if object is not locked (Mutex) lock (mp.SyncLock) { if (mp.Status == MeetingProposal.StatusEnum.Closed) { throw new ApplicationException("This meeting is already closed!"); } else if (mp.Status == MeetingProposal.StatusEnum.Cancelled) { throw new ApplicationException("This meeting is cancelled!"); } else if (mp.CoordinatorUsername != coordinatorUsername) { throw new ApplicationException("You are not the coordinator of this meeting!"); } else if (mp.ClientsJoined == null || mp.ClientsJoined.Count < mp.MinAttendees) { int numJoinedClients = (mp.ClientsJoined != null ? mp.ClientsJoined.Count : 0); throw new ApplicationException($"Min. attendees is {mp.MinAttendees}, but only " + $"{numJoinedClients} have joined so far."); } //Get slot that maximizes participant count uint nClients, maxClients = 0; Slot maxClientsSlot = Slot.FromString("empty,2000-1-1"); Room maxGlobalCapacityRoom = new Room("empty", 0), maxLocalCapacityRoom; foreach (Slot slot in mp.ClientPerSlot.Keys) { //Skip room search if if (mp.ClientPerSlot[slot].Count() < maxClients) { continue; } //Get max capacity room that is available on slot location if (Server.locationRooms[slot.location].Count() > 0) { //Get max capacity room that is available maxLocalCapacityRoom = new Room("empty", 0); foreach (Room room in Server.locationRooms[slot.location]) { if (!room.bookedDates.Contains(slot.date) && room.Capacity >= maxLocalCapacityRoom.Capacity) { maxLocalCapacityRoom = room; } } //Ignore this slot since no room is available if (maxLocalCapacityRoom.Capacity == 0) { continue; } //Set nClients as number of possible participants in this location if ((uint)mp.ClientPerSlot[slot].Count() > maxLocalCapacityRoom.Capacity) { nClients = maxLocalCapacityRoom.Capacity; } else { nClients = (uint)mp.ClientPerSlot[slot].Count(); } if (nClients > maxClients) { //Set max participant number, slot and room maxClients = nClients; maxClientsSlot = slot; maxGlobalCapacityRoom = maxLocalCapacityRoom; } } } //no valid slot was found, clients want slots with no room available if (maxClients == 0) { mp.Status = MeetingProposal.StatusEnum.Cancelled; Console.WriteLine("Meeting Cancelled."); throw new ApplicationException("No room is available, Meeting was cancelled."); } //Booking, updating values in meeting maxGlobalCapacityRoom.bookedDates.Add(maxClientsSlot.date); mp.BookedSlot = maxClientsSlot; mp.BookedRoom = maxGlobalCapacityRoom; mp.Status = MeetingProposal.StatusEnum.Closed; //Only add clients to meeting up to max room size uint del = maxClients; foreach (string clientName in mp.ClientPerSlot[maxClientsSlot]) { if (del-- == 0) { break; } mp.ClientsAccepted[clientName] = mp.ClientsJoined[clientName]; } //Inform all replicas of meeting state Thread threadS = new Thread(() => Server.InformAllServersOfMeetingState(mp)); threadS.Start(); //Inforam all clients Thread thread = new Thread(() => Server.InformAllClientsOfMeetingState(mp)); thread.Start(); Console.WriteLine("Meeting Booked with: " + mp.ClientsAccepted.Keys.Count + " Clients, in Slot: " + mp.BookedSlot.location + " " + mp.BookedSlot.date + " " + " and in Room: " + mp.BookedRoom.Name); } } } }