Exemple #1
0
 ///<summary>
 /// Tries to remove a relationship about rulesB from ownerA's Specific list.
 ///</summary>
 ///<param name="ownerA">Owner of the collision rules that will lose an entry in its Specific relationships.</param>
 ///<param name="rulesB">Collision rules that will be removed from ownerA's Specific relationships.</param>
 public static void RemoveRule(ICollisionRulesOwner ownerA, CollisionRules rulesB)
 {
     if (!ownerA.CollisionRules.specific.Remove(rulesB))
     {
         rulesB.specific.Remove(ownerA.CollisionRules);
     }
 }
Exemple #2
0
 ///<summary>
 /// Tries to remove a relationship about ownerB from rulesA's Specific list.
 ///</summary>
 ///<param name="rulesA">Collision rules that will lose an entry in its Specific relationships.</param>
 ///<param name="ownerB">Owner of the collision rules that will be removed from ownerA's Specific relationships.</param>
 public static void RemoveRule(CollisionRules rulesA, ICollisionRulesOwner ownerB)
 {
     if (!rulesA.specific.Remove(ownerB.CollisionRules))
     {
         ownerB.CollisionRules.specific.Remove(rulesA);
     }
 }
Exemple #3
0
        ///<summary>
        /// Default implementation used to calculate collision rules due to the rulesets' specific relationships.
        ///</summary>
        ///<param name="a">First ruleset in the pair.</param>
        ///<param name="b">Second ruleset in the pair.</param>
        ///<returns>Collision rule governing the interaction between the pair.</returns>
        public static CollisionRule GetSpecificCollisionRuleDefault(CollisionRules a, CollisionRules b)
        {
            CollisionRule aToB;

            a.specific.WrappedDictionary.TryGetValue(b, out aToB);
            CollisionRule bToA;

            b.specific.WrappedDictionary.TryGetValue(a, out bToA);
            return(aToB > bToA ? aToB : bToA);
        }
Exemple #4
0
        ///<summary>
        /// Default implementation used to calculate collision rules due to the rulesets' collision groups.
        ///</summary>
        ///<param name="a">First ruleset in the pair.</param>
        ///<param name="b">Second ruleset in the pair.</param>
        ///<returns>Collision rule governing the interaction between the pair.</returns>
        public static CollisionRule GetGroupCollisionRuleDefault(CollisionRules a, CollisionRules b)
        {
            if (a.group == null || b.group == null)
            {
                return(CollisionRule.Defer); //This can happen occasionally when objects aren't in a space or are being handled uniquely (like in compound bodies).
            }
            CollisionRule pairRule;

            CollisionGroupRules.TryGetValue(new CollisionGroupPair(a.group, b.group), out pairRule);
            return(pairRule);
        }
Exemple #5
0
 ///<summary>
 /// Default implementation used to calculate collision rules due to the rulesets' personal rules.
 ///</summary>
 ///<param name="a">First ruleset in the pair.</param>
 ///<param name="b">Second ruleset in the pair.</param>
 ///<returns>Collision rule governing the interaction between the pair.</returns>
 public static CollisionRule GetPersonalCollisionRuleDefault(CollisionRules a, CollisionRules b)
 {
     return(a.personal > b.personal ? a.personal : b.personal);
 }
Exemple #6
0
 ///<summary>
 /// Adds an entry in rulesA's Specific relationships list about ownerB.
 ///</summary>
 ///<param name="ownerA">Owner of the collision rules that will gain an entry in its Specific relationships.</param>
 ///<param name="rulesB">Collision rules that will be added to ownerA's Specific relationships.</param>
 ///<param name="rule">Rule assigned to the pair.</param>
 public static void AddRule(ICollisionRulesOwner ownerA, CollisionRules rulesB, CollisionRule rule)
 {
     ownerA.CollisionRules.specific.Add(rulesB, rule);
 }
Exemple #7
0
 ///<summary>
 /// Adds an entry in rulesA's Specific relationships list about ownerB.
 ///</summary>
 ///<param name="rulesA">Collision rules that will gain an entry in its Specific relationships.</param>
 ///<param name="ownerB">Owner of the collision rules that will be added to ownerA's Specific relationships.</param>
 ///<param name="rule">Rule assigned to the pair.</param>
 public static void AddRule(CollisionRules rulesA, ICollisionRulesOwner ownerB, CollisionRule rule)
 {
     rulesA.specific.Add(ownerB.CollisionRules, rule);
 }