Example #1
0
        public void ProcessEffect(IEffectParameter parameter)
        {
            INonPlayerCharacter nonPlayerCharacter = parameter.Performer as INonPlayerCharacter;

            if (nonPlayerCharacter != null &&
                (HoursToLoad == null || HoursToLoad.Contains(GlobalReference.GlobalValues.GameDateTime.GameDateTime.Hour)))
            {
                IRoom room;
                if (RoomId != null)
                {
                    try
                    {
                        room = GlobalReference.GlobalValues.World.Zones[RoomId.Zone].Rooms[RoomId.Id];
                    }
                    catch
                    {
                        //invalid room passed
                        return;
                    }
                }
                else
                {
                    room = parameter.Target as IRoom;
                    if (room == null)
                    {
                        //target is not a room so we can't load the mob;
                        return;
                    }
                }

                //clone it so we don't keep using the same mob instance
                nonPlayerCharacter = (INonPlayerCharacter)nonPlayerCharacter.Clone();
                room.AddMobileObjectToRoom(nonPlayerCharacter);
                nonPlayerCharacter.Room = room;
                nonPlayerCharacter.FinishLoad();

                if (parameter.RoomMessage != null)
                {
                    GlobalReference.GlobalValues.Notify.Room(nonPlayerCharacter, null, room, parameter.RoomMessage);
                }
            }
        }