Create a simple dialogue authoring system, tied into our items (#10)

- Editor dialogue graph
- Asset importer for processing the graph into runtime data
- DialogueComponent that steers the dialogue interactions
- DialogueCanbas with a scalable speech bubble to display everything
- Brief README overview of the system

Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com>
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: #10
This commit is contained in:
2025-09-29 09:34:15 +00:00
parent 2cd791f69d
commit f686f28cb8
73 changed files with 6530 additions and 173 deletions

View File

@@ -1,18 +1,58 @@
using UnityEngine;
using System.Collections.Generic;
using System;
[CreateAssetMenu(fileName = "PickupItemData", menuName = "Game/Pickup Item Data")]
public class PickupItemData : ScriptableObject
{
[SerializeField] private string _itemId;
public string itemName;
[TextArea]
public string description;
public Sprite mapSprite;
// Read-only property for itemId
public string itemId => _itemId;
// Auto-generate ID on creation or validation
void OnValidate()
{
// Only generate if empty
if (string.IsNullOrEmpty(_itemId))
{
_itemId = GenerateItemId();
#if UNITY_EDITOR
// Mark the asset as dirty to ensure the ID is saved
UnityEditor.EditorUtility.SetDirty(this);
#endif
}
}
private string GenerateItemId()
{
// Use asset name as the basis for the ID to keep it somewhat readable
string baseName = name.Replace(" ", "").ToLowerInvariant();
// Add a unique suffix based on a GUID
string uniqueSuffix = Guid.NewGuid().ToString().Substring(0, 8);
return $"{baseName}_{uniqueSuffix}";
}
// Method to manually regenerate ID if needed (for editor scripts)
public void RegenerateId()
{
_itemId = GenerateItemId();
}
public static bool AreEquivalent(PickupItemData a, PickupItemData b)
{
if (ReferenceEquals(a, b)) return true;
if (a is null || b is null) return false;
// First compare by itemId if available
if (!string.IsNullOrEmpty(a.itemId) && !string.IsNullOrEmpty(b.itemId))
return a.itemId == b.itemId;
// Compare by itemName as a fallback
return a.itemName == b.itemName;
}