public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); if (ResourceSink != null) { ResourceSink.Update(); } if (IsWorking) { foreach (IMyEntity entityInterface in m_containedEntities) { MyEntity entity = entityInterface as MyEntity; MyCharacter character = entity as MyCharacter; IMyVirtualMass mass = entity as IMyVirtualMass; var naturalGravityMultiplier = MyGravityProviderSystem.CalculateHighestNaturalGravityMultiplierInPoint(entity.WorldMatrix.Translation); var gravity = GetWorldGravity(entity.WorldMatrix.Translation) * MyGravityProviderSystem.CalculateArtificialGravityStrengthMultiplier(naturalGravityMultiplier); if (mass != null && entity.Physics.RigidBody.IsActive) { if (MyDebugDrawSettings.ENABLE_DEBUG_DRAW && MyDebugDrawSettings.DEBUG_DRAW_MISCELLANEOUS) { MyRenderProxy.DebugDrawSphere(entity.WorldMatrix.Translation, 0.2f, mass.IsWorking ? Color.Blue : Color.Red, 1.0f, false); } if (mass.IsWorking && entity.Physics.RigidBody.IsActive) { ((IMyEntity)mass.CubeGrid).Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * mass.VirtualMass, entity.WorldMatrix.Translation, null); } } else if (!entity.Physics.IsKinematic && !entity.Physics.IsStatic && entity.Physics.RigidBody2 == null && //jn: TODO this is actualy check for large grid character == null) { if (entity.Physics.RigidBody != null && entity.Physics.RigidBody.IsActive) { //<ib.change> increase gravity for floating objects //entity.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * entity.Physics.RigidBody.Mass, null, null); if (entity is MyFloatingObject) { var floatingEntity = entity as MyFloatingObject; float w = (floatingEntity.HasConstraints()) ? 2.0f : 1.0f; entity.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, w * gravity * entity.Physics.RigidBody.Mass, null, null); } else { entity.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, gravity * entity.Physics.RigidBody.Mass, null, null); } } } } } }