Exemple #1
0
        public static bool IsMoving(this IMyEntity entity)
        {
            MyPhysicsComponentBase physics = entity.Physics;

            if (physics == null)
            {
                return(false);
            }

            // acceleration seems to not be zero'd out when characters enter cockpits,
            // etc. It's more accurate to just use velocity
            if (//physics.AngularAcceleration.AbsMax() == 0 &&
                physics.AngularVelocity.AbsMax() == 0 &&
                //physics.LinearAcceleration.AbsMax() == 0 &&
                physics.LinearVelocity.AbsMax() == 0)
            {
                return(false);
            }

            //Log.Trace("Physics for entity " + entity.EntityId + " :", "IsMoving");
            //Log.Trace("AngularAcceleration: " + physics.AngularAcceleration, "IsMoving");
            //Log.Trace("AngularVelocity: " + physics.AngularVelocity, "IsMoving");
            //Log.Trace("LinearAcceleration: " + physics.LinearAcceleration, "IsMoving");
            //Log.Trace("LinearVelocity: " + physics.LinearVelocity, "IsMoving");

            return(true);
        }
Exemple #2
0
 public static bool TestPatchMethod(MyEntity thrownEntity,
                                    Vector3D pos,
                                    MyPhysicsComponentBase motionInheritedFrom)
 {
     if (CrunchUtilitiesPlugin.file != null && CrunchUtilitiesPlugin.file.ScrapMetalPatch)
     {
         if (thrownEntity != null && thrownEntity is MyFloatingObject obj)
         {
             if (obj.ItemDefinition.DisplayNameText.Equals("Scrap Metal"))
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
 }
        private void GetOB()
        {
            try
            {
                if (!MyAPIGateway.Session.IsServer)
                {
                    if (PhysCache == null)
                    {
                        topEntity.InitBoxPhysics(MyStringHash.NullOrEmpty, Vector3.Zero, Vector3.One, 0, 0, 0, 0, RigidBodyFlag.RBF_STATIC);
                        PhysCache = topEntity.Physics;

                        missile           = topEntity.GetObjectBuilder() as MyObjectBuilder_Missile;
                        topEntity.Physics = null;
                    }
                    else
                    {
                        topEntity.Physics = PhysCache;

                        missile           = topEntity.GetObjectBuilder() as MyObjectBuilder_Missile;
                        topEntity.Physics = null;
                    }
                }
            }
            catch (Exception e)
            {
                //MyAPIGateway.Utilities.ShowNotification("[ Error in " + GetType().FullName + ": " + e.Message + " ]", 10000, MyFontEnum.Red);
                MyLog.Default.WriteLine(e);
            }
        }
        private static void AddToPos(MyEntity thrownEntity, Vector3D pos, MyPhysicsComponentBase motionInheritedFrom)
        {
            ProfilerShort.Begin("AddToPos");
            ProfilerShort.Begin("GetPos");
            Vector3 forward = MyUtils.GetRandomVector3Normalized();
            Vector3 up      = MyUtils.GetRandomVector3Normalized();

            while (forward == up)
            {
                up = MyUtils.GetRandomVector3Normalized();
            }

            Vector3 right = Vector3.Cross(forward, up);

            up = Vector3.Cross(right, forward);

            thrownEntity.WorldMatrix = MatrixD.CreateWorld(pos, forward, up);
            ProfilerShort.End();
            ProfilerShort.Begin("MyEntities.Add");
            MyEntities.Add(thrownEntity);
            ProfilerShort.BeginNextBlock("ApplyPhysics");
            ApplyPhysics(thrownEntity, motionInheritedFrom);
            ProfilerShort.End();
            ProfilerShort.End();
        }
Exemple #5
0
 public override void OnAddedToContainer(MyComponentContainer container)
 {
     base.OnAddedToContainer(container);
     m_syncObject              = container.Get <MySyncComponentBase>();
     m_physics                 = container.Get <MyPhysicsComponentBase>();
     m_hierarchy               = container.Get <MyHierarchyComponentBase>();
     container.ComponentAdded += container_ComponentAdded;
 }
 private static void ApplyPhysics(MyEntity thrownEntity, MyPhysicsComponentBase motionInheritedFrom)
 {
     if (thrownEntity.Physics != null && motionInheritedFrom != null)
     {
         thrownEntity.Physics.LinearVelocity  = motionInheritedFrom.LinearVelocity;
         thrownEntity.Physics.AngularVelocity = motionInheritedFrom.AngularVelocity;
     }
 }
Exemple #7
0
 public static Vector3 GetLinearAcceleration(this MyPhysicsComponentBase Physics)
 {
     if (Physics.CanUpdateAccelerations && Physics.LinearAcceleration == Vector3.Zero)
     {
         Physics.UpdateAccelerations();
     }
     return(Physics.LinearAcceleration);
 }
Exemple #8
0
 public static bool ActivateIfNeeded(this MyPhysicsComponentBase body)
 {
     if (body.IsActive || body.IsStatic)
     {
         return(false);
     }
     body.ForceActivate();
     return(true);
 }
 void container_ComponentRemoved(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
         m_syncObject = null;
     else if (type == typeof(MyPhysicsComponentBase))
         m_physics = null;
     else if (type == typeof(MyHierarchyComponentBase))
         m_hierarchy = null;
 }
 void container_ComponentAdded(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
         m_syncObject = comp as MySyncComponentBase;
     else if (type == typeof(MyPhysicsComponentBase))
         m_physics = comp as MyPhysicsComponentBase;
     else if (type == typeof(MyHierarchyComponentBase))
         m_hierarchy = comp as MyHierarchyComponentBase;
 }
 public override void OnAddedToContainer()
 {
     base.OnAddedToContainer();
     m_syncObject = Container.Get<MySyncComponentBase>();
     m_physics = Container.Get<MyPhysicsComponentBase>();
     m_hierarchy = Container.Get<MyHierarchyComponentBase>();
     Container.ComponentAdded += container_ComponentAdded;
     Container.ComponentRemoved += container_ComponentRemoved;
 }
 public override void OnAddedToContainer()
 {
     base.OnAddedToContainer();
     m_syncObject                = Container.Get <MySyncComponentBase>();
     m_physics                   = Container.Get <MyPhysicsComponentBase>();
     m_hierarchy                 = Container.Get <MyHierarchyComponentBase>();
     Container.ComponentAdded   += container_ComponentAdded;
     Container.ComponentRemoved += container_ComponentRemoved;
 }
Exemple #13
0
 protected override unsafe void UpdateDoorPosition()
 {
     if (base.m_subparts.Count != 0)
     {
         float num  = (float)Math.Sqrt(1.1375000476837158);
         float z    = base.m_currOpening * 1.75f;
         float num3 = base.m_currOpening * 1.570796f;
         if (z < num)
         {
             num3 = (float)Math.Asin((double)(z / 1.2f));
         }
         else
         {
             float num5 = (1.75f - z) / (1.75f - num);
             num3 = 1.570796f - ((num5 * num5) * ((float)(1.570796012878418 - Math.Asin((double)(num / 1.2f)))));
         }
         z--;
         MyGridPhysics bodyA = base.CubeGrid.Physics;
         bool          flag  = !Sync.IsServer;
         int           num4  = 0;
         bool          flag2 = true;
         foreach (MyEntitySubpart subpart in base.m_subparts)
         {
             if (subpart != null)
             {
                 Matrix  matrix;
                 Matrix *matrixPtr1;
                 Matrix.CreateRotationY(flag2 ? num3 : -num3, out matrix);
                 matrixPtr1.Translation = new Vector3(flag2 ? -1.2f : 1.2f, 0f, z);
                 matrixPtr1             = (Matrix *)ref matrix;
                 Matrix renderLocal             = matrix * base.PositionComp.LocalMatrix;
                 MyPhysicsComponentBase physics = subpart.Physics;
                 if (flag && (physics != null))
                 {
                     Matrix *matrixPtr2;
                     Matrix  identity = Matrix.Identity;
                     matrixPtr2.Translation = new Vector3(flag2 ? -0.55f : 0.55f, 0f, 0f);
                     matrixPtr2             = (Matrix *)ref identity;
                     Matrix *matrixPtr3 = (Matrix *)ref identity;
                     Matrix.Multiply(ref (Matrix) ref matrixPtr3, ref matrix, out identity);
                     subpart.PositionComp.SetLocalMatrix(ref identity, null, true);
                 }
                 subpart.PositionComp.SetLocalMatrix(ref matrix, physics, true, ref renderLocal, true);
                 if (((bodyA != null) && (physics != null)) && (base.m_subpartConstraintsData.Count > num4))
                 {
                     bodyA.RigidBody.Activate();
                     physics.RigidBody.Activate();
                     matrix = Matrix.Invert(matrix);
                     base.m_subpartConstraintsData[num4].SetInBodySpace(base.PositionComp.LocalMatrix, matrix, bodyA, (MyPhysicsBody)physics);
                 }
             }
             flag2 = !flag2;
             num4++;
         }
     }
 }
        internal static MyEntity Spawn(MyInventoryItem item, MatrixD worldMatrix, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var floatingBuilder = PrepareBuilder(ref item);

            floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
            var thrownEntity = MyEntities.CreateFromObjectBuilderAndAdd(floatingBuilder);

            thrownEntity.Physics.ForceActivate();
            ApplyPhysics(thrownEntity, motionInheritedFrom);
            Debug.Assert(thrownEntity.Save == true, "Thrown item will not be saved. Feel free to ignore this.");
            return(thrownEntity);
        }
Exemple #15
0
        private static void AddToPos(MyEntity thrownEntity, Vector3D pos, MyPhysicsComponentBase motionInheritedFrom)
        {
            Vector3 forward = MyUtils.GetRandomVector3Normalized();
            Vector3 vector2 = MyUtils.GetRandomVector3Normalized();

            while (forward == vector2)
            {
                vector2 = MyUtils.GetRandomVector3Normalized();
            }
            thrownEntity.WorldMatrix = MatrixD.CreateWorld(pos, forward, Vector3.Cross(Vector3.Cross(forward, vector2), forward));
            MyEntities.Add(thrownEntity, true);
            ApplyPhysics(thrownEntity, motionInheritedFrom);
        }
 void container_ComponentAdded(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
     {
         m_syncObject = comp as MySyncComponentBase;
     }
     else if (type == typeof(MyPhysicsComponentBase))
     {
         m_physics = comp as MyPhysicsComponentBase;
     }
     else if (type == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = comp as MyHierarchyComponentBase;
     }
 }
 void container_ComponentRemoved(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
     {
         m_syncObject = null;
     }
     else if (type == typeof(MyPhysicsComponentBase))
     {
         m_physics = null;
     }
     else if (type == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = null;
     }
 }
Exemple #18
0
 public override void UpdateBeforeSimulation()
 {
     if (MyDebugDrawSettings.DEBUG_DRAW_TREE_COLLISION_SHAPES)
     {
         MyPhysicsComponentBase physics = base.Physics;
         if (physics != null)
         {
             HkRigidBody rigidBody = physics.RigidBody;
             if (rigidBody != null)
             {
                 int shapeIndex = 0;
                 MyPhysicsDebugDraw.DrawCollisionShape(rigidBody.GetShape(), physics.GetWorldMatrix(), 1f, ref shapeIndex, physics.IsActive ? "A" : "I", false);
             }
         }
     }
 }
Exemple #19
0
        private void UninstallToWorld(object userdata, MyDefinitionId toremove, ref int removecount)
        {
            var item = new MyInventoryItem();

            item.Init(toremove, removecount);
            MyPhysicsComponentBase phys = null;

            {
                var tmp = Entity;
                while (tmp != null && phys == null)
                {
                    phys = tmp.Physics;
                    tmp  = tmp.Parent;
                }
            }
            MySession.Static.Components.Get <MyFloatingObjects>()?.Spawn(item, Entity.WorldMatrix, phys);
        }
        private static bool CanSleepPhysics(MyPhysicsComponentBase check, MyPhysicsComponentBase relativeTo)
        {
            const double toleranceLinear  = .025f;
            const double toleranceAngular = .1f;
            var          checkLinVel      = check.LinearVelocity.LengthSquared();
            var          checkAngVel      = check.AngularVelocity.LengthSquared();

            if (checkLinVel < toleranceLinear && checkAngVel < toleranceAngular)
            {
                return(true);
            }
            if (relativeTo == null)
            {
                return(false);
            }
            checkLinVel = Math.Abs(checkLinVel - relativeTo.LinearVelocity.LengthSquared());
            checkAngVel = Math.Abs(checkAngVel - relativeTo.AngularVelocity.LengthSquared());
            return(checkLinVel < toleranceLinear && checkAngVel < toleranceAngular);
        }
        internal static MyEntity Spawn(MyInventoryItem item, BoundingBoxD box, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var floatingBuilder = PrepareBuilder(ref item);
            var thrownEntity    = MyEntities.CreateFromObjectBuilder(floatingBuilder);

            System.Diagnostics.Debug.Assert(thrownEntity != null);
            if (thrownEntity != null)
            {
                var size     = thrownEntity.PositionComp.LocalVolume.Radius;
                var halfSize = box.Size / 2 - new Vector3(size);
                halfSize = Vector3.Max(halfSize, Vector3.Zero);

                box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
                var pos = MyUtils.GetRandomPosition(ref box);

                AddToPos(thrownEntity, pos, motionInheritedFrom);

                thrownEntity.Physics.ForceActivate();
            }
            return(thrownEntity);
        }
Exemple #22
0
        private float GetObserverAngularVelocityDiff()
        {
            MyGridPhysics physics = base.CubeGrid.Physics;

            if ((physics != null) && (physics.LinearVelocity.LengthSquared() > 16f))
            {
                IMyControllableEntity controlledEntity = MySession.Static.ControlledEntity;
                if (controlledEntity != null)
                {
                    VRage.Game.Entity.MyEntity entity = controlledEntity.Entity;
                    if (entity != null)
                    {
                        MyPhysicsComponentBase base2 = entity.GetTopMostParent(null).Physics;
                        if (base2 != null)
                        {
                            return((physics.AngularVelocity - base2.AngularVelocity).Length());
                        }
                    }
                }
            }
            return(0f);
        }
Exemple #23
0
        /// <summary>
        /// Adjusts input for the autopilot's velocity and entity's velocity.
        /// </summary>
        /// <param name="input">Original TestInput with Direction as the desired direction of travel and Length as the distance to the destination.</param>
        /// <param name="adjusted">Offset will be zero, Direction and Length will be modified from input for the velocity of autopilot and entity.</param>
        /// <param name="entity">The potential obstruction, if null, assumes a static entity</param>
        public void AdjustForCurrentVelocity(ref TestInput input, out TestInput adjusted, MyEntity entity, bool destination)
        {
            Vector3 autopilotVelocity = AutopilotGrid.Physics.LinearVelocity;
            Vector3 relativeVelocity;

            if (entity == null)
            {
                relativeVelocity = autopilotVelocity;
            }
            else
            {
                MyPhysicsComponentBase physics = entity.GetTopMostParent().Physics;
                if (physics == null || physics.IsStatic)
                {
                    relativeVelocity = autopilotVelocity;
                }
                else
                {
                    Vector3 entityVelocity = physics.LinearVelocity;
                    Vector3.Subtract(ref autopilotVelocity, ref entityVelocity, out relativeVelocity);
                }
            }

            Vector3.Add(ref relativeVelocity, ref input.Direction, out adjusted.Direction);
            adjusted.Offset = Vector3D.Zero;
            if (adjusted.Direction == Vector3.Zero)
            {
                adjusted.Length = 0f;
            }
            else
            {
                adjusted.Length = 20f + adjusted.Direction.Normalize() * Pathfinder.SpeedFactor;
                if (destination && input.Length < adjusted.Length)
                {
                    adjusted.Length = input.Length;
                }
            }
        }
Exemple #24
0
 public static void Spawn(MyPhysicalInventoryItem item, MatrixD worldMatrix, MyPhysicsComponentBase motionInheritedFrom, Action <MyEntity> completionCallback)
 {
     if (MyEntities.IsInsideWorld(worldMatrix.Translation))
     {
         MyObjectBuilder_FloatingObject objectBuilder = PrepareBuilder(ref item);
         objectBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
         Vector3D?relativeOffset = null;
         MyEntities.CreateFromObjectBuilderParallel(objectBuilder, true, delegate(MyEntity entity) {
             if ((entity != null) && (entity.Physics != null))
             {
                 entity.Physics.ForceActivate();
                 ApplyPhysics(entity, motionInheritedFrom);
                 if (MyVisualScriptLogicProvider.ItemSpawned != null)
                 {
                     MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, entity.EntityId, item.Amount.ToIntSafe(), worldMatrix.Translation);
                 }
                 if (completionCallback != null)
                 {
                     completionCallback(entity);
                 }
             }
         }, null, null, relativeOffset, false, false);
     }
 }
        public static MyEntity Spawn(MyInventoryItem item, BoundingSphereD sphere, MyPhysicsComponentBase motionInheritedFrom = null, MyVoxelMaterialDefinition voxelMaterial = null)
        {
            ProfilerShort.Begin("MyFloatingObjects.Spawn");
            var floatingBuilder = PrepareBuilder(ref item);

            ProfilerShort.Begin("Create");
            var thrownEntity = MyEntities.CreateFromObjectBuilder(floatingBuilder);

            ProfilerShort.End();
            ((MyFloatingObject)thrownEntity).VoxelMaterial = voxelMaterial;

            var size       = thrownEntity.PositionComp.LocalVolume.Radius;
            var sphereSize = sphere.Radius - size;

            sphereSize = Math.Max(sphereSize, 0);

            sphere = new BoundingSphereD(sphere.Center, sphereSize);

            var pos = MyUtils.GetRandomBorderPosition(ref sphere);

            AddToPos(thrownEntity, pos, motionInheritedFrom);
            ProfilerShort.End();
            return(thrownEntity);
        }
        private void OnPhysicsChanged(MyPhysicsComponentBase obj)
        {
            if (!obj.Enabled)
            {
                return;
            }
            var objectMass = obj.Mass;
            var myMass     = objectMass;

            if (objectMass <= 0)
            {
                objectMass = 1f;
            }
            var block = Container.Get <MyBlockComponent>();

            if (block != null)
            {
                var blockDef = MyDefinitionManager.Get <MyBlockDefinition>(block.DefinitionId);
                if (blockDef != null)
                {
                    myMass = blockDef.Mass;
                }
            }

            var ratio = MathHelper.Clamp((Definition.MassInfluence ?? myMass) / objectMass, 0, 1);

            if (Definition.LinearDamping.HasValue)
            {
                obj.LinearDamping = MathHelper.Lerp(DefaultLinearDamping, Definition.LinearDamping.Value, ratio);
            }

            if (Definition.AngularDamping.HasValue)
            {
                obj.AngularDamping = MathHelper.Lerp(DefaultAngularDamping, Definition.AngularDamping.Value, ratio);
            }
        }
Exemple #27
0
        private void BlockMoved(MyBlockComponent block, MyGridDataComponent gridData)
        {
            var nextGridPhys = gridData?.Container?.Get <MyPhysicsComponentBase>();
            var nextGridPos  = gridData?.Container?.Get <MyPositionComponentBase>();

            if (nextGridPos == _gridPositionComponent && nextGridPhys == _gridPhysicsComponent)
            {
                return;
            }
            if (_gridPositionComponent != null)
            {
                _gridPositionComponent.OnPositionChanged -= WakePhysics;
            }
            _gridPhysicsComponent  = nextGridPhys;
            _gridPositionComponent = nextGridPos;
            if (_gridPositionComponent != null)
            {
                WakePhysics(null);
            }
            else
            {
                RemoveFixedUpdate(Simulate);
            }
        }
        public static MyEntity Spawn(MyPhysicalInventoryItem item, Vector3D position, Vector3D forward, Vector3D up, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var orientedForward = forward;
            var orientedUp      = up;

            var left = Vector3D.Cross(up, forward);

            MyPhysicalItemDefinition itemDefinition = null;

            if (MyDefinitionManager.Static.TryGetDefinition <MyPhysicalItemDefinition>(item.Content.GetObjectId(), out itemDefinition))
            {
                if (itemDefinition.RotateOnSpawnX)
                {
                    orientedForward = up;
                    orientedUp      = -forward;
                }
                if (itemDefinition.RotateOnSpawnY)
                {
                    orientedForward = left;
                }
                if (itemDefinition.RotateOnSpawnZ)
                {
                    orientedUp = -left;
                }
            }

            return(Spawn(item, MatrixD.CreateWorld(position, orientedForward, orientedUp), motionInheritedFrom));
        }
Exemple #29
0
        public static MyEntity Spawn(MyPhysicalInventoryItem item, BoundingSphereD sphere, MyPhysicsComponentBase motionInheritedFrom = null, MyVoxelMaterialDefinition voxelMaterial = null)
        {
            ProfilerShort.Begin("MyFloatingObjects.Spawn");
            var floatingBuilder = PrepareBuilder(ref item);

            ProfilerShort.Begin("Create");
            var thrownEntity = MyEntities.CreateFromObjectBuilder(floatingBuilder);

            ProfilerShort.End();
            ((MyFloatingObject)thrownEntity).VoxelMaterial = voxelMaterial;

            var size       = thrownEntity.PositionComp.LocalVolume.Radius;
            var sphereSize = sphere.Radius - size;

            sphereSize = Math.Max(sphereSize, 0);

            sphere = new BoundingSphereD(sphere.Center, sphereSize);

            var pos = MyUtils.GetRandomBorderPosition(ref sphere);

            AddToPos(thrownEntity, pos, motionInheritedFrom);
            ProfilerShort.End();

            //Visual scripting action
            if (thrownEntity != null && MyVisualScriptLogicProvider.ItemSpawned != null)
            {
                MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, thrownEntity.EntityId, item.Amount.ToIntSafe(), pos);
            }
            return(thrownEntity);
        }
Exemple #30
0
        internal static MyEntity Spawn(MyPhysicalInventoryItem item, BoundingBoxD box, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var floatingBuilder = PrepareBuilder(ref item);
            var thrownEntity    = MyEntities.CreateFromObjectBuilder(floatingBuilder);

            System.Diagnostics.Debug.Assert(thrownEntity != null);
            if (thrownEntity != null)
            {
                var size     = thrownEntity.PositionComp.LocalVolume.Radius;
                var halfSize = box.Size / 2 - new Vector3(size);
                halfSize = Vector3.Max(halfSize, Vector3.Zero);

                box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
                var pos = MyUtils.GetRandomPosition(ref box);

                AddToPos(thrownEntity, pos, motionInheritedFrom);

                thrownEntity.Physics.ForceActivate();

                //Visual scripting action
                if (MyVisualScriptLogicProvider.ItemSpawned != null)
                {
                    MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, thrownEntity.EntityId, item.Amount.ToIntSafe(), pos);
                }
            }
            return(thrownEntity);
        }
Exemple #31
0
        public static MyEntity Spawn(MyPhysicalInventoryItem item, MatrixD worldMatrix, MyPhysicsComponentBase motionInheritedFrom = null)
        {
            var floatingBuilder = PrepareBuilder(ref item);

            floatingBuilder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);
            var thrownEntity = MyEntities.CreateFromObjectBuilderAndAdd(floatingBuilder);

            if (thrownEntity != null)
            {
                thrownEntity.Physics.ForceActivate();
                ApplyPhysics(thrownEntity, motionInheritedFrom);
                Debug.Assert(thrownEntity.Save == true, "Thrown item will not be saved. Feel free to ignore this.");

                //Visual scripting action
                if (MyVisualScriptLogicProvider.ItemSpawned != null)
                {
                    MyVisualScriptLogicProvider.ItemSpawned(item.Content.TypeId.ToString(), item.Content.SubtypeName, thrownEntity.EntityId, item.Amount.ToIntSafe(), worldMatrix.Translation);
                }
            }
            return(thrownEntity);
        }
 public static bool IsInWorldWelded(this MyPhysicsComponentBase body)
 {
     return(body != null && (body is MyPhysicsBody) && IsInWorldWelded((MyPhysicsBody)body));
 }
 public void Weld(MyPhysicsComponentBase other, bool recreateShape = true)
 {
     Weld(other as MyPhysicsBody, recreateShape);
 }
 internal static MyEntity Spawn(MyInventoryItem item, Vector3D position, Vector3D forward, Vector3D up, MyPhysicsComponentBase motionInheritedFrom = null)
 {
     return(Spawn(item, MatrixD.CreateWorld(position, forward, up), motionInheritedFrom));
 }