Esempio n. 1
0
        public override void Click(Entity entity, ItemStack item)
        {
            if (!(entity is PlayerEntity))
            {
                // TODO: non-player support
                return;
            }
            PlayerEntity    player = (PlayerEntity)entity;
            Location        end    = player.ItemSource() + player.ItemDir * 5;
            CollisionResult cr     = player.TheRegion.Collision.CuboidLineTrace(new Location(0.1, 0.1, 0.1), player.GetEyePosition(), end, player.IgnoreThis);

            if (cr.Hit && cr.HitEnt != null)
            {
                // TODO: handle static world impact
                PhysicsEntity pe = (PhysicsEntity)cr.HitEnt.Tag;
                if (pe.GetMass() > 0 && pe.GetMass() < 200)
                {
                    Grab(player, pe, cr.Position);
                }
                else
                {
                    // If (HandHold) { Grab(player, pe, cr.Position); }
                }
            }
        }
Esempio n. 2
0
 public static float CalculateDistance(PhysicsEntity a, PhysicsEntity b, float gravitationalForceMagnitude)
 {
     return(Mathf.Sqrt(G * ((b.GetMass() * a.GetMass()) / gravitationalForceMagnitude)));
 }
Esempio n. 3
0
 public static Vector2 CalculateGravitationalForce(PhysicsEntity a, PhysicsEntity b)
 {
     return(CalculateGravitationalForce(a.GetPosition(), a.GetMass(), b.GetPosition(), b.GetMass()));
 }