示例#1
0
        /// <summary>
        /// Updates the List of stored InstanceCooldowns, removing the expired ones.
        /// </summary>
        private void RemoveExpiredSoftBindings()
        {
            List <InstanceBinding> binding = m_bindings[0];

            if (binding == null)
            {
                return;
            }
            lock (binding)
            {
                for (int index = binding.Count - 1; index >= 0; --index)
                {
                    InstanceBinding record = binding[index];
                    if (record.BindTime.AddMinutes(InstanceMgr.DungeonExpiryMinutes) > DateTime.Now)
                    {
                        binding.RemoveAt(index);
                        record.DeleteLater();
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Checks the list of stored Raid and Heroic instances and the list of recently run Normal
        /// instances for a reference to the given map.
        /// </summary>
        /// <param name="template">The MapInfo of the Instance in question.</param>
        /// <returns>The Instance if found, else null.</returns>
        public BaseInstance GetActiveInstance(MapTemplate template)
        {
            Character character = Character;

            if (character == null)
            {
                return(null);
            }
            InstanceBinding binding = GetBinding(template.Id,
                                                 template.GetDifficulty(character.GetInstanceDifficulty(template.IsRaid)).BindingType);

            if (binding != null)
            {
                BaseInstance instance = InstanceMgr.Instances.GetInstance(binding.MapId, binding.InstanceId);
                if (instance != null && instance.IsActive)
                {
                    return(instance);
                }
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// This is called when an area trigger causes entering an instance
        /// </summary>
        public static bool EnterInstance(Character chr, MapTemplate mapTemplate, Vector3 targetPos)
        {
            if (!mapTemplate.IsInstance)
            {
                log.Error("Character {0} tried to enter \"{1}\" as Instance.", chr,
                          mapTemplate);
                return(false);
            }

            bool  isRaid = mapTemplate.Type == MapType.Raid;
            Group group  = chr.Group;

            if (isRaid && !chr.Role.IsStaff && !group.Flags.HasFlag(GroupFlags.Raid))
            {
                InstanceHandler.SendRequiresRaid(chr.Client, 0);
                return(false);
            }

            if (!mapTemplate.MayEnter(chr))
            {
                return(false);
            }
            chr.SendSystemMessage("Entering instance...");
            InstanceCollection instances = chr.Instances;
            BaseInstance       instance  = instances.GetActiveInstance(mapTemplate);

            if (instance == null)
            {
                if (mapTemplate.GetDifficulty(chr.GetInstanceDifficulty(isRaid)).BindingType == BindingType.Soft &&
                    !instances.HasFreeInstanceSlot && !chr.GodMode)
                {
                    MovementHandler.SendTransferFailure(chr.Client, mapTemplate.Id,
                                                        MapTransferError.TRANSFER_ABORT_TOO_MANY_INSTANCES);
                    return(false);
                }

                if (group != null)
                {
                    instance = group.GetActiveInstance(mapTemplate);
                    if (instance != null && !CheckFull(instance, chr))
                    {
                        return(false);
                    }
                }

                if (instance == null)
                {
                    instance = CreateInstance(chr, mapTemplate.InstanceTemplate,
                                              chr.GetInstanceDifficulty(isRaid));
                    if (instance == null)
                    {
                        log.Warn("Could not create Instance \"{0}\" for: {1}", mapTemplate,
                                 chr);
                        return(false);
                    }
                }
            }
            else if (!chr.GodMode)
            {
                if (!CheckFull(instance, chr))
                {
                    return(false);
                }
                if (isRaid)
                {
                    if (group == null)
                    {
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id,
                                                            MapTransferError.TRANSFER_ABORT_NEED_GROUP);
                        return(false);
                    }

                    InstanceBinding binding1 =
                        group.InstanceLeaderCollection.GetBinding(mapTemplate.Id, BindingType.Hard);
                    InstanceBinding binding2 = instances.GetBinding(mapTemplate.Id, BindingType.Hard);
                    if (binding2 != null && binding1 != binding2)
                    {
                        MovementHandler.SendTransferFailure(chr.Client, instance.Id,
                                                            MapTransferError.TRANSFER_ABORT_NOT_FOUND);
                        return(false);
                    }
                }
            }

            instance.TeleportInside(chr, targetPos);
            return(true);
        }
示例#4
0
		public bool Equals(InstanceBinding obj)
		{
			if (ReferenceEquals(null, obj)) return false;
			if (ReferenceEquals(this, obj)) return true;
			return obj.m_DifficultyIndex == m_DifficultyIndex && obj.BindTime.Equals(BindTime) && Equals(obj.MapId, MapId) && obj.InstanceId == InstanceId;
		}