Exemplo n.º 1
0
        public static void RemoveFromGroup(Group group, ObjectGuid guid, RemoveMethod method = RemoveMethod.Default, ObjectGuid kicker = default(ObjectGuid), string reason = null)
        {
            if (!group)
            {
                return;
            }

            group.RemoveMember(guid, method, kicker, reason);
        }
Exemplo n.º 2
0
        private void SubscriberMessageReceived(RedisChannel redisChannel, RedisValue redisValue)
        {
            if (!redisChannel.ToString().EndsWith("expired", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            var key = Encoding.UTF8.GetString(redisValue);

            LogMethod?.Invoke("Expired", key, null);
            RemoveMethod?.Invoke(key);
        }
Exemplo n.º 3
0
Arquivo: Event.cs Projeto: mortend/uno
        public void SetImplementedEvent(Event decl)
        {
            ImplementedEvent = decl;
            UnoName          = decl.DeclaringType + "." + decl.UnoName;

            if (AddMethod != null && decl.AddMethod != null)
            {
                AddMethod.SetImplementedMethod(decl.AddMethod);
            }
            if (RemoveMethod != null && decl.RemoveMethod != null)
            {
                RemoveMethod.SetImplementedMethod(decl.RemoveMethod);
            }
        }
Exemplo n.º 4
0
        public override void Implement(DynamicTypeBuilder config, TypeBuilder typeBuilder)
        {
            var addMethodIL = AddMethod.GetILGenerator();

            #region AddMethodIL
            GenerateHandlerMethods(BackingField, addMethodIL, true);

            #endregion

            var removeMethodIL = RemoveMethod.GetILGenerator();
            #region RemoveMethodIL
            GenerateHandlerMethods(BackingField, removeMethodIL, false);

            #endregion
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        protected override void RemoveAt(ref IEnumerable collection, int collectionIndex)
        {
            int current = 0;

            foreach (var item in collection)
            {
                if (current == collectionIndex)
                {
                                        #if DEV_MODE
                    Debug.Log("<color=red>RemoveAt(" + StringUtils.TypeToString(collection) + ", " + collectionIndex + "): " + StringUtils.ToString(item) + " with Type=" + StringUtils.TypeToString(item) + "</color>");
                                        #endif

                    RemoveMethod.InvokeWithParameter(collection, item);
                    return;
                }
                current++;
            }
        }
Exemplo n.º 6
0
 public sealed override MethodInfo GetRemoveMethod(bool nonPublic) => RemoveMethod.FilterAccessor(nonPublic);
Exemplo n.º 7
0
 // Called when a member is removed from a group.
 public virtual void OnRemoveMember(Group group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, string reason)
 {
 }
Exemplo n.º 8
0
 public void RemoveFromGroup(RemoveMethod method = RemoveMethod.Default)
 {
     RemoveFromGroup(GetGroup(), GetGUID(), method);
 }
Exemplo n.º 9
0
        public override void OnRemoveMember(Group group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, string reason)
        {
            if (!Global.LFGMgr.isOptionEnabled(LfgOptions.EnableDungeonFinder | LfgOptions.EnableRaidBrowser))
            {
                return;
            }

            ObjectGuid gguid = group.GetGUID();

            Log.outDebug(LogFilter.Lfg, "LFGScripts.OnRemoveMember [{0}]: remove [{1}] Method: {2} Kicker: {3} Reason: {4}", gguid, guid, method, kicker, reason);

            bool isLFG = group.isLFGGroup();

            if (isLFG && method == RemoveMethod.Kick)        // Player have been kicked
            {
                /// @todo - Update internal kick cooldown of kicker
                string str_reason = "";
                if (!string.IsNullOrEmpty(reason))
                {
                    str_reason = reason;
                }
                Global.LFGMgr.InitBoot(gguid, kicker, guid, str_reason);
                return;
            }

            LfgState state = Global.LFGMgr.GetState(gguid);

            // If group is being formed after proposal success do nothing more
            if (state == LfgState.Proposal && method == RemoveMethod.Default)
            {
                // LfgData: Remove player from group
                Global.LFGMgr.SetGroup(guid, ObjectGuid.Empty);
                Global.LFGMgr.RemovePlayerFromGroup(gguid, guid);
                return;
            }

            Global.LFGMgr.LeaveLfg(guid);
            Global.LFGMgr.SetGroup(guid, ObjectGuid.Empty);
            byte players = Global.LFGMgr.RemovePlayerFromGroup(gguid, guid);

            Player player = Global.ObjAccessor.FindPlayer(guid);

            if (player)
            {
                if (method == RemoveMethod.Leave && state == LfgState.Dungeon &&
                    players >= SharedConst.LFGKickVotesNeeded)
                {
                    player.CastSpell(player, SharedConst.LFGSpellDungeonDeserter, true);
                }
                //else if (state == LFG_STATE_BOOT)
                // Update internal kick cooldown of kicked

                player.GetSession().SendLfgUpdateStatus(new LfgUpdateData(LfgUpdateType.LeaderUnk1), true);
                if (isLFG && player.GetMap().IsDungeon())            // Teleport player out the dungeon
                {
                    Global.LFGMgr.TeleportPlayer(player, true);
                }
            }

            if (isLFG && state != LfgState.FinishedDungeon) // Need more players to finish the dungeon
            {
                Player leader = Global.ObjAccessor.FindPlayer(Global.LFGMgr.GetLeader(gguid));
                if (leader)
                {
                    leader.GetSession().SendLfgOfferContinue(Global.LFGMgr.GetDungeon(gguid, false));
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Manually removes selected status effect/s.
        /// </summary>
        /// <param name="target">Target who will get a new status effect.</param>
        /// <param name="caster">Caster who applied status effect on the target. Can be NULL.</param>
        /// <param name="scriptableStatusEffect">New scriptable status effect to be applied.</param>
        /// <param name="isCasterImportant">Should the caster be added to filter for removation method?</param>
        /// <param name="method">Method of the removation.</param>
        public void RemoveStatusEffect(Character target, Character caster, ScriptableStatusEffect scriptableStatusEffect, bool isCasterImportant, RemoveMethod method)
        {
            if (target == null || scriptableStatusEffect == null)
            {
                Debug.unityLogger.Log(LogType.Error, "Null reference for removing a status effect!");
                return;
            }

            // Remove all status effects of the same type.
            if (method == RemoveMethod.RemoveAllOfTheSameType)
            {
                target.AppliedStatusEffects.RemoveAll(delegate(StatusEffect item)
                {
                    if (item.Data.GetType() != scriptableStatusEffect.GetType())
                    {
                        return(false);
                    }

                    if (isCasterImportant)
                    {
                        if (item.Caster != caster)
                        {
                            return(false);
                        }
                    }

                    item.ForceEnd();
                    Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item);
                    return(true);
                });
            }
            // Remove all effects of the same effect.
            else if (method == RemoveMethod.RemoveAllOfTheSameEffect)
            {
                target.AppliedStatusEffects.RemoveAll(delegate(StatusEffect item)
                {
                    if (item.Data != scriptableStatusEffect)
                    {
                        return(false);
                    }

                    if (isCasterImportant)
                    {
                        if (item.Caster != caster)
                        {
                            return(false);
                        }
                    }

                    item.ForceEnd();
                    Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item);
                    return(true);
                });
            }
            // Remove only the first occured status effect.
            else if (method == RemoveMethod.RemoveTheFirst)
            {
                target.AppliedStatusEffects.Remove(target.AppliedStatusEffects.First(delegate(StatusEffect item)
                {
                    if (item.Data != scriptableStatusEffect)
                    {
                        return(false);
                    }

                    if (isCasterImportant)
                    {
                        if (item.Caster != caster)
                        {
                            return(false);
                        }
                    }

                    item.ForceEnd();
                    Debug.unityLogger.LogFormat(LogType.Log, "[{0}] Status effect ({1}) removed!", target.Name, item);
                    return(true);
                }));
            }
        }
Exemplo n.º 11
0
 public Helper(RemoveMethod done)
 {
     remove = done;
 }
Exemplo n.º 12
0
 public Helper(RemoveMethod done)
 {
     this.done = done;
 }
Exemplo n.º 13
0
Arquivo: Event.cs Projeto: mortend/uno
 public void SetOverriddenEvent(Event overriddenEvent)
 {
     OverriddenEvent = overriddenEvent;
     AddMethod?.SetOverriddenMethod(overriddenEvent?.AddMethod);
     RemoveMethod?.SetOverriddenMethod(overriddenEvent?.RemoveMethod);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Tests that common aspects of the specified collection are functional.
        /// </summary>
        /// <param name="collection">An object that is the collection to be tested.</param>
        public static void TestCollection(object collection)
        {
            if (collection != null)
            {
                Type MyType;

                MyType = collection.GetType();
                if (MyType.GetInterface("ICollection") != null)
                {
                    Type[] GenericTypes;

                    GenericTypes = MyType.BaseType.GetGenericArguments();
                    if (GenericTypes != null && GenericTypes.Length == 1)
                    {
                        MethodInfo   AddMethod;
                        PropertyInfo CountProperty;
                        PropertyInfo IndexerProperty;
                        MethodInfo   RemoveMethod;

                        AddMethod       = MyType.GetMethod("Add");
                        CountProperty   = MyType.GetProperty("Count");
                        IndexerProperty = MyType.GetProperty("Item", GenericTypes[0], new Type[] { typeof(int) });
                        RemoveMethod    = MyType.GetMethod("Remove");

                        if (AddMethod != null && RemoveMethod != null && CountProperty != null && IndexerProperty != null)
                        {
                            int CurrentCount;

                            CurrentCount = (int)CountProperty.GetValue(collection);
                            if (CurrentCount > 0)
                            {
                                object TestObject;

                                TestObject = IndexerProperty.GetValue(collection, new object[] { 0 });
                                if (TestObject != null)
                                {
                                    Assert.AreEqual(CurrentCount, CountProperty.GetValue(collection));
                                    RemoveMethod.Invoke(collection, new object[] { TestObject });
                                    Assert.AreEqual(CurrentCount - 1, CountProperty.GetValue(collection));
                                    AddMethod.Invoke(collection, new object[] { TestObject });
                                    Assert.AreEqual(CurrentCount, CountProperty.GetValue(collection));
                                }
                                else
                                {
                                    Assert.Fail("Indexer returned a null result");
                                }
                            }
                            else
                            {
                                throw new ArgumentException("The specified collection is empty and cannot be tested", "collection");
                            }
                        }
                        else
                        {
                            throw new ArgumentException("The specified type does not support required operations", "collection");
                        }
                    }
                    else
                    {
                        throw new ArgumentException("The specified type does not implement a generic collection", "collection");
                    }
                }
                else
                {
                    throw new ArgumentException("The specified type does not implement ICollection", "collection");
                }
            }
            else
            {
                throw new ArgumentException("The specified collection is null", "collection");
            }
        }