/// <summary> /// Creates a generic loot container. /// </summary> /// <param name="containerType">Type of container.</param> /// <param name="containerImage">Icon to display in loot UI.</param> /// <param name="position">Position to spawn container.</param> /// <param name="parent">Parent GameObject.</param> /// <param name="textureArchive">Texture archive for billboard containers.</param> /// <param name="textureRecord">Texture record for billboard containers.</param> /// <param name="loadID">Unique LoadID for save system.</param> /// <returns>DaggerfallLoot.</returns> public static DaggerfallLoot CreateLootContainer( LootContainerTypes containerType, InventoryContainerImages containerImage, Vector3 position, Transform parent, int textureArchive, int textureRecord, ulong loadID = 0) { // Setup initial loot container prefab GameObject go = InstantiatePrefab(DaggerfallUnity.Instance.Option_LootContainerPrefab.gameObject, containerType.ToString(), parent, position); // Setup billboard component DaggerfallBillboard dfBillboard = go.GetComponent <DaggerfallBillboard>(); dfBillboard.SetMaterial(textureArchive, textureRecord); // Setup DaggerfallLoot component to make lootable DaggerfallLoot loot = go.GetComponent <DaggerfallLoot>(); if (loot) { loot.LoadID = loadID; loot.ContainerType = containerType; loot.ContainerImage = containerImage; loot.TextureArchive = textureArchive; loot.TextureRecord = textureRecord; } // Now move up loot icon by half own size so bottom is aligned with position position.y += (dfBillboard.Summary.Size.y / 2f); loot.transform.position = position; return(loot); }
/// <summary> /// Creates a generic loot container. /// </summary> /// <param name="containerType">Type of container.</param> /// <param name="containerImage">Icon to display in loot UI.</param> /// <param name="position">Position to spawn container.</param> /// <param name="parent">Parent GameObject.</param> /// <param name="textureArchive">Texture archive for billboard containers.</param> /// <param name="textureRecord">Texture record for billboard containers.</param> /// <param name="loadID">Unique LoadID for save system.</param> /// <returns>DaggerfallLoot.</returns> public static DaggerfallLoot CreateLootContainer( LootContainerTypes containerType, InventoryContainerImages containerImage, Vector3 position, Transform parent, int textureArchive, int textureRecord, ulong loadID = 0) { // Setup initial loot container prefab GameObject go = InstantiatePrefab(DaggerfallUnity.Instance.Option_LootContainerPrefab.gameObject, containerType.ToString(), parent, position); // Setup billboard component DaggerfallBillboard dfBillboard = go.GetComponent<DaggerfallBillboard>(); dfBillboard.SetMaterial(textureArchive, textureRecord); // Setup DaggerfallLoot component to make lootable DaggerfallLoot loot = go.GetComponent<DaggerfallLoot>(); if (loot) { loot.LoadID = loadID; loot.ContainerType = containerType; loot.ContainerImage = containerImage; loot.TextureArchive = textureArchive; loot.TextureRecord = textureRecord; } // Now move up loot icon by half own size so bottom is aligned with position position.y += (dfBillboard.Summary.Size.y / 2f); loot.transform.position = position; return loot; }