Beispiel #1
0
        public static DateTime GetNextResetTime(MapId id, uint difficultyIndex)
        {
            MapTemplate mapTemplate = WCell.RealmServer.Global.World.GetMapTemplate(id);

            if (mapTemplate != null)
            {
                return(InstanceMgr.GetNextResetTime(mapTemplate.GetDifficulty(difficultyIndex)));
            }
            return(new DateTime());
        }
Beispiel #2
0
 /// <summary>
 /// Gets and removes the InstanceLog for the given Character
 /// </summary>
 /// <param name="character"></param>
 internal static void RetrieveInstances(Character character)
 {
     using (InstanceMgr.syncLock.EnterReadLock())
     {
         InstanceCollection instancesUnlocked =
             InstanceMgr.GetOfflineInstancesUnlocked(character.EntityId.Low, false, true);
         if (instancesUnlocked == null)
         {
             return;
         }
         instancesUnlocked.Character = character;
         character.Instances         = instancesUnlocked;
     }
 }
Beispiel #3
0
        public static void SetCreator(MapId id, string typeName)
        {
            Type type = ServerApp <WCell.RealmServer.RealmServer> .GetType(typeName);

            if (type == (Type)null)
            {
                InstanceMgr.log.Warn("Invalid Creator for Instance \"" + (object)id + "\": " + typeName +
                                     "  - Please correct it in the Instance-config file: " +
                                     InstanceConfigBase <InstanceConfig, MapId> .Filename);
            }
            else
            {
                IProducer producer = AccessorMgr.GetOrCreateDefaultProducer(type);
                InstanceMgr.SetCreator(id, (InstanceCreator)(() => (BaseInstance)producer.Produce()));
            }
        }
Beispiel #4
0
        /// <summary>Convinience method for development</summary>
        /// <param name="creator">Can be null</param>
        public static BaseInstance CreateInstance(Character creator, MapId mapId)
        {
            MapTemplate mapTemplate = WCell.RealmServer.Global.World.GetMapTemplate(mapId);

            if (mapTemplate == null || !mapTemplate.IsInstance)
            {
                return((BaseInstance)null);
            }
            uint difficultyIndex;

            if (creator != null)
            {
                creator.EnsurePureStaffGroup();
                difficultyIndex = creator.GetInstanceDifficulty(mapTemplate.IsRaid);
            }
            else
            {
                difficultyIndex = 0U;
            }

            BaseInstance instance = mapTemplate.InstanceTemplate.Create();

            return(InstanceMgr.SetupInstance(creator, instance, mapTemplate.InstanceTemplate, difficultyIndex));
        }
Beispiel #5
0
        /// <param name="creator">Can be null</param>
        public static BaseInstance CreateInstance(Character creator, InstanceTemplate template, uint difficultyIndex)
        {
            BaseInstance instance = template.Create();

            return(InstanceMgr.SetupInstance(creator, instance, template, difficultyIndex));
        }
Beispiel #6
0
 /// <param name="creator">Can be null</param>
 public static I CreateInstance <I>(Character creator, InstanceTemplate template, uint difficultyIndex)
     where I : BaseInstance, new()
 {
     return((I)InstanceMgr.SetupInstance(creator, (BaseInstance)Activator.CreateInstance <I>(), template,
                                         difficultyIndex));
 }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lowId"></param>
 /// <param name="autoCreate"></param>
 /// <param name="remove"></param>
 /// <returns></returns>
 public static InstanceCollection GetOfflineInstances(uint lowId, bool autoCreate, bool remove)
 {
     using (InstanceMgr.syncLock.EnterReadLock())
         return(InstanceMgr.GetOfflineInstancesUnlocked(lowId, autoCreate, remove));
 }
Beispiel #8
0
 public static void RemoveLog(uint lowId)
 {
     InstanceMgr.GetOfflineInstances(lowId, false, true);
 }
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lowId"></param>
 /// <param name="autoCreate"></param>
 /// <returns></returns>
 public static InstanceCollection GetOfflineInstances(uint lowId, bool autoCreate)
 {
     return(InstanceMgr.GetOfflineInstances(lowId, autoCreate, false));
 }
Beispiel #10
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)
            {
                InstanceMgr.log.Error("Character {0} tried to enter \"{1}\" as Instance.", (object)chr,
                                      (object)mapTemplate);
                return(false);
            }

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

            if (isRaid && !chr.Role.IsStaff && !group.Flags.HasFlag((Enum)GroupFlags.Raid))
            {
                InstanceHandler.SendRequiresRaid((IPacketReceiver)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((IPacketReceiver)chr.Client, mapTemplate.Id,
                                                        MapTransferError.TRANSFER_ABORT_TOO_MANY_INSTANCES);
                    return(false);
                }

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

                if (instance == null)
                {
                    instance = InstanceMgr.CreateInstance(chr, mapTemplate.InstanceTemplate,
                                                          chr.GetInstanceDifficulty(isRaid));
                    if (instance == null)
                    {
                        InstanceMgr.log.Warn("Could not create Instance \"{0}\" for: {1}", (object)mapTemplate,
                                             (object)chr);
                        return(false);
                    }
                }
            }
            else if (!chr.GodMode)
            {
                if (!InstanceMgr.CheckFull(instance, chr))
                {
                    return(false);
                }
                if (isRaid)
                {
                    if (group == null)
                    {
                        MovementHandler.SendTransferFailure((IPacketReceiver)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 != (InstanceBinding)null && binding1 != binding2)
                    {
                        MovementHandler.SendTransferFailure((IPacketReceiver)chr.Client, instance.Id,
                                                            MapTransferError.TRANSFER_ABORT_NOT_FOUND);
                        return(false);
                    }
                }
            }

            instance.TeleportInside(chr, targetPos);
            return(true);
        }
Beispiel #11
0
 protected override void InitSetting(InstanceConfigEntry <MapId> configEntry)
 {
     InstanceMgr.SetCreator(configEntry.Name, configEntry.TypeName.Trim());
 }