Example #1
0
        /// <summary>
        /// Removes any rule between the two groups in the space.
        /// </summary>
        /// <param name="groupA">First CollisionGroup of the pair.</param>
        /// <param name="groupB">SecondCollisionGroup of the pair.</param>
        public static void RemoveCollisionRule(CollisionGroup groupA, CollisionGroup groupB)
        {
            Dictionary <CollisionGroupPair, CollisionRule> dictionary = CollisionRules.CollisionGroupRules;
            var pair = new CollisionGroupPair(groupA, groupB);

            if (dictionary.ContainsKey(pair))
            {
                dictionary.Remove(pair);
            }
        }
Example #2
0
        //Equals is not overriden because the hashcode because the hashcode is the default hashcode, just modified a bit.

        /// <summary>
        /// Defines the CollisionRule between the two groups for a given space.
        /// </summary>
        /// <param name="groupA">First CollisionGroup of the pair.</param>
        /// <param name="groupB">Second CollisionGroup of the pair.</param>
        /// <param name="rule">CollisionRule to use between the pair.</param>
        public static void DefineCollisionRule(CollisionGroup groupA, CollisionGroup groupB, CollisionRule rule)
        {
            var pair = new CollisionGroupPair(groupA, groupB);

            if (CollisionRules.CollisionGroupRules.ContainsKey(pair))
            {
                CollisionRules.CollisionGroupRules[pair] = rule;
            }
            else
            {
                CollisionRules.CollisionGroupRules.Add(pair, rule);
            }
        }