public void CraftConstructionBuildMode(ConstructionData item, bool pay_craft_cost = true, UnityAction <Buildable> callback = null) { if (!pay_craft_cost || CanCraft(item)) { CancelCrafting(); Construction construction = Construction.CreateBuildMode(item, transform.position + transform.forward * 1f); current_buildable = construction.GetBuildable(); current_buildable.StartBuild(character); current_build_data = item; clicked_build = false; build_pay_cost = pay_craft_cost; build_callback = callback; build_timer = 0f; } }
public void BuildItem(InventoryData inventory, int slot) { InventoryItemData invdata = inventory?.GetItem(slot); ItemData idata = ItemData.Get(invdata?.item_id); if (invdata != null && idata != null) { ConstructionData construct = idata.construction_data; PlantData aplant = idata.plant_data; CharacterData acharacter = idata.character_data; if (construct != null) { inventory.RemoveItemAt(slot, 1); Construction construction = character.Crafting.CraftConstruction(construct, false); BuiltConstructionData constru = PlayerData.Get().GetConstructed(construction.GetUID()); if (idata.HasDurability()) { constru.durability = invdata.durability; //Save durability } TheAudio.Get().PlaySFX("craft", construction.GetBuildable().build_audio); } else if (aplant != null) { inventory.RemoveItemAt(slot, 1); Plant plant = character.Crafting.CraftPlant(aplant, 0, false); TheAudio.Get().PlaySFX("craft", plant.GetBuildable().build_audio); } else if (acharacter != null) { inventory.RemoveItemAt(slot, 1); Character charact = character.Crafting.CraftCharacter(acharacter, false); TheAudio.Get().PlaySFX("craft", charact.GetBuildable().build_audio); } PlayerUI.Get(character.player_id)?.CancelSelection(); } }