Esempio n. 1
0
 /// <summary>
 /// Luo uuden tyhjän rakenteen.
 /// </summary>
 public PhysicsStructure()
 {
     centerObject = new PhysicsObject(1, 1)
     {
         IgnoresPhysicsLogics = true, IsVisible = false
     };
     objects             = new List <PhysicsObject>();
     Joints              = new List <IAxleJoint>();
     _collisionIgnorer   = new ObjectIgnorer();
     AssociatedListeners = new List <Listener>();
     AddedToGame        += AddJoints;
     Removed            += RemoveJoints;
     Add(centerObject); // Tämä pitää lisätä, sillä muuten jossain tilanteissa structuren ensimmäinen kappale pyörii keskiakselinsa ympäri.
 }
Esempio n. 2
0
        public void SetCollisionIgnorer(Ignorer ignorer)
        {
            if (ignorer is null)
            {
                FSBody.JypeliGroupIgnorer = null;
                FSBody.ObjectIgnorer      = null;
                return;
            }

            if (ignorer is JypeliGroupIgnorer)
            {
                JypeliGroupIgnorer ign = ignorer as JypeliGroupIgnorer;
                FSBody.JypeliGroupIgnorer = ign;
            }
            else if (ignorer is ObjectIgnorer || ignorer is null)
            {
                ObjectIgnorer ign = ignorer as ObjectIgnorer;
                FSBody.ObjectIgnorer = ign;
            }
            else
            {
                throw new NotImplementedException("Annettu Ignore ei ole toteutettu.");
            }
        }
Esempio n. 3
0
        public override bool CanCollide(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other)
        {
            AdvGroupIgnorer value = other as AdvGroupIgnorer;

            return
                (value == null ||
                 CanCollideInternal(value));
        }
Esempio n. 4
0
 /// <summary>
 /// Voivatko kappaleet törmätä toisiinsa
 /// </summary>
 /// <param name="thisBody"></param>
 /// <param name="otherBody"></param>
 /// <param name="other"></param>
 /// <returns></returns>
 public override bool CanCollide(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other)
 {
     return(other != this);
 }
Esempio n. 5
0
 public abstract bool CanCollide(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other);
Esempio n. 6
0
        public override bool CanCollide(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other)
        {
            JypeliGroupIgnorer jOther = other as JypeliGroupIgnorer;

            if (jOther == null)
            {
                return(true);
            }

            return((this.LegacyGroup == 0 || jOther.LegacyGroup == 0 || this.LegacyGroup != jOther.LegacyGroup) && (this.IgnoreMask & jOther.IgnoreMask) == 0);
        }
Esempio n. 7
0
 private bool CanCollideInternal(IPhysicsBody thisBody, IPhysicsBody otherBody, Ignorer other)
 {
     return(isInverted ^ CanCollide(thisBody, otherBody, other));
 }
Esempio n. 8
0
 protected Ignorer(Ignorer copy)
 {
     this.isInverted = copy.isInverted;
 }
Esempio n. 9
0
 internal static bool CanCollide(IPhysicsBody leftBody, IPhysicsBody rightBody, Ignorer left, Ignorer right)
 {
     return(left.CanCollideInternal(leftBody, rightBody, right));
 }
Esempio n. 10
0
 public CollisionIgnorerAdapter(Jypeli.Ignorer adaptee)
 {
     this.innerIgnorer = adaptee;
 }
Esempio n. 11
0
 public void SetCollisionIgnorer(Ignorer ignorer)
 {
     this.Body.CollisionIgnorer = new CollisionIgnorerAdapter(ignorer);
 }