Added Dohya
This commit is contained in:
@@ -24,6 +24,35 @@ public sealed class ItemProcessingRecipe : ScriptableObject
|
||||
(!string.IsNullOrEmpty(inputItem.ItemId) && item.ItemId == inputItem.ItemId);
|
||||
}
|
||||
|
||||
private void OnValidate() =>
|
||||
public bool TryValidateOutputPrefab(out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
if (outputItem == null || outputItem.WorldPrefab == null)
|
||||
return true;
|
||||
|
||||
NetworkItem prefabItem = outputItem.WorldPrefab.GetComponent<NetworkItem>();
|
||||
if (prefabItem == null)
|
||||
{
|
||||
error = $"Output prefab '{outputItem.WorldPrefab.name}' has no NetworkItem.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prefabItem.Definition == outputItem)
|
||||
return true;
|
||||
|
||||
string actualOutput = prefabItem.Definition != null
|
||||
? prefabItem.Definition.name
|
||||
: "None";
|
||||
error = $"Output item '{outputItem.name}' points to prefab " +
|
||||
$"'{outputItem.WorldPrefab.name}', but that prefab uses definition " +
|
||||
$"'{actualOutput}'.";
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
recipeId = recipeId?.Trim().ToLowerInvariant();
|
||||
if (!TryValidateOutputPrefab(out string error))
|
||||
Debug.LogError($"Invalid processing recipe '{name}': {error}", this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user