We've got enemies and movement!!

This commit is contained in:
Matt F 2026-05-12 22:18:23 -07:00
parent 42ee0bf65d
commit 3287e8ea43
26 changed files with 1409 additions and 161 deletions

View file

@ -15,14 +15,13 @@ namespace TD.Gameplay
/// the full ScriptableObject locally on every client. TowerRegistry is the lookup
/// table that makes that resolution possible without hard-coding asset paths.</para>
///
/// <para><b>Auto-discovery.</b> On Awake, all <see cref="TowerDefinition"/> assets
/// under <c>Resources/TowerDefinitions/</c> are loaded automatically. No inspector
/// drag-and-drop required — add a new asset to that folder and it is registered at
/// runtime with no other changes needed. This scales cleanly to 100+ tower types.</para>
/// <para><b>Registration.</b> Drag every <see cref="TowerDefinition"/> asset into the
/// <c>Definitions</c> list on this component in the inspector. Assets can live anywhere
/// in the project — no special folder required.</para>
///
/// <para><b>Path E upgrade path.</b> In Path E the registry will filter to only the
/// definitions belonging to the active match's <c>RaceDefinition</c> rosters. For now
/// all assets in the Resources folder are registered.</para>
/// all assigned assets are registered.</para>
///
/// <para><b>Plain MonoBehaviour.</b> Not a NetworkBehaviour — the registry is
/// identical on every peer (same assets, same names), so there is nothing to sync.</para>
@ -37,14 +36,12 @@ namespace TD.Gameplay
/// </summary>
public static TowerRegistry Instance { get; private set; }
// ----- Constants --------------------------------------------------
// ----- Inspector --------------------------------------------------
/// <summary>
/// Resources-relative folder path that TowerDefinition assets must live under
/// to be auto-discovered. Create this folder if it doesn't exist.
/// Full path: Assets/Resources/TowerDefinitions/
/// </summary>
private const string ResourcesFolder = "TowerDefinitions";
[Tooltip("All TowerDefinition assets available in this match. " +
"Drag assets here from Assets/_Project/Data/TowerDefinitions/ " +
"(or wherever they live). Asset name is used as the registry key.")]
[SerializeField] private TowerDefinition[] definitions;
// ----- Internal lookup table --------------------------------------
@ -96,21 +93,14 @@ namespace TD.Gameplay
{
byName.Clear();
// Resources.LoadAll finds every TowerDefinition asset anywhere under
// Assets/Resources/TowerDefinitions/ (including sub-folders).
// No manual registration needed — drop an asset in the folder and it
// is available on the next play session.
var loaded = Resources.LoadAll<TowerDefinition>(ResourcesFolder);
if (loaded.Length == 0)
if (definitions == null || definitions.Length == 0)
{
Debug.LogWarning($"[TowerRegistry] No TowerDefinition assets found under " +
$"Resources/{ResourcesFolder}/. " +
$"Create the folder and add TowerDefinition assets to it.");
Debug.LogWarning("[TowerRegistry] No TowerDefinition assets assigned. " +
"Drag assets into the Definitions list on the TowerRegistry component.");
return;
}
foreach (var def in loaded)
foreach (var def in definitions)
{
if (def == null) continue;
@ -124,8 +114,7 @@ namespace TD.Gameplay
byName[def.name] = def;
}
Debug.Log($"[TowerRegistry] Auto-discovered and registered " +
$"{byName.Count} tower definition(s) from Resources/{ResourcesFolder}/.");
Debug.Log($"[TowerRegistry] Registered {byName.Count} tower definition(s).");
}
}
}