Пример #1
0
 protected virtual void CallOnIntersection(PhysicModel arg1)
 {
     if (OnIntersection != null)
     {
         OnIntersection.Invoke(this, arg1);
     }
 }
Пример #2
0
        public override void Intersection(PhysicModel modelB)
        {
            //base.Intersection(modelB);

            var delta  = (MapObject.Position - modelB.MapObject.Position).Length();
            var radSum = Radius;

            if (modelB is PhysicslSphere sphere)
            {
                radSum += sphere.Radius;
            }
            //OnINtersection?.

            if (delta >= radSum)
            {
                return;
            }

            CallOnIntersection(modelB);

            //Console.WriteLine($"{modelA} coll {modelB}");

            if (IsCollision && modelB.IsCollision)
            {
                // отодвигание
                var firstModel  = IsStatic ? modelB : this;
                var secondModel = firstModel == this ? modelB : this;

                var deltaVec = firstModel.MapObject.Position - secondModel.MapObject.Position;
                if (!deltaVec.Equals(Vector2.Zero))
                {
                    firstModel.MapObject.Position -= deltaVec / deltaVec.Length() * (delta - radSum);
                }
            }
        }
Пример #3
0
 public virtual void Intersection(PhysicModel modelB)
 {
 }