private void UpdateCollisionSpheres(Vec3 position, Vec3 velocity, ItemObject missileItem) { MissionWeapon missionWeapon = new MissionWeapon(missileItem, (ItemModifier)null, (Banner)null); Vec3 vec3_1 = velocity; double num1 = (double)vec3_1.Normalize(); Vec3 va = vec3_1; double num2 = (double)va.Normalize(); float x = va.x; float y = va.y; float z = va.z; float num3 = (float)((double)x * (double)position.x + (double)y * (double)position.y + (double)z * (double)position.z); Vec3 vb = new Vec3(1f, 1f); float num4 = (double)Math.Abs(z - 0.0f) < 1.40129846432482E-45 ? 1f : z; vb.z = (float)(-(double)num3 - (double)x * (1.0 - (double)position.x) - (double)y * (1.0 - (double)position.y) + (double)num4 * (double)position.z) / num4; double num5 = (double)vb.Normalize(); Vec3 vec3_2 = Vec3.CrossProduct(va, vb); double num6 = (double)vec3_2.Normalize(); Vec3[] vec3Array = new Vec3[0]; for (int index = 0; index < 0; ++index) { float num7 = (float)((double)index * 360.0 / 0.0 * 3.14159274101257 / 180.0); vec3Array[index] = va + vb * (float)Math.Sin((double)num7) * 0.1f + vec3_2 * (float)Math.Cos((double)num7) * 0.1f; } for (int index = 0; index < vec3Array.Length; ++index) { Vec3 missileDirection = vec3Array[index]; WeaponData weaponData = missionWeapon.GetWeaponData(false); Vec3 missileCollisionPoint = Mission.Current.GetMissileCollisionPoint(position, missileDirection, velocity.Length, in weaponData); MatrixFrame frame = this.collisionEntity[index].GetFrame(); frame.origin = missileCollisionPoint; this.collisionEntity[index].SetFrame(ref frame); } }
public static GameEntity Instantiate( Scene scene, MissionWeapon weapon, bool showHolsterWithWeapon, bool needBatchedVersion) { WeaponData weaponData = weapon.GetWeaponData(needBatchedVersion); WeaponStatsData[] weaponStatsData = weapon.GetWeaponStatsData(); WeaponData ammoWeaponData = weapon.GetAmmoWeaponData(needBatchedVersion); WeaponStatsData[] ammoWeaponStatsData = weapon.GetAmmoWeaponStatsData(); GameEntity fromWeapon = MBAPI.IMBGameEntityExtensions.CreateFromWeapon(scene.Pointer, in weaponData, weaponStatsData, weaponStatsData.Length, in ammoWeaponData, ammoWeaponStatsData, ammoWeaponStatsData.Length, showHolsterWithWeapon); weaponData.DeinitializeManagedPointers(); return(fromWeapon); }