///<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); } }
///<summary> /// Tries to remove a relationship about ownerB 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="ownerB">Owner of the collision rules that will be removed from ownerA's Specific relationships.</param> public static void RemoveRule(ICollisionRulesOwner ownerA, ICollisionRulesOwner ownerB) { if (!ownerA.CollisionRules.specific.Remove(ownerB.CollisionRules)) { ownerB.CollisionRules.specific.Remove(ownerA.CollisionRules); } }
///<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); } }
private Func <BroadPhaseEntry, bool> GetOverlapFilter(ICollisionRulesOwner rulesOwner) { bool Filter(BroadPhaseEntry e) { CollisionRule rule = CollisionRules.GetCollisionRule(e, rulesOwner); return(rule <= CollisionRule.NoSolver); } return(Filter); }
private CollisionRule GetCollisionRuleWithGroup(ICollisionRulesOwner rulesOwner, CollisionGroup group) { if (rulesOwner.CollisionRules.Personal != CollisionRule.Defer) { return(rulesOwner.CollisionRules.Personal); } CollisionGroupPair pair = new CollisionGroupPair(group, rulesOwner.CollisionRules.Group); CollisionRules.CollisionGroupRules.TryGetValue(pair, out CollisionRule rule); return(rule); }
private CollisionRule CustomCollisionRuleCalculator(ICollisionRulesOwner aOwner, ICollisionRulesOwner bOwner) { CollisionRules a = aOwner.CollisionRules; CollisionRules b = bOwner.CollisionRules; CollisionRule groupRule = CollisionRules.GetGroupCollisionRuleDefault(a, b); if (groupRule == CollisionRule.NoBroadPhase) { return(groupRule); } return(CollisionRules.GetCollisionRuleDefault(aOwner, bOwner)); }
/// <summary> /// Determines what collision rule governs the interaction between the two objects. /// </summary> /// <param name="aOwner">First ruleset owner in the pair. This entity's space is used to determine the collision detection settings that contain special collision group interaction rules.</param> /// <param name="bOwner">Second ruleset owner in the pair.</param> /// <returns>Collision rule governing the interaction between the pair.</returns> public static CollisionRule GetCollisionRuleDefault(ICollisionRulesOwner aOwner, ICollisionRulesOwner bOwner) { var a = aOwner.CollisionRules; var b = bOwner.CollisionRules; CollisionRule pairRule = GetSpecificCollisionRuleDefault(a, b); if (pairRule == CollisionRule.Defer) { pairRule = GetPersonalCollisionRuleDefault(a, b); if (pairRule == CollisionRule.Defer) { pairRule = GetGroupCollisionRuleDefault(a, b); } } if (pairRule == CollisionRule.Defer) { pairRule = DefaultCollisionRule; } return(pairRule); }
///<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); }
///<summary> /// Tries to remove a relationship about ownerB 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="ownerB">Owner of the collision rules that will be removed from ownerA's Specific relationships.</param> public static void RemoveRule(ICollisionRulesOwner ownerA, ICollisionRulesOwner ownerB) { if (!ownerA.CollisionRules.specific.Remove(ownerB.CollisionRules)) ownerB.CollisionRules.specific.Remove(ownerA.CollisionRules); }
///<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); }
///<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); }
/// <summary> /// Determines what collision rule governs the interaction between the two objects. /// </summary> /// <param name="aOwner">First ruleset owner in the pair. This entity's space is used to determine the collision detection settings that contain special collision group interaction rules.</param> /// <param name="bOwner">Second ruleset owner in the pair.</param> /// <returns>Collision rule governing the interaction between the pair.</returns> public static CollisionRule GetCollisionRuleDefault(ICollisionRulesOwner aOwner, ICollisionRulesOwner bOwner) { var a = aOwner.CollisionRules; var b = bOwner.CollisionRules; CollisionRule pairRule = GetSpecificCollisionRuleDefault(a, b); if (pairRule == CollisionRule.Defer) { pairRule = GetPersonalCollisionRuleDefault(a, b); if (pairRule == CollisionRule.Defer) pairRule = GetGroupCollisionRuleDefault(a, b); } if (pairRule == CollisionRule.Defer) pairRule = DefaultCollisionRule; return pairRule; }
///<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); }
/// <summary> /// Uses the CollisionRuleCalculator to get the collision rule between two collision rules owners. /// </summary> /// <param name="ownerA">First owner of the pair.</param> /// <param name="ownerB">Second owner of the pair.</param> /// <returns>CollisionRule between the pair, according to the CollisionRuleCalculator.</returns> public static CollisionRule GetCollisionRule(ICollisionRulesOwner ownerA, ICollisionRulesOwner ownerB) { return collisionRuleCalculator(ownerA.CollisionRules, ownerB.CollisionRules); }
/// <summary> /// Uses the CollisionRuleCalculator to get the collision rule between two collision rules owners. /// </summary> /// <param name="ownerA">First owner of the pair.</param> /// <param name="ownerB">Second owner of the pair.</param> /// <returns>CollisionRule between the pair, according to the CollisionRuleCalculator.</returns> public static CollisionRule GetCollisionRule(ICollisionRulesOwner ownerA, ICollisionRulesOwner ownerB) { return(collisionRuleCalculator(ownerA, ownerB)); }