private GameEntity AddItem(Scene scene, ItemObject item, MatrixFrame itemFrame, MatrixFrame itemFrame1, MatrixFrame itemFrame2)
{
ItemRosterElement rosterElement = new ItemRosterElement(item, 0, null);
MetaMesh itemMeshForInventory = rosterElement.GetItemMeshForInventory(false);
if (item.IsCraftedWeapon)
{
MatrixFrame frame = itemMeshForInventory.Frame;
frame.Elevate(-item.WeaponDesign.CraftedWeaponLength / 2f);
itemMeshForInventory.Frame = frame;
}
GameEntity gameEntity = null;
if (itemMeshForInventory != null && rosterElement.EquipmentElement.Item.ItemType == ItemObject.ItemTypeEnum.HandArmor)
{
gameEntity = GameEntity.CreateEmpty(scene, true);
AnimationSystemData animationSystemData = Game.Current.HumanMonster.FillAnimationSystemData(MBGlobals.PlayerMaleActionSet, 1f, false);
AgentVisualsNativeData agentVisualsNativeData = Game.Current.HumanMonster.FillAgentVisualsNativeData();
gameEntity.CreateSkeletonWithActionSet(ref agentVisualsNativeData, ref animationSystemData);
gameEntity.SetFrame(ref itemFrame);
gameEntity.Skeleton.SetAgentActionChannel(0, this.act_tableau_hand_armor_pose, 0f, -0.2f);
gameEntity.AddMultiMeshToSkeleton(itemMeshForInventory);
gameEntity.Skeleton.TickAnimationsAndForceUpdate(0.01f, itemFrame, true);
}
else if (itemMeshForInventory != null)
{
if (item.WeaponComponent != null)
{
WeaponClass weaponClass = item.WeaponComponent.PrimaryWeapon.WeaponClass;
if (weaponClass == WeaponClass.ThrowingAxe || weaponClass == WeaponClass.ThrowingKnife || weaponClass == WeaponClass.Javelin || weaponClass == WeaponClass.Bolt)
{
gameEntity = GameEntity.CreateEmpty(scene, true);
MetaMesh metaMesh = itemMeshForInventory.CreateCopy();
metaMesh.Frame = itemFrame;
gameEntity.AddMultiMesh(metaMesh, true);
MetaMesh metaMesh2 = itemMeshForInventory.CreateCopy();
metaMesh2.Frame = itemFrame1;
gameEntity.AddMultiMesh(metaMesh2, true);
MetaMesh metaMesh3 = itemMeshForInventory.CreateCopy();
metaMesh3.Frame = itemFrame2;
gameEntity.AddMultiMesh(metaMesh3, true);
}
else
{
gameEntity = scene.AddItemEntity(ref itemFrame, itemMeshForInventory);
}
}
else
{
gameEntity = scene.AddItemEntity(ref itemFrame, itemMeshForInventory);
if (item.Type == ItemObject.ItemTypeEnum.HorseHarness && item.ArmorComponent != null)
{
MetaMesh copy = MetaMesh.GetCopy(item.ArmorComponent.ReinsMesh, true, true);
if (copy != null)
{
gameEntity.AddMultiMesh(copy, true);
}
}
}
}
else
{
MBDebug.ShowWarning("[DEBUG]Item with " + rosterElement.EquipmentElement.Item.StringId + "[DEBUG] string id cannot be found");
}
gameEntity.SetVisibilityExcludeParents(false);
return gameEntity;
}