public override void blasted(ref _Bullet3.DamageSourceUnit ds, float pressure, float boringFactor, Vector3 center, float radius, Collider collider, _Action3 attacker) { var act = this.act; var line = act.tfBody.position - center; var sqrmag = line.sqrMagnitude; var magR = MathOpt.invSqrt(sqrmag); var mag = magR * sqrmag; //if( action.ragdoll.isRagdollMode ) action.ragdoll.rbBase.AddForceAtPosition( line * ( magR * pressure * 0.6f ) + Vector3.up * 0.4f, center, ForceMode.Impulse ); //else act.rb.AddForceAtPosition( line * ( magR * pressure * 0.6f ) + Vector3.up * 0.4f, center, ForceMode.Impulse ); //act.rb.AddExplosionForce( pressure, center, radius, 0.8f, ForceMode.Impulse );// //act.rb.AddForceAtPosition( pressure * ( act.tfBody.position - center ).normalized, center, ForceMode.Impulse ); //if( act.ragdoll.isRagdollMode ) foreach( var i in act.ragdoll.rbs ) i.AddForceAtPosition( ( line + Vector3.up ) * ( magR * pressure ), center, ForceMode.Impulse ); //else rbHit.AddForceAtPosition((line + Vector3.up) * (magR * pressure), center, ForceMode.Impulse); //rbHit.AddExplosionForce( pressure, center, radius, 0.8f, ForceMode.Impulse );// if (!attacker || attacker.targetTeam.isMate(act.attachedTeam)) { if (!act.isDead) { //var level = ( act.move.speed > 1.5f ) | ( mag / radius < 0.4f ) ? (int)ds.moveStoppingDamage + 1 : 0; var level = act.isAvoiding ? (int)(ds.moveStoppingDamage * 0.1f + 1) : 0; act.changeToBlowingMode(attacker, level); ds.moveStoppingDamage = 0.0f; //armor.applyDamage( ref ds, 1.5f, 1.0f ); } else { act.ragdoll.switchToRagdoll(); } } }
/// <summary> /// これはよくわからない。わすれました。両端が引っ張られて縮むのかな…。 /// いや締まるんじゃないかな、まっすぐに /// </summary> public void shrink(LineUnit line, Vector3 first, Vector3 last) { var ifirst = line.pointId; var ilast = ifirst + numberOfSegmnts + 1; velocities[ifirst] = (first - positions[ifirst]) * GM.t.deltaR; velocities[ilast] = (last - positions[ilast]) * GM.t.deltaR; positions[ifirst] = first; positions[ilast] = last; var dt = GM.t.delta; // > 0.1f ? 0.1f : GM.t.delta; var move = (last - first); var sqrmag = move.sqrMagnitude; var magR = MathOpt.invSqrt(sqrmag); var unit = magR * sqrmag / (numberOfSegmnts + 1); var dir = move * magR; for (var i = ifirst + 1; i < ilast; i++) { var desired = first + dir * (unit * i); // 速度 velocities[i] = (desired - positions[i]) * 0.5f * 120.0f; } for (var i = ifirst + 1; i < ilast; i++) { // 移動 positions[i] += velocities[i] * dt; } }
// ラインの取得・返却 ------------------------------------------------ /// <summary> /// ラインの取得。始点・終点を指定する。間の点は平均的に算出される。 /// </summary> /// <param name="start">始点</param> /// <param name="end">終点</param> /// <returns>ライン情報オブジェクト</returns> public virtual TLineUnit instantiate(Vector3 start, Vector3 end) { var line = lines.rent(); var unitLength = numberOfSegmnts + 2; var numOfSegR = 1.0f / (numberOfSegmnts + 1); positions[line.pointId] = start; positions[line.pointId + unitLength - 1] = end; var move = end - start; var sqrmag = move.sqrMagnitude; var totalR = MathOpt.invSqrt(sqrmag); var dir = move * totalR; var span = totalR * sqrmag * numOfSegR; var ist = line.pointId + 1; var iover = ist + numberOfSegmnts; for (var i = ist; i < iover; i++) { positions[i] = start + dir * (span * i); } return(line); }