Esempio n. 1
0
        public static InstancedMap GetInstance(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            if (!trigger.Text.HasNext)
            {
                trigger.Reply("No MapId specified.");
            }
            MapId mapId = trigger.Text.NextEnum(MapId.End);

            if (mapId == MapId.End)
            {
                trigger.Reply("Invalid MapId.");
                return(null);
            }

            if (!trigger.Text.HasNext)
            {
                trigger.Reply("No Instance-Id specified.");
            }
            uint         instanceId = trigger.Text.NextUInt();
            BaseInstance instance   = InstanceMgr.Instances.GetInstance(mapId, instanceId);

            if (instance == null)
            {
                trigger.Reply("Instance id does not exist: #{1} (for {0})", (object)mapId, (object)instanceId);
            }
            return(instance);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the Instance of the given Map of either the Leader or any member
        /// if anyone is already in it.
        /// </summary>
        public BaseInstance GetActiveInstance(MapTemplate map)
        {
            GroupMember leader = m_leader;

            if (leader != null)
            {
                Character character = leader.Character;
                if (character != null)
                {
                    InstanceCollection instances = character.Instances;
                    if (instances != null)
                    {
                        BaseInstance activeInstance = instances.GetActiveInstance(map);
                        if (activeInstance != null)
                        {
                            return(activeInstance);
                        }
                    }
                }
            }

            foreach (Character allCharacter in GetAllCharacters())
            {
                BaseInstance activeInstance = allCharacter.GetActiveInstance(map);
                if (activeInstance != null)
                {
                    return(activeInstance);
                }
            }

            return(null);
        }
 public void Push(string phoneNumber, BaseInstance instance)
 {
     if (!workflowInstances.ContainsKey(phoneNumber))
     {
         workflowInstances.Add(phoneNumber, new Stack <BaseInstance>());
     }
     workflowInstances[phoneNumber].Push(instance);
 }
Esempio n. 4
0
 public IWorkflow GetStateMachine(BaseInstance instance)
 {
     if (instance == null)
     {
         return null;
     }
     return GetStateMachine(instance.GetType());
 }
        public void Add(Type objType, Guid moduleId, object[] para, string title)
        {
            BaseInstance inst = new BaseInstance();

            UserControlBase controlBase = inst.CreateControlInstance(objType, moduleId, para);

            base.Add(controlBase);
        }
 public void Push(string phoneNumber, BaseInstance instance)
 {
     if (!workflowInstances.ContainsKey(phoneNumber))
       {
     workflowInstances.Add(phoneNumber, new Stack<BaseInstance>());
       }
       workflowInstances[phoneNumber].Push(instance);
 }
Esempio n. 7
0
        private void SendAreYouSure(BaseInstance wf, string data)
        {
            wf.PhoneNumber = data;

            bus.Publish(new SendSms()
            {
                PhoneNumber = data, Body = "You were in the middle of something, sure you want to abort? Y/N"
            });
        }
Esempio n. 8
0
        public void Handle(SmsReceived sms)
        {
            BaseInstance instance = instanceRepository.Peek(sms.PhoneNumber);

            if (instance != null)
            {
                if (this.mapper.MappingExists(sms.Body) && !(instance is ForkInstance))
                {
                    ForkInstance fork = new ForkInstance()
                    {
                        ForkingFromInstance = instance,
                        ForkingFromWorkflow = this.mapper.GetStateMachine(instance.GetType()),
                        ForkingToKeyword    = sms.Body,
                        PhoneNumber         = sms.PhoneNumber
                    };

                    var stateMachine = this.mapper.GetStateMachine(fork.GetType());

                    stateMachine.RaiseAnEvent(fork, stateMachine.Start, sms.PhoneNumber);

                    instanceRepository.Push(sms.PhoneNumber, fork);
                }
                else
                {
                    //then raise the SMS received event
                    var stateMachine = this.mapper.GetStateMachine(instance.GetType());

                    stateMachine.RaiseAnEvent(instance, stateMachine.SMSReceived, sms.Body);

                    if (instance.CurrentState == stateMachine.Final)
                    {
                        instanceRepository.Pop(sms.PhoneNumber);
                    }
                }
            }
            else if (this.mapper.MappingExists(sms.Body))
            {
                //make a new state machine instance
                instance = this.mapper.GetStateMachineInstance(sms.Body);
                IWorkflow stateMachine = this.mapper.GetStateMachine(sms.Body);

                stateMachine.RaiseAnEvent(instance, stateMachine.Start, sms.PhoneNumber);
                instanceRepository.Push(sms.PhoneNumber, instance);
            }
            else
            {
                bus.Publish(new SendSms()
                {
                    PhoneNumber = sms.PhoneNumber, Body = "That command was not recognized."
                });
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Called before the given member is removed to clean up everything related to the given member
        /// </summary>
        protected void OnMemberRemoved(GroupMember member)
        {
            Character chr = member.Character;

            if (chr != null && chr.IsInWorld)
            {
                if (!chr.IsInContext)
                {
                    chr.ExecuteInContext(() => OnMemberRemoved(member));
                    return;
                }

                GroupMemberHandler memberRemoved = MemberRemoved;
                if (memberRemoved != null)
                {
                    memberRemoved(member);
                }
                --m_Count;
                SendEmptyUpdate(chr);
                chr.GroupMember = null;
                GroupHandler.SendResult(chr.Client, GroupResult.NoError);
                member.SubGroup.RemoveMember(member);
                member.Character = null;
                if (chr.Map is BaseInstance)
                {
                    BaseInstance instance = (BaseInstance)chr.Map;
                    chr.Map.CallDelayed(GroupInstanceKickDelayMillis, () =>
                    {
                        if (!chr.IsInWorld || chr.Map != instance || instance.CanEnter(chr))
                        {
                            return;
                        }
                        chr.TeleportToNearestGraveyard();
                    });
                }
            }
            else
            {
                GroupMemberHandler memberRemoved = MemberRemoved;
                if (memberRemoved != null)
                {
                    memberRemoved(member);
                }
                --m_Count;
                Singleton <GroupMgr> .Instance.OfflineChars.Remove(member.Id);

                member.m_subGroup = null;
            }

            member.m_nextMember = null;
        }
Esempio n. 10
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                Character target = trigger.Args.Target as Character;
                string    str    = trigger.Text.NextModifiers();
                MapId     mapID  = trigger.Text.NextEnum(MapId.End);

                if (mapID == MapId.End)
                {
                    trigger.Reply("Invalid MapId.");
                }
                else
                {
                    MapTemplate mapTemplate = World.GetMapTemplate(mapID);
                    if (mapTemplate != null && mapTemplate.IsInstance)
                    {
                        uint num;
                        if (str.Contains("d"))
                        {
                            num = trigger.Text.NextUInt();
                            if (mapTemplate.GetDifficulty(num) == null)
                            {
                                trigger.Reply("Invalid Difficulty: {0}");
                            }
                        }
                        else
                        {
                            num = target == null ? 0U : target.GetInstanceDifficulty(mapTemplate.IsRaid);
                        }

                        BaseInstance instance = InstanceMgr.CreateInstance(target, mapTemplate.InstanceTemplate, num);
                        if (instance != null)
                        {
                            trigger.Reply("Instance created: " + instance);
                            if (!str.Contains("e") || target == null)
                            {
                                return;
                            }
                            instance.TeleportInside((Character)trigger.Args.Target);
                        }
                        else
                        {
                            trigger.Reply("Unable to create Instance of: " + mapTemplate);
                        }
                    }
                    else
                    {
                        trigger.Reply("Invalid MapId.");
                    }
                }
            }
Esempio n. 11
0
        public SaveGameFile(string filename)
        {
            ValidFile = false;
            Name      = "(EMPTY)";
            SveFile   = string.Format("{0}.SVE", filename);
            MapFile   = string.Format("{0}.MAP", filename);
            if (!File.Exists(SveFile) || !File.Exists(MapFile))
            {
                return;
            }

            try
            {
                using (FileStream fs = new FileStream(SveFile, FileMode.Open))
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        if (fs.Length != 37856)
                        {
                            Name = "(INCORRECT FILE SIZE)";
                            return;
                        }

                        string turn            = Common.YearString(ReadUShort(br, 0));
                        ushort humanPlayer     = ReadUShort(br, 2);
                        ushort difficultyLevel = ReadUShort(br, 10);
                        string leaderName      = ReadStrings(br, 16, 112, 14)[humanPlayer];
                        string civName         = ReadStrings(br, 128, 96, 12)[humanPlayer];
                        string tribeName       = ReadStrings(br, 224, 88, 11)[humanPlayer];
                        string title           = Common.DifficultyName(difficultyLevel);

                        Name       = string.Format("{0} {1}, {2}/{3}", title, leaderName, civName, turn);
                        Difficulty = (int)difficultyLevel;
                    }
                ValidFile = true;
            }
            catch (Exception ex)
            {
                BaseInstance.Log($"Could not open .SVE file: {ex.InnerException}");
                Name = "(COULD NOT READ SAVE FILE HEADER)";
            }
        }
Esempio n. 12
0
 public static T Get <T>()
 {
     return((T)BaseInstance.Get2(typeof(T)));
 }
Esempio n. 13
0
 public DungeonInstanceSettings(BaseInstance instance)
     : base(instance)
 {
 }
Esempio n. 14
0
 public RaidInstanceSettings(BaseInstance instance)
     : base(instance)
 {
 }
Esempio n. 15
0
		public RaidInstanceSettings(BaseInstance instance)
			: base(instance)
		{
		}
Esempio n. 16
0
 protected InstanceSettings(BaseInstance instance)
 {
     Instance = instance;
 }
Esempio n. 17
0
		public DungeonInstanceSettings(BaseInstance instance) : base(instance)
		{
		}