using System; using FarseerPhysics.Dynamics; namespace FarseerPhysics.Common.PhysicsLogic { [Flags] public enum PhysicsLogicType { Explosion = (1 << 0) } public struct PhysicsLogicFilter { public PhysicsLogicType ControllerIgnores; /// /// Ignores the controller. The controller has no effect on this body. /// /// The logic type. public void IgnorePhysicsLogic(PhysicsLogicType type) { ControllerIgnores |= type; } /// /// Restore the controller. The controller affects this body. /// /// The logic type. public void RestorePhysicsLogic(PhysicsLogicType type) { ControllerIgnores &= ~type; } /// /// Determines whether this body ignores the the specified controller. /// /// The logic type. /// /// true if the body has the specified flag; otherwise, false. /// public bool IsPhysicsLogicIgnored(PhysicsLogicType type) { return (ControllerIgnores & type) == type; } } public abstract class PhysicsLogic : FilterData { private PhysicsLogicType _type; public World World; public override bool IsActiveOn(Body body) { if (body.PhysicsLogicFilter.IsPhysicsLogicIgnored(_type)) return false; return base.IsActiveOn(body); } public PhysicsLogic(World world, PhysicsLogicType type) { _type = type; World = world; } } }