Beispiel #1
0
    public bool Push(Sphere Sphere, ref Vector3 Velocity)
    {
        Vector vector;

        if (!this.shape.Shape.Intersects(Sphere))
        {
            return(false);
        }
        Facepunch.Geometry.Plane plane  = Facepunch.Geometry.Plane.DirectionPoint(this.pushDir0, this.pushPoint0);
        Facepunch.Geometry.Plane plane2 = Facepunch.Geometry.Plane.DirectionPoint(this.pushDir1, this.pushPoint1);
        float num  = plane.DistanceTo(Sphere.Center + ((Facepunch.Geometry.Point)(((Normal)plane.Direction) * Sphere.Radius)));
        float num2 = plane2.DistanceTo(Sphere.Center + ((Facepunch.Geometry.Point)(((Normal)plane2.Direction) * Sphere.Radius)));

        if (num > num2)
        {
            vector = (Vector)(((Normal)plane.Direction) * (this.pushSpeed * Time.deltaTime));
        }
        else
        {
            vector = (Vector)(((Normal)plane2.Direction) * (this.pushSpeed * Time.deltaTime));
        }
        Velocity.x += vector.x;
        Velocity.y += vector.y;
        Velocity.z += vector.z;
        return(true);
    }
Beispiel #2
0
    public bool Push(Facepunch.Geometry.Sphere Sphere, ref Vector3 Velocity)
    {
        Vector vector;

        if (!this.shape.Shape.Intersects(Sphere))
        {
            return(false);
        }
        Facepunch.Geometry.Plane plane  = Facepunch.Geometry.Plane.DirectionPoint(this.pushDir0, this.pushPoint0);
        Facepunch.Geometry.Plane plane1 = Facepunch.Geometry.Plane.DirectionPoint(this.pushDir1, this.pushPoint1);
        vector     = (plane.DistanceTo(Sphere.Center + ((Normal)plane.Direction * Sphere.Radius)) <= plane1.DistanceTo(Sphere.Center + ((Normal)plane1.Direction * Sphere.Radius)) ? (Normal)plane1.Direction * (this.pushSpeed * Time.deltaTime) : (Normal)plane.Direction * (this.pushSpeed * Time.deltaTime));
        Velocity.x = Velocity.x + vector.x;
        Velocity.y = Velocity.y + vector.y;
        Velocity.z = Velocity.z + vector.z;
        return(true);
    }