public static ObjectInteraction CreateObjectInteraction(GameObject myObj, GameObject parentObj,float DimX,float DimY,float DimZ, float CenterY, string WorldString, string InventoryString, string EquipString, int ItemType, int ItemId, int link, int Quality, int Owner, int isMoveable, int isUsable, int isAnimated, int useSprite, int isQuant, int isEnchanted, int flags, int inUseFlag)
{
ObjectInteraction objInteract = myObj.AddComponent<ObjectInteraction>();
BoxCollider box =myObj.GetComponent<BoxCollider>();
if ((box==null) && (myObj.GetComponent<NPC>()==null) && (isUsable==1))
{
//add a mesh for interaction
box= myObj.AddComponent<BoxCollider>();
box.size = new Vector3(0.2f,0.2f,0.2f);
box.center= new Vector3(0.0f,0.1f,0.0f);
if (isMoveable==1)
{
box.material= Resources.Load<PhysicMaterial>("Materials/objects_bounce");
}
}
objInteract.WorldDisplayIndex = int.Parse(WorldString.Substring (WorldString.Length-3,3));
objInteract.InvDisplayIndex= int.Parse (InventoryString.Substring (InventoryString.Length-3,3));
if (isUsable==1)
{
objInteract.CanBeUsed=true;
}
//SpriteRenderer objSprite = myObj.transform.FindChild(myObj.name + "_sprite").GetComponent<SpriteRenderer>();
// SpriteRenderer objSprite = parentObj.GetComponentInChildren<SpriteRenderer>();
// objInteract.WorldString=WorldString;
// objInteract.InventoryString=InventoryString;
//objInteract.EquipString=EquipString;
//objInteract.InventoryDisplay=InventoryString;
//objInteract.GetItemType()=ItemType;//UWexporter id type
objInteract.item_id=ItemId;//Internal ItemID
objInteract.Link=link;
objInteract.Quality=Quality;
objInteract.Owner=Owner;
objInteract.flags=flags;
//if (inUseFlag==1)
//{
//objInteract.InUse=true;
//}
if (isMoveable==1)
{
objInteract.CanBePickedUp=true;
Rigidbody rgd = parentObj.AddComponent<Rigidbody>();
rgd.angularDrag=0.0f;
GameWorldController.FreezeMovement(myObj);
}
if (ItemType !=ObjectInteraction.ANIMATION)
{
if (isAnimated==1)
{
objInteract.isAnimated=true;
}
if (useSprite==1)
{
objInteract.ignoreSprite=false;
}
else
{
objInteract.ignoreSprite=true;
}
}
else
{
objInteract.ignoreSprite=true;
}
if (isQuant==1)
{
objInteract.isQuant=true;
}
if (isEnchanted==1)
{
objInteract.isEnchanted=true;
Debug.Log (myObj.name + " is enchanted. Take a look at it please.");
}
return objInteract;
}