BannerlordTwitch.Util.RenderExport.GetItemPoseAndCameraForCraftedItem C# (CSharp) Method

GetItemPoseAndCameraForCraftedItem() private static method

private static GetItemPoseAndCameraForCraftedItem ( ItemObject item, Scene scene, Camera &camera, MatrixFrame &itemFrame, MatrixFrame &itemFrame1, MatrixFrame &itemFrame2 ) : void
item ItemObject
scene Scene
camera Camera
itemFrame MatrixFrame
itemFrame1 MatrixFrame
itemFrame2 MatrixFrame
return void
		private static void GetItemPoseAndCameraForCraftedItem(ItemObject item, Scene scene, ref Camera camera, ref MatrixFrame itemFrame, ref MatrixFrame itemFrame1, ref MatrixFrame itemFrame2)
		{
			if (camera == null)
			{
				camera = Camera.CreateCamera();
			}
			itemFrame = MatrixFrame.Identity;
			WeaponClass weaponClass = item.WeaponDesign.Template.WeaponUsageDatas.First<WeaponUsageData>().WeaponClass;
			Vec3 u = itemFrame.rotation.u;
			Vec3 v = itemFrame.origin - u * (item.WeaponDesign.CraftedWeaponLength * 0.5f);
			Vec3 v2 = v + u * item.WeaponDesign.CraftedWeaponLength;
			Vec3 v3 = v - u * item.WeaponDesign.BottomPivotOffset;
			int num = 0;
			Vec3 v4 = default(Vec3);
			foreach (float num2 in item.WeaponDesign.TopPivotOffsets)
			{
				if (num2 > Math.Abs(1E-05f))
				{
					Vec3 vec = v + u * num2;
					if (num == 1)
					{
						v4 = vec;
					}
					num++;
				}
			}
			if (weaponClass == WeaponClass.OneHandedSword || weaponClass == WeaponClass.TwoHandedSword)
			{
				GameEntity gameEntity = scene.FindEntityWithTag("sword_camera");
				Vec3 vec2 = default(Vec3);
				gameEntity.GetCameraParamsFromCameraScript(camera, ref vec2);
				gameEntity.SetVisibilityExcludeParents(false);
				Vec3 v5 = itemFrame.TransformToLocal(v3);
				MatrixFrame identity = MatrixFrame.Identity;
				identity.origin = -v5;
				GameEntity gameEntity2 = scene.FindEntityWithTag("sword");
				gameEntity2.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity2.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity);
			}
			if (weaponClass == WeaponClass.OneHandedAxe || weaponClass == WeaponClass.TwoHandedAxe)
			{
				GameEntity gameEntity3 = scene.FindEntityWithTag("axe_camera");
				Vec3 vec3 = default(Vec3);
				gameEntity3.GetCameraParamsFromCameraScript(camera, ref vec3);
				gameEntity3.SetVisibilityExcludeParents(false);
				Vec3 v6 = itemFrame.TransformToLocal(v4);
				MatrixFrame identity2 = MatrixFrame.Identity;
				identity2.origin = -v6;
				GameEntity gameEntity4 = scene.FindEntityWithTag("axe");
				gameEntity4.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity4.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity2);
			}
			if (weaponClass == WeaponClass.Dagger)
			{
				GameEntity gameEntity5 = scene.FindEntityWithTag("sword_camera");
				Vec3 vec4 = default(Vec3);
				gameEntity5.GetCameraParamsFromCameraScript(camera, ref vec4);
				gameEntity5.SetVisibilityExcludeParents(false);
				Vec3 v7 = itemFrame.TransformToLocal(v3);
				MatrixFrame identity3 = MatrixFrame.Identity;
				identity3.origin = -v7;
				GameEntity gameEntity6 = scene.FindEntityWithTag("sword");
				gameEntity6.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity6.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity3);
			}
			if (weaponClass == WeaponClass.ThrowingAxe)
			{
				GameEntity gameEntity7 = scene.FindEntityWithTag("throwing_axe_camera");
				Vec3 vec5 = default(Vec3);
				gameEntity7.GetCameraParamsFromCameraScript(camera, ref vec5);
				gameEntity7.SetVisibilityExcludeParents(false);
				Vec3 v8 = v + u * item.PrimaryWeapon.CenterOfMass;
				Vec3 v9 = itemFrame.TransformToLocal(v8);
				MatrixFrame identity4 = MatrixFrame.Identity;
				identity4.origin = -v9 * 2.5f;
				GameEntity gameEntity8 = scene.FindEntityWithTag("throwing_axe");
				gameEntity8.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity8.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity4);
				gameEntity8 = scene.FindEntityWithTag("throwing_axe_1");
				gameEntity8.SetVisibilityExcludeParents(false);
				itemFrame1 = gameEntity8.GetGlobalFrame();
				itemFrame1 = itemFrame1.TransformToParent(identity4);
				gameEntity8 = scene.FindEntityWithTag("throwing_axe_2");
				gameEntity8.SetVisibilityExcludeParents(false);
				itemFrame2 = gameEntity8.GetGlobalFrame();
				itemFrame2 = itemFrame2.TransformToParent(identity4);
			}
			if (weaponClass == WeaponClass.Javelin)
			{
				GameEntity gameEntity9 = scene.FindEntityWithTag("javelin_camera");
				Vec3 vec6 = default(Vec3);
				gameEntity9.GetCameraParamsFromCameraScript(camera, ref vec6);
				gameEntity9.SetVisibilityExcludeParents(false);
				Vec3 v10 = itemFrame.TransformToLocal(v4);
				MatrixFrame identity5 = MatrixFrame.Identity;
				identity5.origin = -v10 * 2.2f;
				GameEntity gameEntity10 = scene.FindEntityWithTag("javelin");
				gameEntity10.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity10.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity5);
				gameEntity10 = scene.FindEntityWithTag("javelin_1");
				gameEntity10.SetVisibilityExcludeParents(false);
				itemFrame1 = gameEntity10.GetGlobalFrame();
				itemFrame1 = itemFrame1.TransformToParent(identity5);
				gameEntity10 = scene.FindEntityWithTag("javelin_2");
				gameEntity10.SetVisibilityExcludeParents(false);
				itemFrame2 = gameEntity10.GetGlobalFrame();
				itemFrame2 = itemFrame2.TransformToParent(identity5);
			}
			if (weaponClass == WeaponClass.ThrowingKnife)
			{
				GameEntity gameEntity11 = scene.FindEntityWithTag("javelin_camera");
				Vec3 vec7 = default(Vec3);
				gameEntity11.GetCameraParamsFromCameraScript(camera, ref vec7);
				gameEntity11.SetVisibilityExcludeParents(false);
				Vec3 v11 = itemFrame.TransformToLocal(v2);
				MatrixFrame identity6 = MatrixFrame.Identity;
				identity6.origin = -v11 * 1.4f;
				GameEntity gameEntity12 = scene.FindEntityWithTag("javelin");
				gameEntity12.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity12.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity6);
				gameEntity12 = scene.FindEntityWithTag("javelin_1");
				gameEntity12.SetVisibilityExcludeParents(false);
				itemFrame1 = gameEntity12.GetGlobalFrame();
				itemFrame1 = itemFrame1.TransformToParent(identity6);
				gameEntity12 = scene.FindEntityWithTag("javelin_2");
				gameEntity12.SetVisibilityExcludeParents(false);
				itemFrame2 = gameEntity12.GetGlobalFrame();
				itemFrame2 = itemFrame2.TransformToParent(identity6);
			}
			if (weaponClass == WeaponClass.TwoHandedPolearm || weaponClass == WeaponClass.OneHandedPolearm || weaponClass == WeaponClass.LowGripPolearm || weaponClass == WeaponClass.Mace || weaponClass == WeaponClass.TwoHandedMace)
			{
				GameEntity gameEntity13 = scene.FindEntityWithTag("spear_camera");
				Vec3 vec8 = default(Vec3);
				gameEntity13.GetCameraParamsFromCameraScript(camera, ref vec8);
				gameEntity13.SetVisibilityExcludeParents(false);
				Vec3 v12 = itemFrame.TransformToLocal(v4);
				MatrixFrame identity7 = MatrixFrame.Identity;
				identity7.origin = -v12;
				GameEntity gameEntity14 = scene.FindEntityWithTag("spear");
				gameEntity14.SetVisibilityExcludeParents(false);
				itemFrame = gameEntity14.GetGlobalFrame();
				itemFrame = itemFrame.TransformToParent(identity7);
			}
		}
    }