internal void ApplyForceEffect(LFloat deltaTime) { bool sliding = mLinearVelocity.sqrMagnitude > 0; bool rotating = mAngularVelocity > 0; // linear velocity LVector2 va = mUserForce * mMassInverse; if (!mIsFixed) { va += LPhysicsStatic2D.LGravity * mGravityScale; } if (sliding && mLinearDrag > 0) { LFloat da = mLinearDrag * mMassInverse; LFloat minr = (mLinearVelocity / deltaTime).sqrMagnitude; if (da * da >= minr) { va = LVector2.zero; mLinearVelocity = LVector2.zero; } else { va -= da * mLinearVelocity.normalized; } } if (va != LVector2.zero) { mLinearVelocity += va * deltaTime; } // angular velocity LFloat ra = mUserTorque * mInertiaInverse; if (rotating && mAngularDrag > 0) { LFloat da = mAngularDrag * mInertiaInverse; LFloat minr = mAngularVelocity / deltaTime; if (da >= minr) { ra = 0; mAngularVelocity = 0; } else { ra -= da * LMath.Sign(ra); } } if (ra != 0) { mAngularVelocity += ra * deltaTime; } }
public void DoInit() { parts.Sort((a, b) => LMath.Sign(a.startFrame - b.startFrame)); var time = LFloat.MinValue; foreach (var part in parts) { var partDeadTime = part.DeadTimer; if (partDeadTime > time) { time = partDeadTime; } } maxPartTime = time + doneDelay; }
void ResortSkill() { parts.Sort((a, b) => LMath.Sign(a.startTimer - b.startTimer)); var time = LFloat.MinValue; foreach (var part in parts) { part.startTimer = part.startTimer * SkillPart.AnimFrameScale; var partDeadTime = part.DeadTimer; if (partDeadTime > time) { time = partDeadTime; } } maxPartTime = time + doneDelay; }