first commit

This commit is contained in:
2026-06-04 23:22:13 +03:00
commit d329f501be
310 changed files with 36395 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
using System;
using System.Text;
using OTGIntegrated.Items;
using UnityEngine;
namespace OTGIntegrated.Crafting
{
[Serializable]
public sealed class Ingredient
{
public ItemData item;
[Min(1)] public int amount = 1;
}
[CreateAssetMenu(fileName = "RecipeData", menuName = "OTG Integrated/Recipe Data")]
public sealed class RecipeData : ScriptableObject
{
public string recipeId;
public string displayName;
[TextArea(2, 5)] public string description;
public Ingredient[] ingredients;
public ItemData resultItem;
[Min(1)] public int resultAmount = 1;
private void OnValidate()
{
if (string.IsNullOrWhiteSpace(recipeId))
{
recipeId = name;
}
if (string.IsNullOrWhiteSpace(displayName))
{
displayName = recipeId;
}
resultAmount = Mathf.Max(1, resultAmount);
}
public string GetIngredientsText()
{
if (ingredients == null || ingredients.Length == 0)
{
return "Без ингредиентов";
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < ingredients.Length; i++)
{
Ingredient ingredient = ingredients[i];
if (ingredient == null || ingredient.item == null)
{
continue;
}
if (builder.Length > 0)
{
builder.Append(", ");
}
builder.Append(ingredient.item.displayName);
builder.Append(" x");
builder.Append(ingredient.amount);
}
return builder.Length == 0 ? "Без ингредиентов" : builder.ToString();
}
}
}