Пример #1
0
        /// <summary>
        /// Called when an occupant is leaving a room owned by this zone, and entering a room owned by a different zone.
        /// </summary>
        /// <param name="roomOccupancyChange">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param>
        void OnLeftZone(RoomOccupancyChangedEventArgs roomOccupancyChange)
        {
            EventHandler <ZoneOccupancyChangedEventArgs> handler = this.LeftZone;

            if (handler == null)
            {
                return;
            }

            handler(this, new ZoneOccupancyChangedEventArgs(this, roomOccupancyChange));
        }
Пример #2
0
        /// <summary>
        /// Called when an occupant has left one of the rooms that this zone owns.
        /// </summary>
        /// <para>
        /// This method will check if the occupant leaving the room is entering a room in a different zone other than this instance.
        /// If so, then the LeftZone event is raised.
        /// </para>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param>
        void OccupantLeftRoom(object sender, RoomOccupancyChangedEventArgs e)
        {
            // Not sure what happened during travel, but the occupant does not have an arrival room.
            // So we don't do anything or the occupant is just traveling around within our zone, so we ignore it.
            if (e.ArrivalRoom == null || e.ArrivalRoom.Owner == this)
            {
                return;
            }

            this.OnLeftZone(e);
        }
Пример #3
0
        public void Args_throw_exception_with_null_departure_room()
        {
            // Arrange
            var arrival         = Mock.Of <IRoom>();
            var character       = Mock.Of <ICharacter>();
            var travelDirection = Mock.Of <ITravelDirection>();

            // Act
            var eventArgs = new RoomOccupancyChangedEventArgs(
                character,
                travelDirection,
                null,
                arrival);
        }
Пример #4
0
        public void Args_throw_exception_with_null_travel_direction()
        {
            // Arrange
            var departure = Mock.Of <IRoom>();
            var arrival   = Mock.Of <IRoom>();
            var character = Mock.Of <ICharacter>();

            // Act
            var eventArgs = new RoomOccupancyChangedEventArgs(
                character,
                null,
                departure,
                arrival);
        }
Пример #5
0
        /// <summary>
        /// Called when an occupant has entered one of the rooms that this zone owns.
        /// </summary>
        /// <para>
        /// This method will check if the occupant entering the room is entering a room in this zone for the first time.
        /// If so, then the EnteredZone event is raised.
        /// </para>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MudDesigner.MudEngine.Environment.RoomOccupancyChangedEventArgs" /> instance containing the event data.</param>
        void OccupantEnteredRoom(object sender, RoomOccupancyChangedEventArgs e)
        {
            // The occupant is entering our zone for the first time.
            if (e.DepartureRoom == null)
            {
                this.OnEnteredZone(e);
                return;
            }

            // The occupant is moving around within our zone already.
            if (e.DepartureRoom.Owner == this)
            {
                return;
            }

            this.OnEnteredZone(e);
        }
Пример #6
0
        public void Event_arg_is_instanced_with_valid_properties()
        {
            // Arrange
            var departure       = Mock.Of <IRoom>();
            var arrival         = Mock.Of <IRoom>();
            var character       = Mock.Of <ICharacter>();
            var travelDirection = Mock.Of <ITravelDirection>();

            // Act
            var eventArgs = new RoomOccupancyChangedEventArgs(
                character,
                travelDirection,
                departure,
                arrival);

            // Assert
            Assert.IsNotNull(eventArgs.Occupant, "Occupant was null.");
            Assert.IsNotNull(eventArgs.TravelDirection, "TravelDirection was null.");
            Assert.IsNotNull(eventArgs.ArrivalRoom, "ArrivalRoom was null.");
            Assert.IsNotNull(eventArgs.DepartureRoom, "DepartureRoom was null.");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoneOccupancyChangedEventArgs"/> class.
 /// </summary>
 /// <param name="zone">The zone.</param>
 /// <param name="roomOccupancyChange">The <see cref="RoomOccupancyChangedEventArgs"/> instance containing the event data.</param>
 public ZoneOccupancyChangedEventArgs(IZone zone, RoomOccupancyChangedEventArgs roomOccupancyChange) 
     : base(roomOccupancyChange.Occupant, roomOccupancyChange.TravelDirection, roomOccupancyChange.DepartureRoom, roomOccupancyChange.ArrivalRoom)
 {
     this.AffectedZone = zone;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoneOccupancyChangedEventArgs"/> class.
 /// </summary>
 /// <param name="zone">The zone.</param>
 /// <param name="roomOccupancyChange">The <see cref="RoomOccupancyChangedEventArgs"/> instance containing the event data.</param>
 public ZoneOccupancyChangedEventArgs(IZone zone, RoomOccupancyChangedEventArgs roomOccupancyChange)
     : base(roomOccupancyChange.Occupant, roomOccupancyChange.TravelDirection, roomOccupancyChange.DepartureRoom, roomOccupancyChange.ArrivalRoom)
 {
     this.AffectedZone = zone;
 }