public MyEntityPhysicsStateGroupWithSupport(MyEntity entity, IMyReplicable ownerReplicable) : base(entity, ownerReplicable) { m_onSupportMove = OnSupportMove; m_onSupportVelocityChanged = OnSupportVelocityChanged; if (Sync.IsServer) OnMoved += PhysicsStateGroup_OnMoved; }
public MyEntityPhysicsStateGroupWithSupport(MyEntity entity, IMyReplicable ownerReplicable) : base(entity, ownerReplicable) { m_onSupportMove = OnSupportMove; m_onSupportVelocityChanged = OnSupportVelocityChanged; if (Sync.IsServer) { OnMoved += PhysicsStateGroup_OnMoved; } }
/// <summary> /// Serializes velocities into 12 bytes. /// </summary> protected static void SerializeVelocities(BitStream stream, MyEntity entity, float simulationRatio, bool applyWhenReading, bool movingOnServer, VelocityDelegate velocityHandler = null) { if (stream.Writing) { WriteVelocities(stream, entity, simulationRatio, movingOnServer); } else { ReadVelocities(stream, entity, simulationRatio, movingOnServer, ref m_readLinearVelocity, ref m_readAngularVelocity); float linearVelocityDiff = 0.0f; float angularVelocityDiff = 0.0f; if (entity != null && entity.Physics != null) { linearVelocityDiff = (entity.Physics.LinearVelocity - m_readLinearVelocity).LengthSquared(); angularVelocityDiff = (entity.Physics.AngularVelocity - m_readAngularVelocity).LengthSquared(); } if ((linearVelocityDiff > 0.001f || angularVelocityDiff > 0.001f || applyWhenReading) && entity.Physics != null) { Vector3 oldLinear = entity.Physics.LinearVelocity; entity.Physics.LinearVelocity = m_readLinearVelocity; entity.Physics.AngularVelocity = m_readAngularVelocity; entity.Physics.UpdateAccelerations(); if (velocityHandler != null && MyFakes.COMPENSATE_SPEED_WITH_SUPPORT) { velocityHandler(ref oldLinear, ref m_readLinearVelocity); } } } }
/// <summary> /// Serializes velocities into 12 bytes. /// </summary> public static void SerializeVelocities(BitStream stream, MyEntity entity, float simulationRatio, bool applyWhenReading, bool movingOnServer, VelocityDelegate velocityHandler = null) { if (stream.Writing) { WriteVelocities(stream, entity, simulationRatio, movingOnServer); } else { ReadVelocities(stream, entity, simulationRatio, movingOnServer, ref m_readLinearVelocity, ref m_readAngularVelocity); if (applyWhenReading && entity.Physics != null) { Vector3 oldLinear = entity.Physics.LinearVelocity; entity.Physics.LinearVelocity = m_readLinearVelocity; entity.Physics.AngularVelocity = m_readAngularVelocity; entity.Physics.UpdateAccelerations(); if (velocityHandler != null && MyFakes.COMPENSATE_SPEED_WITH_SUPPORT) { velocityHandler(ref oldLinear, ref m_readLinearVelocity); } } } }
/// <summary> /// Serializes velocities into 12 bytes. /// </summary> protected void SerializeVelocities(BitStream stream, MyEntity entity, float simulationRatio, bool applyWhenReading, bool movingOnServer, VelocityDelegate velocityHandler = null) { if (stream.Writing) { WriteVelocities(stream, entity, simulationRatio, movingOnServer); } else { ReadVelocities(stream, entity, simulationRatio,movingOnServer, ref m_readLinearVelocity, ref m_readAngularVelocity); float linearVelocityDiff = 0.0f; float angularVelocityDiff = 0.0f; if (entity != null && entity.Physics != null) { linearVelocityDiff = (entity.Physics.LinearVelocity - m_readLinearVelocity).LengthSquared(); angularVelocityDiff = (entity.Physics.AngularVelocity - m_readAngularVelocity).LengthSquared(); } if ((linearVelocityDiff > 0.001f || angularVelocityDiff > 0.001f || applyWhenReading) && entity.Physics != null) { Vector3 oldLinear = entity.Physics.LinearVelocity; entity.Physics.LinearVelocity = m_readLinearVelocity; entity.Physics.AngularVelocity = m_readAngularVelocity; entity.Physics.UpdateAccelerations(); if (velocityHandler != null && MyFakes.COMPENSATE_SPEED_WITH_SUPPORT) { velocityHandler(ref oldLinear, ref m_readLinearVelocity); } } } }
/// <summary> /// Serializes velocities into 12 bytes. /// </summary> public static void SerializeVelocities(BitStream stream, MyEntity entity, float simulationRatio, bool applyWhenReading, bool movingOnServer, VelocityDelegate velocityHandler = null) { if(stream.Writing) { WriteVelocities(stream, entity, simulationRatio, movingOnServer); } else { ReadVelocities(stream, entity, simulationRatio,movingOnServer, ref m_readLinearVelocity, ref m_readAngularVelocity); if (applyWhenReading && entity.Physics != null) { Vector3 oldLinear = entity.Physics.LinearVelocity; entity.Physics.LinearVelocity = m_readLinearVelocity; entity.Physics.AngularVelocity = m_readAngularVelocity; entity.Physics.UpdateAccelerations(); if (velocityHandler != null && MyFakes.COMPENSATE_SPEED_WITH_SUPPORT) { velocityHandler(ref oldLinear, ref m_readLinearVelocity); } } } }